Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Doubt in accessing value constraint model

    Posted 09/22/13 10:01 AM

    Originally posted by: regisgomes


    Hi,

     

    I implemented a constraint like this:

    for (int i=0; i<d.m; i++){
        IloExpr r1(env);
        for (int j=1; j<=d.n; j++){
            r1 += mp.x[(d.n+1)*i + j]*d.p_ij[j][i+1];
        }
        r1 += mp.e[i] - mp.Cmax;
        mp.constraints.add(r1 <= 0);
        mp.constraints.setNames("r1");
        r1.end();
      }

     

    Already found out that the method getAX is used to access the value of a row. But I can not do this.

    Could you help me?

    I want the value of a specific constraint.

    Thank you.

     


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Doubt in accessing value constraint model

    Posted 09/23/13 02:33 AM

    > Already found out that the method getAX is used to access the value of a row. But I can not do this.
    >
    Please be more specific. What exactly is the problem?

    > I want the value of a specific constraint.

    >
    What do you mean by "value of a constraint"? The value of its left-hand side? The slack? Its boolean value depending on whether it is satisfied or not?


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Doubt in accessing value constraint model

    Posted 09/23/13 07:21 AM

    Originally posted by: regisgomes


    Hi Junglas,

    I want the value of lhs of a constraint that I setting a name in best solution, but specifically when the best solution does not have all variables with integer value.

    mp.constraints.setNames("r1");

    I do not know properly pass the constraint which I want the value of the lhs best solution is not entire. I tried this way but it did not work:

    cout << "r1 " << mp.cplex.getAX(mp.constraints[2]) << endl;

    I used the number 2 just to test, I do not know how or if I can use the name "r1" constraint.

     

    Thanks.


    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: Doubt in accessing value constraint model

    Posted 09/23/13 07:27 AM

    And what is the error you get for this?


    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: Doubt in accessing value constraint model

    Posted 09/23/13 07:32 AM

    Originally posted by: regisgomes


    Thanks,

     

    CPLEX Error 1006: Error during callback.

     

    I am using ILOBRANCHCALLBACK.


    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: Doubt in accessing value constraint model

    Posted 09/23/13 09:13 AM

    Are you invoking IloCplex::getAX() in a callback? That is not supported. In that case use the callback's getValue() method on the expression returned by IloRange::getExpr(). This will also produce the value of the left-hand side of the constraint.


    #CPLEXOptimizers
    #DecisionOptimization


  • 7.  Re: Doubt in accessing value constraint model

    Posted 09/23/13 09:47 AM

    Originally posted by: regisgomes


    Thanks,

    Now it worked.

    Just one more question, if I can setting a name in the constraint I can use this name in the getValue method to identify the constraint that I want to access? How do I do that?


    #CPLEXOptimizers
    #DecisionOptimization


  • 8.  Re: Doubt in accessing value constraint model

    Posted 09/23/13 09:54 AM

    No, you cannot use the name of a constraint as argument to getValue(). You can only pass references to constraints to that method.


    #CPLEXOptimizers
    #DecisionOptimization


  • 9.  Re: Doubt in accessing value constraint model

    Posted 09/23/13 09:59 AM

    Originally posted by: regisgomes


    Thanks!

    You helped me greatly.

    It until a further.

     

    Regis Gomes.


    #CPLEXOptimizers
    #DecisionOptimization