Download
language ESSENCE 1.2.0
$ prob009.essence: Perfect Square Placement
$ Problem details available at http://www.csplib.org/Problems/prob009/
$ 05 September 2007
$

given nbSizes : int(1..)
letting sizes be domain int(1..nbSizes)

letting container_size be sum i : sizes . 1

where (sum s : sizes . s**2) = container_size**2

letting Index be domain int(0..container_size-1)
letting Square be domain sizes

find x, y : function (total) Square --> Index

such that
    forAll s : Square . x(s) + s < container_size /\ y(s) + s < container_size,
    forAll s1,s2 : Square , s1 != s2 .
        max({x(s1),x(s2)}) - min({x(s1)+s1,x(s2)+s2}) >= 0 \/
        max({y(s1),y(s2)}) - min({y(s1)+s1,y(s2)+s2}) >= 0