我创建了一个CPLEX半连续变量,然后更新了它的下限值。该变量不再被视为半连续变量。
IloCplex cplex = new IloCplex();
IloLinearNumExpr objective = cplex.linearNumExpr();
IloNumVar x1=cplex.semiContVar(10, Double.MAX_VALUE,IloNumVarType.Float,"x1");
IloNumVar x2 = cplex.numVar(10, Double.MAX_VALUE,IloNumVarType.Float,"x2");
//If below line is commented, variable x1 is treated as semi continuous
x1.setLB(10);
objective.addTerm(x1, 4);
objective.addTerm(x2, 2);
cplex.addMinimize(objective);
cplex.lowerBound(x1..getVar().setLB(arg0);
cplex.solve();
if (cplex.solve()) {
cplex.exportModel("Test2Variables.lp");
System.out.println(cplex.getObjValue());
}
我希望输出为20,但实际输出为60
答案 0 :(得分:2)
好,我得到了解决方案:
当我使用下限设置时:((IloSemiContVar)x1).setSemiContLB(10);
这解决了问题。