Hi,
I have been going through the MiniZinc Coursera courses and have come across a situation I can't understand. The attached model is based on the 'arrows' assignment of module 5 in the Advanced course. It has been stripped down to minimise the size while still demonstrate the behaviour I see.
There are two test files, test1 and test2. The characteristic difference between the two is the former only has a single rotational variant for each ship/object, whereas the latter has multiple variants (see 'config' array).
When I run the model with test1 I see the expected output. When I run it with test2 I get the error message
- MiniZinc: assertion failed: Index set mismatch. The index set of the left hand side value is [1..18], but index set of the right hand side value is [1..196]. You may need to coerce the index sets using an array transformation.
I have no idea where the 1..196 range comes from. Interestingly it is 28 times greater than the expected 1..18, 28 being the number of rect offsets in the test data.
Another thing I noticed, and probably related. The model compiles ok as attached, but if I replace
array[1..num_ship_roff] of var LENGTH: x;
constraint x = [rectoff[r,1] | s in SHIP, r in shape[k[s]]];
with
array[1..num_ship_roff] of var LENGTH: x = [rectoff[r,1] | s in SHIP, r in shape[k[s]]];
then the IDE highlights the rhs of the definition with the error message
- MiniZinc: type error: initialisation value for `x' has invalid type-inst: expected `array[int] of var int', actual `array[int] of var opt int'
Why does MinZinc respond differently to a declaration and constraint vs a declaration that contains the definition?
Thanks,
Paul