0

Dears,

Currently, I am using OPL-DoCplex to solve a problem using CP. The basic model was built in OPL then I called it into python by DoCplex. I have the following questions: 1- In the OPL model, there are decision expressions (dexpr) that were not import to python. How can I do that or where can I find the imported dexpr if any. 2- How can I stop the solver after finding each feasible solution do some post-processing then run the solver again. Is that possible?

Thanks in advance Mohamed

1 Answers1

1
  1. You may turn your dexpr into tuple sets if you want those to be seen in the python code

  2. You can use flow control in OPL and call postProcess/

Example at https://github.com/AlexFleischerParis/zooopl/blob/master/zooseveralcpo.mod

using CP;


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

execute
{
    writeln("nbBus40 = ",nbBus40," and nbBus30 = ",nbBus30," and the cost is ",costBus40*nbBus40  +nbBus30*costBus30);
}



main
{
cp.param.SearchType=24;
cp.param.workers=1;

thisOplModel.generate();
cp.startNewSearch();
while
(cp.next()) {  thisOplModel.postProcess(); }
} 
Alex Fleischer
  • 9,276
  • 2
  • 12
  • 15