Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Getting all dual values & some IloExpr help

    Posted 01/09/14 05:12 AM

    Originally posted by: MariusGi


    Hello, I am trying to solve my problem with Benders decomposition cutting plate algorithm.
    My main problem right now is that I'm running the calculations 3 times and I need to get all the dual values, but after calculations when I call cplex2.getDuals(vals2, con2); I get only dual values of the last calculation.

    Secondly I will need to multiply 2x2 matrix and 1x2 different dual values 3x times. Is IloExpr function is capable of doing it and how to do it?
    I want to calculate G, gradient, which needs dual values of each calculation in vector.
    Really looking forward your awnser, thanx. 
    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    IloRangeArray IRA2(env2);

    for(int i=0;i<l;i++){
    IRA2.add(IloRange(env2,0,T[i][0]*cplex.getValue(vars[0])+T[i][1]*cplex.getValue(vars[1])+W[i][0]*vars2[0]+W[i][1]*vars2[1]));
    con2.add(IRA2[i]);
    model2.add(IRA2[i]);

    IloCplex cplex2(model2);  // only extract once
    for(int i=0;i<3;i++){
         for(int j=0;j<2;j++) {
         IRA2[j].setLB((float)rand()/(float)(RAND_MAX));
         }
         if ( !cplex2.solve() ) {
             env2.error() << "Failed to optimize LP." << endl;
             throw(-1);
         }
        IloNumArray vals2(env2);
        cplex2.getDuals(vals2, con2);
        env2.out() << "Dual values  = " << vals2 << endl;
    }

    cplex2.getDuals(vals2, con2);
    env2.out() << "Dual values  = " << vals2 << endl; //TYPES JUST THE LAST DUAL VALUES

    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Getting all dual values & some IloExpr help

    Posted 01/10/14 01:27 AM

    Just make vals2 and con2 an array with 3 elements, each element being an IloNumArray/IloNumVarArray. Then do getDuals(vals2[i], con2[i]). This way you will have the three different sets of duals after the loop.

    IloExpr can accomodate any linear expression, so it can also represent the product of multiplying a matrix with a vector. You can use IloScalProd or just implement matrix-vector implementation in a loop.


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Getting all dual values & some IloExpr help

    Posted 01/10/14 06:07 AM

    Originally posted by: MariusGi


    Thank you. It works.


    #CPLEXOptimizers
    #DecisionOptimization