Zimpl:非线性约束

时间:2015-10-08 14:00:25

标签: scip

我有一个类型的约束(在zmpl中)

  

S1中的sum(i,j):x [i,j] * c [i,j]< = 100

其中,x是二维的二进制变量,c [i,j]是参数。 我想将此更改为

  

在S1中的和(i,j):x [i,j] * c [i,sum(i)x [i,j]]< = 100

基本上,第二个索引中的参数取决于第i行中所选变量的数量。有任何有效的方法吗?

1 个答案:

答案 0 :(得分:0)

首先:不可能用变量表达式索引参数,因为这也基本上使它们成为变量。

相反,我建议使用其他变量来建模所需的约束,并尝试尽可能 zimpl

set S2 := { 0..card(S1) }; # new set to model all possible outcomes of the sum operation

var y[S1] >= 0;   # y models nonnegative coefficients c[i,j]

var z[S2] binary; # models the value of the x-sum 

subto binlink: sum <i,j> in S1: x[i,j] - sum <s> in S2: s * z[s] == 0;
# binlink expresses the outcome of the x-sum in z

subto partition: sum <s> in S2: z[s] == 1; 
# maybe redundant because of binlink, but easy to write

subto coeflink: forall <i,j> in S1: y[i,j] == sum <s> in S2: c[i,s] * z[i,s]
#links continous coefficient variable to coefficient parameter

subto yourcons: sum <i,j> in S1: x[i,j] * y[i,j] <= 100;
# finally...

请注意,此配方是非线性的,但我认为值得一试。它的有效性很大程度上取决于&#34;动态系数的数量&#34;在你的表述和我的答案中定义的 S2 集的大小。