Reputation: 49
How to modify the below incremental constrains to be greater than or equal (>=) not equal only (==) ? I have added the below incremental constrains in the main
main
{
for(var i in thisOplModel.inner_beams2 )
{
thisOplModel.ctEmptyy[i].setCoef(thisOplModel.beam_firstchannel[i],1);
thisOplModel.ctEmptyy[i].setCoef(thisOplModel.beam_firstchannel[i-1],-1);
thisOplModel.ctEmptyy[i].setCoef(thisOplModel.beam_nomusedchannel[i-1],-1);
thisOplModel.ctEmptyy[i].setBounds(0,0);
}
}
// the above constrains gives me the results of:
// beam_firstchannel[i]==beam_firstchannel[i-1]+beam_nomusedchannel[i-1];
// My question is how to modify the above incremental constrains to be
// beam_firstchannel[i]>=beam_firstchannel[i-1]+beam_nomusedchannel[i-1];
subject to
{
forall (i in inner_beams2 )
ctEmptyy:
0>=0;
}
Upvotes: 0
Views: 31
Reputation: 10059
With incremental you can do that:
int nbKids=300;
float costBus40=500;
float costBus30=400;
dvar int+ nbBus40;
dvar int+ nbBus30;
minimize
costBus40*nbBus40 +nbBus30*costBus30;
subject to
{
ctKids:40*nbBus40+nbBus30*30>=nbKids;
ctEmpty1:0<=0;
ctEmpty2:0<=0;
}
execute
{
writeln("nbBus40 = ",nbBus40);
writeln("nbBus30 = ",nbBus30);
}
main
{
thisOplModel.generate();
thisOplModel.ctEmpty1.setCoef(thisOplModel.nbBus40,1);
// ==5
thisOplModel.ctEmpty1.setBounds(5, 5);
thisOplModel.ctEmpty2.setCoef(thisOplModel.nbBus30,1);
// >=8
thisOplModel.ctEmpty2.setBounds(8, 10000);
cplex.solve();
thisOplModel.postProcess();
cplex.exportModel("exp.lp");
}
gives
nbBus40 = 5
nbBus30 = 8
Upvotes: 1