title: Prolog Constraint Processing : Packing Squares
body: <p>I'm trying to solve a constraint processing problem in prolog.</p>
  
  <p>I need to pack 4 squares of 5x5,4x4,3x3 and 2x2 in a grid of 10x10.
  They may not overlap.</p>
  
  <p>My variables look like this:</p>
  
  <pre><code>Name: SqX(i), i=1..10, domain: 1..10
  </code></pre>
  
  <p>Where X is either 5,4,3 or 2. The index i represents the row, the domain the column in the grid.</p>
  
  <p>My first constraints try to define the width and height of the squares. I formulate it as such:</p>
  
  <pre><code>Constraint: SqX(i) &gt; SqX(j)-X /\ i&gt;j-X, range: i&gt;0 /\ j&gt;0
  </code></pre>
  
  <p>So that the possible points are constrained to be within X rows and columns from each other.
  Prolog however, stops on these constraints and gives the following result:</p>
  
  <pre><code>Adding constraint "(Sq5_I &gt; Sq5_J-5) /\ (I&gt;J-5)" for values:
          I=1, J=1, 
          I=1, J=2, 
          I=1, J=3, 
          I=1, J=4, 
          I=1, J=5, 
          I=1, J=6, 
  =======================[ End Solutions ]=======================
  </code></pre>
  
  <p>So it stops there, not even checking the other squares. My constraints are most likely too tight, but I can't see why or how. Any suggestions?</p>