top | item 20152115

(no title)

new4thaccount | 6 years ago

Thanks for your hard work. I really want to like Prolog, but I often don't know how to fit it into an actual system of use.

My field is power systems which involves solving numerical problems with large sparse matrices and very large scale optimization problems (millions of constraints) using LP and MIP solvers.

The first class of problems can be easily solved with tools like Matlab, Fortran, Python, Julia, C++...etc. The optimization problems can be solved with any language that has a library to talk to a solver.

Prolog is really cool, but I doubt it could solve problems of that size even if given days, much less a few minutes. I'd love to be proven wrong, but it seems like it really excels at these small toy problems. Could you enlighten my ignorance on how it can be used on larger scale problems? Thanks in advance!

discuss

order

hjek|6 years ago

I haven't used Prolog at that scale myself, but I'll just add completely unsubstantiated hearsay from the ##Prolog IRC on FreeNode: Someone reported no problems using SWI Prolog for running queries on "59 million facts".

It might also be worth checking Triska's video about n-queens[0] where the last 2/3 is all about optimising the search and using different labelling strategies.

Don't know if it's relevant for your problem, but memoization is also a thing in Prolog[1] like in other languages.

Maybe not the answer you're looking for. Is your system relatively simple to describe? Then we can give it a try...

[0]: https://invidio.us/watch?v=l_tbL9RjFdo

[1]: https://swish.swi-prolog.org/example/tabling.swinb

new4thaccount|6 years ago

59M sounds pretty sweet!

I'll check out Triska's videos when I pick up my Prolog book on writing a text adventure again. It's pretty much the only Prolog book that helps walk me through it without the theory. I do like theory, but I need a high level overview first before I can make sense of anything.

The basics of the system are very easy to describe, but realistic system implementations are waaay more complex and have hundreds of pages of solver code and SQL packages. A very simple example on a tiny system would be the below:

https://www.juliaopt.org/notebooks/Dvorkin%20-%20Power%20sys...