I'm trying to understand MiniZincs geost
constraint, which is described in the packing constraint section of the docs. I'm trying to implement 2D packing of rectangles with rotation: So I'd like to fit rectangles on a plate of given length and width, but I'm having a hard time understanding the expected input format.
I have the following model, where I read the number of parts or rectangles to be placed into nParts
. nShapes
is the number of shapes those rectangles can take.
include "globals.mzn";
int: nParts;
set of int: PARTS = 1..nParts;
int: nShapes;
set of int: SHAPES = 1..nShapes;
int: plateLength;
int: plateWidth;
set of int: LEN = 0..plateLength;
set of int: WID = 0..plateWidth;
int: k = 2;
set of int: DIM = 1..k;
array[SHAPES,DIM] of int: rect_size;
array[SHAPES,DIM] of 0..0: rect_offset;
array[PARTS] of set of SHAPES: shape;
array[PARTS,DIM] of var int: xy;
array[PARTS] of var SHAPES: kind;
constraint geost(k, rect_size, rect_offset, shape, xy, kind);
constraint forall(i in PARTS)(kind[i] in shape[i]);
constraint forall(i in PARTS)(xy[i,1] in LEN);
constraint forall(i in PARTS)(xy[i,1] + rect_size[kind[i], 1] in LEN);
constraint forall(i in PARTS)(xy[i,2] in WID);
constraint forall(i in PARTS)(xy[i,2] + rect_size[kind[i], 2] in WID);
Given model seems to work for this extremly simple data (placing only one rectangle, with two possible shapes):
plateLength = 4000;
plateWidth = 4000;
nParts = 1;
nShapes = 2;
rect_size = [|4000, 2000|
2000, 4000|];
rect_offset = [|0, 0|
0, 0|];
shape = [{1,2}];
Yet for more complex data, I'm running into errors, leading to the conclusion my understanding of the input format might be wrong. In the following example, I want to place 5 parts on a plate and I'd expect a result like this: The first rectangle can take the shape [4000, 2000] or [2000, 4000] and is therefor indexed via {1,2}, the second rectangle can take the shape [2000, 2000] and is indexed via {3}.
plateLength = 4000;
plateWidth = 4000;
nParts = 5;
nShapes = 7;
rect_size = [|4000, 2000|
2000, 4000|
2000, 2000|
1000, 2000|
2000, 1000|
500, 1000|
1000, 500|];
rect_offset = [|0, 0|
0, 0|
0, 0|
0, 0|
0, 0|
0, 0|
0, 0|];
shape = [{1,2}, {3}, {4,5}, {6,7}, {6,7}];
Is this specification correct? If not, how can I correctly specify the input for the geost constraint? A simple example would also help, I have only found rather complex ones here and here.