News for hackers. Stuff that matters.
Re:Using Simulated Annealing to Solve Logic Puzzles by osense on Monday July 18, 2016 @03:40AM (#12113683)
Another fun way to solve this is using Logic programming, e.g. http://baptiste-wicht.com/posts/2010/09/solve-einsteins-ridd...
Re:Using Simulated Annealing to Solve Logic Puzzles by kriro on Monday July 18, 2016 @05:03AM (#12113932)
Indeed anything with constraints is usually a great use case for Prolog. I particularly like this version in ECLiPSe which is specialized on constraint programming with Prolog: https://gist.github.com/JuanitoFatas/2227711

I haven't benchmarked it but it is pretty intuitive to read which is very important for these types of problems.

Re:Using Simulated Annealing to Solve Logic Puzzles by nurettin on Monday July 18, 2016 @12:31PM (#12116100)
This is the best prolog solution I've seen for this kind of puzzle. Other solutions all had to define a bunch of primitives for neighborhood constraints.
Re:Using Simulated Annealing to Solve Logic Puzzles by osense on Monday July 18, 2016 @11:55AM (#12115813)
Very concise and easy to read, I like it :)
Re:Using Simulated Annealing to Solve Logic Puzzles by gort on Monday July 18, 2016 @12:09PM (#12115931)
The article mentions the problem of "local minimums". The author suggests occasionally accepting worse solutions, in order to escape from such. "The hope here is that by following this worse solution, we can eventually get to the global minimum." This is good but one may wish to take it further.

I once messed with something called "metropolis coupling", where you run multiple threads in parallel, with different thresholds for how often they accept worse solutions, i.e. one thread is "cold", one is slightly "hotter", and so on. If a hot thread's current solution is better than the solution of the neighbouring colder thread, the solutions are swapped. In this way the coldest thread (which is the one we're paying attention to) gets pulled out of the local minimum.

As I say, I messed with this once and it did seem to help. It seems to have been developed for inference in evolutionary phylogenetics, and is perhaps a bit obscure?

Re:Using Simulated Annealing to Solve Logic Puzzles by ChronosKey on Monday July 18, 2016 @12:55PM (#12116303)
Hi, author here:

Yep, this is the sort of thing we study in our cooperative and adaptive algorithms class. Similar techniques to what you suggest are shown here https://books.google.ca/books?id=G5ML5EYch94C&pg=PA88&lpg=PA...

Re:Using Simulated Annealing to Solve Logic Puzzles by klausnrooster on Sunday July 31, 2016 @11:30PM (#12200049)
Looks neat but I gave up on it converging on my new laptop. I'm going to port it to rebol2. This bit confuses me:

  random.choice(range(0, i) + range(i+1, 4))
how is that different from

  random.choice(range(0, 4))? 
Obviously no Pythonista, but playing around in the REPL I see no diff.
Re:Using Simulated Annealing to Solve Logic Puzzles by klausnrooster on Monday August 01, 2016 @09:16PM (#12207249)
Duh. Where is the button that reverses the passage of time?
Re:Using Simulated Annealing to Solve Logic Puzzles by murbard2 on Monday July 18, 2016 @09:44PM (#12119029)
This has the advantage of working as a sampling strategy, not just an optimization strategy. It is useful when the mass of your distribution is concentrated in a region that may be hard to find with a random walk.

https://en.wikipedia.org/wiki/Parallel_tempering

Markov-chain Monte-Carlo sampling gives a theoretical underpinning which explains why simulated annealing works in optimization.

Re:Using Simulated Annealing to Solve Logic Puzzles by tekromancr on Monday July 18, 2016 @12:53PM (#12116293)
That's actually pretty brilliant. I haven't ever heard of metropolis coupling before, but I can see how it would break the algo out of a local minimum. Also, klaatu barada nikto.
Re:Using Simulated Annealing to Solve Logic Puzzles by placebo on Monday July 18, 2016 @05:35AM (#12114030)
Nice. I've used Simulated Annealing to achieve good results in problems were the solution space was too large for constraint programming, but for this specific sort of problems I've had good experience using constraint programming frameworks like GECODE or choco
Re:Using Simulated Annealing to Solve Logic Puzzles by doomrobo on Monday July 18, 2016 @09:03AM (#12114790)
A lot of people here mention Prolog as another tool to solve this problem. I wonder if there's a natural way to combine constraint solving with simulated annealing.
Re:Using Simulated Annealing to Solve Logic Puzzles by rsingla on Monday July 18, 2016 @01:59AM (#12113428)
A very well written post on Simulated Annealing, and a fun puzzle to solve (even if it is old!)
Re:Using Simulated Annealing to Solve Logic Puzzles by jawns on Monday July 18, 2016 @09:30AM (#12114915)
If you like this sort of thing, I wrote some code a couple of years ago to generate and solve logical deduction problems, such as the "Cheryl's Birthday" brainteaser:

https://github.com/shaungallagher/cheryls-murder/blob/master...

The code isn't very clean (it was written hastily as part of a hack days project at work) but the notebook walks you through it, so even if you're not familiar with Python, you'll get a sense of the technique.

Re:Using Simulated Annealing to Solve Logic Puzzles by baldeagle on Sunday July 17, 2016 @11:34PM (#12113108)
Bonus points for including code in python to solve arbitrary logic puzzles.
Re:Using Simulated Annealing to Solve Logic Puzzles by agentultra on Monday July 18, 2016 @09:42AM (#12114967)
I've used simulated annealing to make constraint solvers more efficient. The nice thing about constraint solvers and simulated annealing as demonstrated is that it's fairly straight forward to adapt the algorithm to your specific problem and data in order to get the best performance.
Re:Using Simulated Annealing to Solve Logic Puzzles by tunesmith on Sunday July 17, 2016 @11:48PM (#12113136)
So, what does it mean exactly when they say that these kinds of problems are in the same class as Sudoku?
Re:Using Simulated Annealing to Solve Logic Puzzles by ChronosKey on Monday July 18, 2016 @12:18AM (#12113203)
Simulated annealing and similar techniques such as Tabu Search are good for problems that have large search spaces due to combinatorial explosion (https://en.wikipedia.org/wiki/Combinatorial_explosion) and can be expressed as a state and an associated cost/fitness function.
Re:Using Simulated Annealing to Solve Logic Puzzles by yummyfajitas on Monday July 18, 2016 @03:49AM (#12113715)
This is true provided your cost function is "continuous" w.r.t. distance. Roughly what this means is that if you make a small change - e.g. one edit in this example - then your cost function shouldn't change a lot.

If you don't have some form of continuity condition you are actually just doing random search.

Re:Using Simulated Annealing to Solve Logic Puzzles by waynecochran on Monday July 18, 2016 @12:39AM (#12113243)
Re:Using Simulated Annealing to Solve Logic Puzzles by machinelearning on Sunday July 17, 2016 @11:59PM (#12113161)
both problems have constraints and you solve the puzzle by finding the right configuration of data that meets the constraints.
Re:Using Simulated Annealing to Solve Logic Puzzles by kej on Monday July 18, 2016 @11:40AM (#12115705)
They're both examples of an exact cover problem: https://en.wikipedia.org/wiki/Exact_cover
Re:Using Simulated Annealing to Solve Logic Puzzles by makeset on Monday July 18, 2016 @03:28PM (#12117495)
Constraint Satisfaction Problems can be modeled as Hopfield-type neural networks, such as Boltzmann machines (RBMs of deep learning are a variant) which can be tuned using simulated annealing.

There was plenty of research on this around 1985-1995 (the "second coming" of neural networks), but it died out with the hype because it was never an actually practical way to solve CSPs. Given the recent innovations in deep learning, it should eventually pick up again, to enable deep learners to solve constraint satisfaction subproblems within the same integrated architecture.

Re:Using Simulated Annealing to Solve Logic Puzzles by cordite on Monday July 18, 2016 @09:55AM (#12115022)
This sounds exactly like this game: http://www.kaser.com/sherwin.html

There's relational properties, combinations, and maybes all over

Re:Using Simulated Annealing to Solve Logic Puzzles by Anilm3 on Monday July 18, 2016 @08:54AM (#12114746)
Really interesting, I wrote a logic puzzle solver in Prolog a long time ago while I was in uni, I just created a repo for anyone who wants to check it out. Unfortunately the documentation and comments are all in Spanish...

https://github.com/Anilm3/Logic-Puzzle-Solver

Re:Using Simulated Annealing to Solve Logic Puzzles by anthk on Monday July 18, 2016 @04:38PM (#12117932)
Al menos podías haber dejado "head-tail", es más intuitivo.

Gracias de todo modos ;)

Re:Using Simulated Annealing to Solve Logic Puzzles by rahimnathwani on Monday July 18, 2016 @04:01AM (#12113758)
Tweaking 't' here seems to be similar to tweaking the learning rate in gradient descent. But in gradient descent you assume the problem is convex.

Is there any way to tell whether this logic problem (or any other) is convex? Is it possible that the correct solution's 5-away neighbours all have very high costs (like 9+)? What prevents you from doing worse that brute force?

Re:Using Simulated Annealing to Solve Logic Puzzles by jasdeepsingh on Monday July 18, 2016 @08:22AM (#12114615)
What if we change the cost function to something that returns a number which has a direct correlation with the maximum number of attributes that matched? Would solving the problem be any easier or we would still leave the possibility of getting stuck in local optimums just like the one described in the post?
Re:Using Simulated Annealing to Solve Logic Puzzles by rahimnathwani on Monday July 18, 2016 @08:39AM (#12114687)
What do you mean by the 'maximum number of attributes that matched'? How is it different from the number of conditions that are satisfied?
Re:Using Simulated Annealing to Solve Logic Puzzles by jnwrd on Monday July 18, 2016 @06:52AM (#12114285)
I wonder if Quantum Annealing would also be applicable.
Re:Using Simulated Annealing to Solve Logic Puzzles by leni536 on Monday July 18, 2016 @08:35AM (#12114665)
I think in theory it is possible by unary encoding attributes of the five houses then defining the appropriate weights according to the constraints.

In practice it might not be possible to map the resulting graph on the D-Wave's architecture, I can't find any good documentation on the D-Wave though.