我需要帮助。我已经在CPLEX上编写了我的模型,现在我想通过改变其中一个二进制变量来解决同样的问题,以便浮动一段时间。让我举个例子,对于前两个时期,前两个时期变量是二进制的,但对于最后的8个时期,它将是连续的(放松的)。我试图解决它的opl流量控制,但我有一些变量转换的问题。如果你能帮助我,我将非常高兴
谢谢你提前
答案 0 :(得分:0)
dvar float x[1..5] in 0..9.2;
dvar int intx[1..5];
maximize sum(i in 1..5) x[i];
subject to
{
forall(i in 1..5)ctx:intx[i]-x[i]==0;
}
execute
{
writeln("x : ",x);
}
main
{
writeln("solve model");
thisOplModel.generate();
cplex.solve();
thisOplModel.postProcess();
writeln("relax integrity constraint on x for 1 and 2 and solve model");
cplex.setLb(thisOplModel.ctx[1],-Infinity);
cplex.setLb(thisOplModel.ctx[2],-Infinity);
cplex.solve();
thisOplModel.postProcess();
writeln("put back integrity constraint on x and solve model");
cplex.setLb(thisOplModel.ctx[1],0);
cplex.setUb(thisOplModel.ctx[2],0);
cplex.solve();
thisOplModel.postProcess();
}
给出
solve model
x : [9 9 9 9 9]
relax integrity constraint on x for 1 and 2 and solve model
x : [9.2 9.2 9 9 9]
put back integrity constraint on x and solve model
x : [9 9.2 9 9 9] enter code here
问候