'Purchasing Constraint in CPLEX using binary constraints
I have been trying to develop a constraint which says B[i][t]= 1 then Pur[i][t]==Q[i] and when B[i][t]==0 then Pur[i][t]==0
Please guide. Thanks
Solution 1:[1]
In OPL and all CPLEX APIs you can use logical constraints.
In OPL for instance,
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
}
In your example
(B[i][t]== 1) => (Pur[i][t]==Q[i]) ;
(B[i][t]==0) => ( Pur[i][t]==0);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Alex Fleischer |