0

I have a constraint of the type(in zmpl)

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

where, x is a binary variable of two dimension and c[i,j] is a parameter. I would like to change this to

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

Essentially the parameter in the second index depends on the number of selected variables in the ith row. Any effective way to do this ?

Malice
  • 1,457
  • 16
  • 32

1 Answers1

0

First: It is not possible to index parameters with variable expressions, because this essentially makes them variables, too.

Instead, I suggest to use additional variables to model the desired constraint and I try to be as zimpl as possible:

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...

Note that this formulation is nonlinear, but I think it is worth a try. Its effectiveness pretty much depends on the number of "dynamic coefficients" in your formulation and the size of the set S2 defined in my answer.

Gregor
  • 1,333
  • 9
  • 16