我是约束规划和 Minizinc 的新手。我一直在寻找解决这个并不困难的任务的方法,但我什么也没找到。
我想计算数组中出现的不同元素的数量:这是我的数组的声明:
array[1..n,1..n] of var 1..n: countLeft;
Run Code Online (Sandbox Code Playgroud)
我尝试这样做:
constraint
forall(j in 1..n) (
length(array2set([countLeft[i,j]|i in 1..stopCountLeft[j]]) )==left_vision[j]
);
Run Code Online (Sandbox Code Playgroud)
但显然我的数组类型为: array[int]of var opt int 并且不被函数 array2set 接受。
有任何想法吗?