使用cplex.getSolnPoolNsolns()获取解决方案0

时间:2016-08-24 21:20:26

标签: java cplex

我正在尝试使用Java在Cplex中解决模型。但是当我试图使用cplex.getSolnPoolNsolns()在解决方案池中获得解决方案时,它返回的值为0.我想知道这意味着什么?

1 个答案:

答案 0 :(得分:0)

请检查您的代码是否与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()等任何步骤。