what is the best way of defining the range of an array decision variable when it is not a contiguous sequence of integers apart from writing too many constraints?
An example: enum PRODUCTS ={product_1,product_2,product_3,product_4};
array [PRODUCTS] of var 0..2 : x; // contiguous array [PRODUCTS] of var 0,3,10 : y; ///non contiguous sequence and error
i tried also with the set of int
such as set of int : y_range= 0,1,3;
enum PRODUCTS ={product_1,product_2,product_3,product_4};
array [PRODUCTS] of var 0..2 : x; // contiguous array [PRODUCTS] of var y_range : y; ///non contiguous sequence and error
but didn't work out..
Non-continuous domains are allowed in MiniZinc. It seems you just made a mistake in your syntax. The following code works:
enum PRODUCTS ={product_1,product_2,product_3,product_4};
array [PRODUCTS] of var {0,3,10} : y;
Note that a non-continuous set literal, which initializes the domains of your variables, needs curly brackets ({}
).