A Constraint-Based Local Search solver for the Water Retention on Magic Squares-problem.

The problem is a very hard combinatorial optimisation problem, invented by Craig Knecht. More can be read about it at:

Craig's website for the problem:

The solver is mainly based on the theory and ideas from my bachelor thesis, which I wrote at Uppsala University, Sweden, for the Astra Group which does research about Constraint Programming and related technologies:

Water Retention on Magic Squares with Constraint-Based Local Search

I 'm posting two solvers in this project. One written in C++ which is the fastest, at least for the heavier objective functions, and a Dynadec Comet solver which lets you easily post new constraints along with the Magic-constraints.

Author: Johan Öfverstedt

Project Samples

Project Activity

See All Activity >

Follow Water Retention on Magic Squares Solver

Water Retention on Magic Squares Solver Web Site

Other Useful Business Software

SolarWinds is #1 in network monitoring. SolarWinds is #1 in network monitoring. Icon
SolarWinds is #1 in network monitoring. Icon

Reduce network outages and improve performance with advanced network monitoring software.

SolarWinds® Network Performance Monitor (NPM) is the ONLY monitoring solution with NetPath™ for hop-by-hop visibility into your critical paths, on-premises and into the cloud. NPM also features PerfStack™, helping you accelerate identification of root cause by dragging-and-dropping network performance metrics on a common timeline for immediate visual correlation across all of your network data. See why we're the leader. Try it free for 30 days!

Rate This Project

Login To Rate This Project

User Ratings

ease 1 of 5 2 of 5 3 of 5 4 of 5 5 of 5 0 / 5
features 1 of 5 2 of 5 3 of 5 4 of 5 5 of 5 0 / 5
design 1 of 5 2 of 5 3 of 5 4 of 5 5 of 5 0 / 5
support 1 of 5 2 of 5 3 of 5 4 of 5 5 of 5 0 / 5

User Reviews

  • Reliable and runs smoothly

  • Many famous mathematicians have previously signed the magic square guest book - Ben Franklin, Euler, Planck. De La Loubere's method for constructing magic squares shows the ingenuity of a bygone era. Johan's program is the modern equivalent of the De La Loubere's method. The magic square community is ecstatic to have this capability. Check out the tribute to Durer's 1514 magic square in the Associative_magic_square wiki that this program made possible. See the adaptations being make to this code in Harry White's Bordered Magic Square website (COMPLETE utility in the download section) My suggestion for Johan's next update would be to add the capability of specifying a set pattern to be searched. Example: I tried to find the maximum retention for the 13 x 13 associative magic square. It is always fun to be the first one to find a new record with a new free program. The program uses all its time searching for the best solution .. 6928 was what I found. I put the skeleton of that pattern .. ie the lake and pond borders into the F1 compiler and was able to boost the retention to 6944. This program is going to easily produce new records but it needs a second pass refinement capability of being able to specify the pattern from the first search as the basis of a second search. Great work Johan, Thanks !

Read more reviews >

Additional Project Details

Intended Audience


User Interface

Console/Terminal, Command-line

Programming Language