0
我想用Java解决Cplex中的模型。但是,当我尝试使用cplex.getSolnPoolNsolns()获取解决方案池中的解决方案时,它返回的值为0.我想知道这是什么意思?获取解决方案0使用cplex.getSolnPoolNsolns()
我想用Java解决Cplex中的模型。但是,当我尝试使用cplex.getSolnPoolNsolns()获取解决方案池中的解决方案时,它返回的值为0.我想知道这是什么意思?获取解决方案0使用cplex.getSolnPoolNsolns()
请检查您的代码是否与以下CPLEX文档中的标准示例匹配。
public static void main(String[] args) {
if (args.length != 1) {
usage();
return;
}
try {
IloCplex cplex = new IloCplex();
cplex.importModel(args[0]);
/* Set the solution pool relative gap parameter to obtain solutions
of objective value within 10% of the optimal */
cplex.setParam(IloCplex.DoubleParam.SolnPoolGap, 0.1);
if (cplex.populate()) {
System.out.println("Solution status = " + cplex.getStatus());
System.out.println("Incumbent objective value = "
+ cplex.getObjValue());
/* Get the number of solutions in the solution pool */
int numsol = cplex.getSolnPoolNsolns();
System.out.println("The solution pool contains " + numsol +
" solutions.");
}
}
您是否缺少像cplex.populate()
这样的任何步骤。