我有一个类型的约束(在zmpl中)
S1中的和(i,j):xi,j*ci,j<=100
其中,x是二维的二元变量,ci,j是参数。我想把这个换成
S1中的sum (i,j):xi,j*c[i,sum (i) xi,j]<=100
实质上,第二个索引中的参数取决于ith行中所选变量的数量。有什么有效的方法吗?
发布于 2015-10-19 09:24:31
首先:不可能用变量表达式对参数进行索引,因为这实际上也使它们成为变量。
相反,我建议使用额外的变量来建模所需的约束,并且我试图尽可能地成为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...
请注意,这个公式是非线性的,但我认为值得一试。它的有效性在很大程度上取决于您的公式中的“动态系数”的数量以及在我的答案中定义的集合S2的大小。
https://stackoverflow.com/questions/33018002
复制相似问题