Originally posted by: SystemAdmin
[afleischer said:]
Hi,
there is an experimental API for this, in beta test and available in OPL 6.
Let me give you a small example.
int n = 5;
dvar int x;
dvar int y;
template TEMPLATE {
int n = ...;
execute {
writeln("n=",n);
}
subject to {
x >= n+1;
y>= n+100;
}
}
execute {
writeln("n=",n);
}
minimize x+y;
subject to {
x >= n+100;
y >=n+1;
}
main {
thisOplModel.generate();
var templateOpl = new IloOplModel(thisOplModel.TEMPLATE,cplex);
var templateData = new IloOplDataElements();
templateData.n = 10;
templateOpl.addDataSource(templateData);
templateOpl.generate();
cplex.solve();
writeln("objectiveValue = ",cplex.getObjValue());
writeln("x = ",thisOplModel.x);
writeln("y = ",thisOplModel.y);
if (thisOplModel.x!=105) fail();
if (thisOplModel.y!=110) fail();
templateData.end();
templateOpl.end();
}
;
#DecisionOptimization#OPLusingCPLEXOptimizer