簡體   English   中英

如何將以下增量約束修改為大於或等於不等於?

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

如何將以下增量約束修改為大於或等於(>=)不等於(==)? 我在 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;
}
  

使用增量,您可以這樣做:

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

nbBus40 = 5
nbBus30 = 8

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM