I am running the first MiniZinc example in the Handbook, coloring the states and territories of Australia. It runs fine as written.
% Colouring Australia using nc colours
int: nc = 3;
var 1..nc: wa; var 1..nc: nt; var 1..nc: sa; var 1..nc: q;
var 1..nc: nsw; var 1..nc: v; var 1..nc: t;
constraint wa != nt;
constraint wa != sa;
constraint nt != sa;
constraint nt != q;
constraint sa != q;
constraint sa != nsw;
constraint sa != v;
constraint q != nsw;
constraint nsw != v;
solve satisfy;
output ["wa=\(wa)\t nt=\(nt)\t sa=\(sa)\n",
"q=\(q)\t nsw=\(nsw)\t v=\(v)\n",
"t=", show(t), "\n"];
But when I change nc (the number of colors) to be a decision variable (change int: nc = 3; to be var 1..10: nc;) and change solve satisfy; to be solve minimize nc; I get an error message saying
MiniZinc: type error: type-inst must be par set but is `var set of int'
I was hoping that MiniZinc would tell me the minimum number of colors needed.
What should I do to get the minimum number of colors?
UPDATE: I found one way to get the answer I want. I added the following.
array[1..7] of var int: ts = [wa, nt, sa, q, nsw, v, t];
var int: min_nc = max(ts);
solve minimize min_nc;
Is there a better way?