为 CPLEX OPL 热启动提供初始最佳 LB

发布于 2025-01-12 17:59:20 字数 802 浏览 0 评论 0原文

我正在使用 OPL(无 Java/C++ API)在 CPLEX 12.10 中应用热启动技术来解决 MILP 最小化问题。 从模型1中,我得到了可行解S和LB值。 然后我使用 doc 并包含 LB 作为约束(obj >= LB)。

到目前为止,一切正常。然而,从引擎日志中,我注意到模型 2 没有使用提供的 LB 作为第一个最佳边界。因此,面对困难的情况,模型 2 以显着大的 MIP GAP 结束,而模型 1 已经证明 LB 具有小得多的 MIP GAP。

有没有办法强制 CPLEX 使用提供的 LB 值作为某个截止值?在官方参数列表中,我发现 降低目标值限制,但似乎不推荐。

I am applying the warm-start technique in CPLEX 12.10 using OPL (no Java/C++ API) for a MILP minimization problem.
From model 1, I obtained a feasible solution S and a LB value.
Then I injected S as a MIP start for model 2 using Vector API indicated by the doc and included LB as a constraint (obj >= LB).

So far, everything is working. However, from the engine log, I notice that model 2 does not use the provided LB as the first best bound. Hence in the face of difficult instances, model 2 ends with a significantly large MIP GAP, whereas LB is already demonstrated by model 1 to have a much smaller MIP GAP.

Is there any way to force CPLEX to use the provided LB value as some cut-off value? In the official list of parameters, I found lower objective value limit, but it seems not recommended.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

↘人皮目录ツ 2025-01-19 17:59:20

则可以编写

oplModel.Obj.LB=0;

如果 Obj 是目标,oplModel 是模型,

流程控制,但这并不总是有利于收敛。例如, 混合生活游戏 给出

374
412
412
427
427
431

,而如果我使用边界,

// hybrid CPOptimizer and CPLEX to solve lifegame
//
// warmstart between CPO and CPLEX tu use them both
// 
// the objective is maximize
//
// And in 60s
//
// we get 
// 396 hybrid (hybrid.mod)
// 379 cplex alone (lifegameip.mod)
// 280 cpo alone (lifegamecp.mod)

int nbiter=3;
int n=30;

int values[0..(n+2)*(n+2)-1];
main {

    var n=thisOplModel.n;
   var nbiter=thisOplModel.nbiter;

  var source1 = new IloOplModelSource("lifegameip.mod");
  var cplex = new IloCplex();
  var def1 = new IloOplModelDefinition(source1);
  
  
  var source2 = new IloOplModelSource("lifegamecp.mod");
  var cp = new IloCP();
  var def2 = new IloOplModelDefinition(source2);
  
  var opl1 = new IloOplModel(def1,cplex);
  var opl2 = new IloOplModel(def2,cp);
  opl1.generate();
  opl2.generate();
  
  var objValues=new Array(2*5);
  
  for(var iter=1;iter<=nbiter;iter++)
  {
  
  writeln("iter ",iter);
  
  opl1.Obj.UB=450;
  
  // start with CPLEX
  cplex.tilim=10;
  cplex.solve();
  writeln("cplex objective = ",cplex.getObjValue());
  
  objValues[iter*2-1]=cplex.getObjValue();
  
  cp.param.timelimit=10;
  
  // Warmstart in CPO
  var sol=new IloOplCPSolution();
  for(var i=0;i<=(n+2)*(n+2)-1;i++) sol.setValue(opl2.x[i],opl1.x[i]);
  cp.setStartingPoint(sol);
  opl2.Obj.UB=450
 
  // CP Solve
  cp.solve();
  writeln("cpo objective =",cp.getObjValue());
  objValues[iter*2]=cp.getObjValue();
  
  // And warmstart CPLEX
  var vectors = new IloOplCplexVectors();
  // We attach the values (defined as data) as starting solution
  // for the variables x.
  
  for(var i=0;i<=(n+2)*(n+2)-1;i++) thisOplModel.values[i]=opl2.x[i];
  vectors.attach(opl1.x,thisOplModel.values);
  vectors.setStart(cplex);   
}  
  
 writeln("list of objectives") ;
 for(var i=1;i<=2*nbiter;i++) writeln(objValues[i]);
  
}  

我会得到更糟糕的结果

0
241
241
332
332
366

You can write

oplModel.Obj.LB=0;

in a flow control if Obj is the objective and oplModel the model but that's not always good for convergence.

For instance, the hybrid lifegame gives

374
412
412
427
427
431

whereas if I use bounds

// hybrid CPOptimizer and CPLEX to solve lifegame
//
// warmstart between CPO and CPLEX tu use them both
// 
// the objective is maximize
//
// And in 60s
//
// we get 
// 396 hybrid (hybrid.mod)
// 379 cplex alone (lifegameip.mod)
// 280 cpo alone (lifegamecp.mod)

int nbiter=3;
int n=30;

int values[0..(n+2)*(n+2)-1];
main {

    var n=thisOplModel.n;
   var nbiter=thisOplModel.nbiter;

  var source1 = new IloOplModelSource("lifegameip.mod");
  var cplex = new IloCplex();
  var def1 = new IloOplModelDefinition(source1);
  
  
  var source2 = new IloOplModelSource("lifegamecp.mod");
  var cp = new IloCP();
  var def2 = new IloOplModelDefinition(source2);
  
  var opl1 = new IloOplModel(def1,cplex);
  var opl2 = new IloOplModel(def2,cp);
  opl1.generate();
  opl2.generate();
  
  var objValues=new Array(2*5);
  
  for(var iter=1;iter<=nbiter;iter++)
  {
  
  writeln("iter ",iter);
  
  opl1.Obj.UB=450;
  
  // start with CPLEX
  cplex.tilim=10;
  cplex.solve();
  writeln("cplex objective = ",cplex.getObjValue());
  
  objValues[iter*2-1]=cplex.getObjValue();
  
  cp.param.timelimit=10;
  
  // Warmstart in CPO
  var sol=new IloOplCPSolution();
  for(var i=0;i<=(n+2)*(n+2)-1;i++) sol.setValue(opl2.x[i],opl1.x[i]);
  cp.setStartingPoint(sol);
  opl2.Obj.UB=450
 
  // CP Solve
  cp.solve();
  writeln("cpo objective =",cp.getObjValue());
  objValues[iter*2]=cp.getObjValue();
  
  // And warmstart CPLEX
  var vectors = new IloOplCplexVectors();
  // We attach the values (defined as data) as starting solution
  // for the variables x.
  
  for(var i=0;i<=(n+2)*(n+2)-1;i++) thisOplModel.values[i]=opl2.x[i];
  vectors.attach(opl1.x,thisOplModel.values);
  vectors.setStart(cplex);   
}  
  
 writeln("list of objectives") ;
 for(var i=1;i<=2*nbiter;i++) writeln(objValues[i]);
  
}  

I get worse results

0
241
241
332
332
366
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文