minizinc:在两个数组索引上的总和约束' k' ,,' j'对于所有索引' i'在3Darray中创建TypeError
正如下面的代码所解释的那样,我想实现一个约束,其中每个“ i”,所有“ j”和'k'的总和在数组中[k,i,j]中的特定“ i”必须小于或等于1。
constraint forall(i in 1..10)( sum(j in 1..10, k in 1..10)(ARRAY[k,i,j] <= 1) );
但是,我得到此错误:
MiniZinc: type error: no function or predicate with this signature found: `sum(var int)'
Cannot use the following functions or predicates with the same identifier:
function int : sum(array [$T] of int: x);
(argument 1 expects type array[$_] of int, but type var int given)
function int : sum(array [int] of opt int: x);
(argument 1 expects type array[int] of opt int, but type var int given)
function var int : sum(array [$T] of var int: x);
(argument 1 expects type array[$_] of var int, but type var int given)
function var int : sum(array [int] of var opt int: x);
(argument 1 expects type array[int] of var opt int, but type var int given)
function float : sum(array [$T] of float: x);
(argument 1 expects type array[$_] of float, but type var int given)
function float : sum(array [int] of opt float: x);
(argument 1 expects type array[int] of opt float, but type var int given)
function var float : sum(array [$T] of var float: x);
(argument 1 expects type array[$_] of var float, but type var int given)
function var float : sum(array [int] of var opt float: x);
(argument 1 expects type array[int] of var opt float, but type var int given)
错误是什么意思,我将如何制定约束?
As the code below hopefully explains, I want to implement a constraint where for each 'i', the sum over all 'j' and 'k' for that specific 'i' in ARRAY[k,i,j] must be less than or equal to 1.
constraint forall(i in 1..10)( sum(j in 1..10, k in 1..10)(ARRAY[k,i,j] <= 1) );
However, I get this error:
MiniZinc: type error: no function or predicate with this signature found: `sum(var int)'
Cannot use the following functions or predicates with the same identifier:
function int : sum(array [$T] of int: x);
(argument 1 expects type array[$_] of int, but type var int given)
function int : sum(array [int] of opt int: x);
(argument 1 expects type array[int] of opt int, but type var int given)
function var int : sum(array [$T] of var int: x);
(argument 1 expects type array[$_] of var int, but type var int given)
function var int : sum(array [int] of var opt int: x);
(argument 1 expects type array[int] of var opt int, but type var int given)
function float : sum(array [$T] of float: x);
(argument 1 expects type array[$_] of float, but type var int given)
function float : sum(array [int] of opt float: x);
(argument 1 expects type array[int] of opt float, but type var int given)
function var float : sum(array [$T] of var float: x);
(argument 1 expects type array[$_] of var float, but type var int given)
function var float : sum(array [int] of var opt float: x);
(argument 1 expects type array[int] of var opt float, but type var int given)
What does the error mean, and how would I make the constraint do what I want?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于条件(
&lt; =
)被放置在错误的位置,因此抛出了错误。它应该在sum
的主体之外:The error is thrown since the condition (
<=
) is placed in the wrong place. It should be outside the body ofsum
: