Originally posted by: AndyHam
(I don't think this forum is not for this topic, but I could not find the right forum. Any help will be appreciated. Thanks, Andy)
Dear IBM,
I have a flow control model for MIP-CP linking. The flowcontrol model works well within OPL environment. However, when I called the flowcontrol model via doOPL, it does not function. doOPL works well with stand-alone OPL models. The following is what I got when I call "main.py". Basically, it does not do anything. There are codes for main.py and flowcontrol.mod in this post. Would you please take a look at the codes and let me know what I have done wrong?
C:\Users\Google Drive\Codes\OPL>main.py
Tried aggregator 1 time.
No LP presolve or aggregator reductions.
Presolve time = 0.02 sec. (0.00 ticks)
oplmodel:
mod file: C:\Users\AndyHam\Google Drive\Codes\OPL\FlowControl.mod
0 .dat files
0 python structures
//main.py
from doopl.factory import *
import os
from os.path import dirname, abspath, join
DIR_Model = join(dirname(abspath(__file__)), 'code')
mod = join(DIR_Model, "FlowControl.mod")
with create_opl_model(model=mod) as opl:
opl.run()
print(opl)
//"FlowControl.mod"
main {
var cp = new IloCP();
var cplex = new IloCplex();
var tLimit=5;
var model;
var data1 = new IloOplDataSource("...");
model="Stage1.mod";
var source = new IloOplModelSource(model);
var def = new IloOplModelDefinition(source);
var opl = new IloOplModel(def,cplex);
opl.addDataSource(data1);
opl.generate();
cplex.tilim=5;
cplex.solve();
opl.postProcess();
model="Stage2.mod";
var source2 = new IloOplModelSource(model);
var def2 = new IloOplModelDefinition(source2);
var opl2 = new IloOplModel(def2,cp);
opl2.addDataSource(data1);
var data0=new IloOplDataElements();
data0.O2F=thisOplModel.O2F;
for(var o in opl.OBC)
for (var f in opl.FF)
if(opl.bjobOnFF[o][f]==1) data0.O2F.add(o.id,f.id);
opl2.addDataSource(data0);
opl2.generate();
cp.param.timelimit=tLimit;
cp.param.NoOverlapInferenceLevel = "Extended";
cp.param.Workers=3;
var f = cp.factory;
f.searchPhase(opl2.seqFF);
if (cp.solve()) opl2.postProcess();
}
#DecisionOptimization#OPLusingCPOptimizer