[AMPL]强加一个总和等于元素的数量
[AMPL]Impose a sum to be equal to the number of elements
我正在尝试施加一个简单的约束,但在我尝试的任何方式下都不起作用。我要强加:
subject to myConstrain:
sum { a1 in A, a2 in A } myVar[a1,a2] = *<<<number of elements of the set A>>>*
我该怎么做?有没有可以使用的功能?我用这种方法试过,但是不行。
subject to myConstrain:
sum { a1 in A, a2 in A } myVar[a1,a2] = sum {a in A} 1;
谢谢
你可以这样写约束条件:
subject to myConstrain:
sum{a1 in A, a2 in A} myVar[a1, a2] = card(A);
我正在尝试施加一个简单的约束,但在我尝试的任何方式下都不起作用。我要强加:
subject to myConstrain:
sum { a1 in A, a2 in A } myVar[a1,a2] = *<<<number of elements of the set A>>>*
我该怎么做?有没有可以使用的功能?我用这种方法试过,但是不行。
subject to myConstrain:
sum { a1 in A, a2 in A } myVar[a1,a2] = sum {a in A} 1;
谢谢
你可以这样写约束条件:
subject to myConstrain:
sum{a1 in A, a2 in A} myVar[a1, a2] = card(A);