/* Our E-GENET implementation is embedded in clp(FD), being used as a modeling language. Execution of the program amounts to setting up the constraints in the constraint store and invoke the E-GENET solver using the last goal labeling(L, 0, max_regret, indomain) in the definition of top/1. Note that the program also conforms to CHIP's syntax. */ top(Rectangles) :- create_customers(Rectangles), diffn(Rectangles, unused, unused, unused, unused, unused), get_dvar(Rectangles, L), L = [6,2,12,4,22,1,32,3,9,4,11,3,19,2,26,1,5,3,11,4,23,1,35,2,10,2,17,1,25,4,34,3,1,1,13,2,24,4,35,3,7,3,13,4,20,1,32,2,4,1,16,4,18,3,27,2,10,4,13,3,18,2,34,1,7,1,17,2,23,3,26,4,5,4,16,3,25,2,30,1,5,2,15,3,24,1,32,4,8,4,15,1,22,3,29,2,7,4,17,3,21,1,31,2,2,1,14,4,20,2,31,3,9,2,16,1,18,4,30,3,1,3,12,2,19,1,29,4,7,2,15,4,18,1,28,3,6,4,14,2,21,3,35,1,10,3,13,1,21,2,27,4,3,3,14,1,22,4,33,2,28,1,2,3,19,4,29,3,2,2,17,4,12,3,8,2,31,4,4,3,34,4,11,1,4,2,33,4,24,3,34,2,19,3,6,1,1,2,20,3,29,1,9,3,30,2,12,1,23,4,3,2,27,3,24,2,1,4,33,1,23,2,6,3,28,4,21,4,33,3,3,1,8,3,22,2,27,1,10,1,26,2,20,4,15,2,32,1,4,4,3,4,26,3,25,1,35,4,25,3,5,1,9,1,30,4,16,2,31,1,2,4,11,2,8,1,14,3,28,2], labeling(L, 0, max_regret, indomain). create_customers(Rectangles) :- length(Group1, 80), create1(Group1), length(Group2, 60), create2(Group2), append(Group1, Group2, Rectangles). create1([]) :- !. create1([[X1,Y1,1,1],[X2,Y2,1,1],[X3,Y3,1,1],[X4,Y4,1,1]|Rest]) :- X1 :: 1..10, X2 :: 11..17, X3 :: 18..25, X4 :: 26..35, [Y1, Y2, Y3, Y4] :: 1..4, alldifferent([Y1, Y2, Y3, Y4]), create1(Rest). create2([]) :- !. create2([[X1,Y1,1,1],[X2,Y2,1,1],[X3,Y3,1,1]|Rest]) :- [X1, X2, X3] :: 1..35, Zone = [1,1,1,1,1,1,1,1,1,1, 2,2,2,2,2,2,2, 3,3,3,3,3,3,3,3, 4,4,4,4,4,4,4,4,4,4], element(X1, Zone, D1), element(X2, Zone, D2), element(X3, Zone, D3), alldifferent([D1, D2, D3]), [Y1, Y2, Y3] :: 1..4, alldifferent([Y1, Y2, Y3]), create2(Rest). get_dvar([], []) :- !. get_dvar([ [X,Y,_,_] | Other_Re ], [X, Y | Other_dvar]) :- get_dvar(Other_Re, Other_dvar).