0

While working on a linear program, I came across this question: it is possible to correlate two classes of variables, for example Xij (set of variables greater than or equal to zero) and Yij (decision variables) so that:

if Xij> 0 -> Yij = 1
if Xij == 0 -> Yij = 0

Thank you all in advance.

user3254491
  • 119
  • 1
  • 3
  • 10

2 Answers2

0

With all CPLEX APIs you may use logical constraints.

For instance for "if then" in OPL CPLEX you can write

int nbKids=300;
float costBus40=500;
float costBus30=400;



dvar int+ nbBus40;
dvar int+ nbBus30;

minimize
 costBus40*nbBus40  +nbBus30*costBus30;

subject to
{
 40*nbBus40+nbBus30*30>=nbKids;

 // with if nb buses 40 more than 3  then nb buses30 more than 7

 (nbBus40>=3)=>(nbBus30>=7);
 //(nbBus40>=3)<=(nbBus30>=7); //equivalent
}
Alex Fleischer
  • 9,276
  • 2
  • 12
  • 15
0

In order for my proposed solution to work, first, you need to define values Xij_min and Xij_max to represent the minimum and maximum limits of the Xij variable when it is Xij > 0.

Xij_min can be as small as you wish or makes sense and Xij_max can be arbitrarily high if there are no physical limits to your variables.

Then by adding the two following constraints, what you want can be achieved:

Xij >= Xij_min * Yij
Xij <= Xij_max * Yij

For the sake of this example, I will assume Xij_min = 0.1 and Xij_max = 1000. This will make the constraints:

Xij >= 0.1 * Yij
Xij <= 1000 * Yij

If Xij is to take a value between 0.1 and 1000 (which we defined as the feasible, positive range), then Yij will have to be 1.

Now if Xij becomes 0, then in order for these constraints to hold Yij will need to be 0 in order to have Xij <= 0 and Xij >= 0.

gmavrom
  • 430
  • 4
  • 12