简体   繁体   中英

How to modify the below incremental constrains to be greater than or equal not equal only?

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;
}
  

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM