[英]Cardinality constraint type failure; how to use minizinc `card` correctly
The following model works for langfords problem 以下模型适用于兰福德问题
int: m = 2;
int: n = 3;
set of int: DOM = 1..m*n;
set of int: RAN = 1..n;
array [DOM] of var 1..n: nos;
constraint forall(j in DOM, k in j+1..m*n) (nos[j] = nos[k] /\ forall(l in j + 1 .. k - 1)(nos[l] != nos[k]) -> k - j = nos[j] + 1);
constraint forall(r in RAN)( sum([1 | i in DOM where nos[i] = r]) = m);
solve satisfy;
However the to more more natural reading constraint 但是,以更自然的阅读约束
constraint forall(r in RAN)( card({i | i in DOM where nos[i] = r}) = m);
fails with the error 失败并显示错误
MiniZinc: type error: no function or predicate with this signature found: `card(var opt set of int)'
Any suggestions? 有什么建议么?
Your set size is dependent on a var
, this means that the type is var opt
insted of var
as you would imagine. 您所设定的大小取决于一个
var
,这意味着该类型是var opt
insted的的var
,你会想象。
For more information read here: 有关更多信息,请参见此处:
MiniZinc: type error: expected `array[int] of int', actual `array[int] of var opt int MiniZinc:类型错误:预期的`int的array [int],实际的var opt int的array [int]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.