Decision Optimization

Decision Optimization

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

 View Only
  • 1.  how to change RHS

    Posted Wed April 06, 2011 04:38 PM

    Originally posted by: Sung_Hwang


    Dear all,

    I am a CPLEX beginner and I want to change RHS value every iteration.

    For example, I have a problem as below.

    min x1 + 2x2 + 3x3
    s.t
    x1 + 3x3 >= 5
    x2 + x3 = 1
    x1, x2, x3 >=0

    After first iteration, I would like to change RHF from (5, 1) to (3, 3).

    I found that setBounds is the function that changes RHS, but still dont know how to use it.

    thank you
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: how to change RHS

    Posted Wed April 06, 2011 06:09 PM

    Originally posted by: SystemAdmin


    In the c++ and Java APIs (probably also Python), the methods that add constraints to a model return the constraint (actually, a pointer to it). Store the constraints someplace (maybe in an array or list). Then go back and call the setBounds method on each constraint whose right hand side changes. You can call setUB or setLB for inequalities (for instance, in your example, I would call setLB to change the 5). If you call setBounds, you need to make one of the bounds infinite when dealing with an inequality. To change an equation, you call setBounds with the new RHS as the value for both bounds.

    Paul

    Mathematicians are like Frenchmen: whenever you say something to them, they translate it into their own language, and at once it is something entirely different. (Goethe)
    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: how to change RHS

    Posted Fri April 08, 2011 02:32 AM

    Originally posted by: Sung_Hwang


    Thank you Rubin,

    I have one more question.

    You said the model return the constrain set, but how it happen?

    I know the function that return the objective function, but I could not find the function that return the constraints.

    Thank you

    -Sung-
    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: how to change RHS

    Posted Fri April 08, 2011 09:44 AM

    Originally posted by: SystemAdmin


    The functions that add the constraints to the model return a reference to the constraints added. In C++ this is for example IloModel::add(), in Java IloCplex.add(). In C++ you can do
    IloExtractable ref = model.add(x <= 3);
    

    and 'ref' will be a reference to the constraint 'x <= 3' that you just added. Similarly in Java.
    Checkout the CPLEX reference manual for further details about the various add() methods.
    #CPLEXOptimizers
    #DecisionOptimization