Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Solution Pool - Get many two-dimensional answers

    Posted 02/26/18 09:15 AM

    Originally posted by: arthurmedeiros


    Hello,

    I obtain, as final results of my model, an answer like X[i][j] which I'm able to export to a txt file and so on. But I would like to do the same with the all the incumbent answers stored in solution pool.

    I'm able to get their objective values with getObjValue(i) and even write all the solutions in a file with the command cplex.writeSolutions.

    So, when I try to print X[i][j] it prints only the best solution. How do I get the values from the others as well? I know that I have then somewhere, I'm just not able to extract.

    Above some of the implementation in C++

     

    typedef IloArray<IloNumVarArray> NumVarMatrix;
    typedef IloArray<IloNumArray> NumMatrix;
    NumVarMatrix x(env, Up_i);
    NumMatrix answer(env, Up_i);
    
    for (int i = 0; i < Up_i; i++)
    {
            x[i] = IloNumVarArray(env, Up_j);
            answer[i] = IloNumArray(env, Up_j);
            for (int j = 0; j < Up_j; j++)
                    x[i][j] = IloNumVar(env, 0.0, 1, ILOINT);
    }
    
    for (int i = 0; i < up_i; i++)
            cplex.getValues(answer[i], x[i]);
    
    //How do i get the answer[i][j] from all the solutions in solution pool?
    for (int i = 0; i < Up_i; i++)
    {
        env.out() << "Storage: " << i << endl;
            for (int j = 0; j < up_j; j++)
                    env.out() << answer[i][j] << " ";
    }    
    

    Thanks in advance.


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Solution Pool - Get many two-dimensional answers

    Posted 02/26/18 10:05 AM

    Take a look at the reference documentation: function getValues() takes a solution as argument. Specify the index of the solution that you want to query.


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Solution Pool - Get many two-dimensional answers

    Posted 02/26/18 10:56 AM

    Originally posted by: arthurmedeiros


    Oh, I ran some tests and everything went fine.

    I new I was missing something simple. Thanks a lot Daniel.


    #CPLEXOptimizers
    #DecisionOptimization