[英]Cardinality constraint type failure; how to use minizinc `card` correctly
以下模型適用於蘭福德問題
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;
但是,以更自然的閱讀約束
constraint forall(r in RAN)( card({i | i in DOM where nos[i] = r}) = m);
失敗並顯示錯誤
MiniZinc: type error: no function or predicate with this signature found: `card(var opt set of int)'
有什么建議么?
您所設定的大小取決於一個var
,這意味着該類型是var opt
insted的的var
,你會想象。
有關更多信息,請參見此處:
MiniZinc:類型錯誤:預期的`int的array [int],實際的var opt int的array [int]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.