admin管理员组文章数量:1406951
I am running a CPLEX OPL model for 10 entities. The objective is to optimize a certain objective for each entity. Step 1: The CPLEX model first runs for the first entity, optimizing the objective function. Step 2: After solving for the first entity, a non-decision variable or parameter is updated in the main function based on the optimization results obtained. Step 3: The updated data is then used to run the CPLEX model for the second entity. Step 4: This process continues iteratively for all 10 entities, where after each iteration, the necessary variables are updated before solving for the next entity. How to do this cplex opl using main function.
I am running a CPLEX OPL model for 10 entities. The objective is to optimize a certain objective for each entity. Step 1: The CPLEX model first runs for the first entity, optimizing the objective function. Step 2: After solving for the first entity, a non-decision variable or parameter is updated in the main function based on the optimization results obtained. Step 3: The updated data is then used to run the CPLEX model for the second entity. Step 4: This process continues iteratively for all 10 entities, where after each iteration, the necessary variables are updated before solving for the next entity. How to do this cplex opl using main function.
Share Improve this question asked Mar 9 at 6:45 SUBHADARSHINI PANDASUBHADARSHINI PANDA 433 bronze badges1 Answer
Reset to default 2Let me share a small example I wrote :
main {
var source = new IloOplModelSource("subvalue.mod");
var cplex = new IloCplex();
var def = new IloOplModelDefinition(source);
for(var k=1;k<=10;k++)
{
var opl = new IloOplModel(def,cplex);
var data2= new IloOplDataElements();
data2.maxOfx=k;
opl.addDataSource(data2);
opl.generate();
if (cplex.solve()) {
opl.postProcess();
writeln("OBJ = " + cplex.getObjValue());
} else {
writeln("No solution");
}
opl.end();
}
}
which gives
x= 1
OBJ = 1
x= 2
OBJ = 2
x= 3
OBJ = 3
x= 4
OBJ = 4
x= 5
OBJ = 5
x= 6
OBJ = 6
x= 7
OBJ = 7
x= 8
OBJ = 8
x= 9
OBJ = 9
x= 10
OBJ = 10
with subvalue.mod
float maxOfx = ...;
dvar float x;
maximize x;
subject to {
x<=maxOfx;
}
execute
{
writeln("x= ",x);
}
本文标签:
版权声明:本文标题:optimization - How to update non-decision variablesparameters Iteratively in CPLEX OPL using main function? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744876373a2629937.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论