简体   繁体   中英

How to add incemental constrains for array in cplex?

How to add this row in the main using incremental constrains to be run in next iteration model

   forall ( i in beams)
        beam_nomusedchannel [i]  <= ceil (Nchannels/adjbeams[i]);

noting that i have defined it as

 forall ( i in beams)
        ctEmpty:0<=0;

noting that beam_nomusedchannel is a decision variable array in the model adjbeams is an after processing defined array (after subject to) in the model

range beams=0..10;

int adjbeams[i in beams]=i;
int NChannels=20;

dvar int beam_nomusedchannel[beams] in 0..100;

maximize sum(i in beams) beam_nomusedchannel[i];
subject to
{

forall ( i in beams)
        ctEmpty:0<=0;
}

execute
{
  writeln(beam_nomusedchannel);
}

main
{
  thisOplModel.generate();
  cplex.solve();
  thisOplModel.postProcess();
  for(i in thisOplModel.beams)
  {
    thisOplModel.ctEmpty[i].setCoef(thisOplModel.beam_nomusedchannel[i], 1);
    thisOplModel.ctEmpty[i].UB=thisOplModel.NChannels/thisOplModel.adjbeams[i];
  }
  
  cplex.solve();
  thisOplModel.postProcess();
}
  

gives

[100 100 100 100 100 100 100 100 100 100 100]
 [100 20 10 6 5 4 3 2 2 2 2]

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