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()
這樣的任何步驟。