Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  removing/changing constraint

    Posted 06/30/09 01:54 PM

    Originally posted by: SystemAdmin


    [Mr.Buxley said:]

    Im using the concert Tech. to solve  MIP problems and then I add my own cutting planes to the model using an IloExprArray and resolve.
    Is there Any way I can delete/change a constraint that has been added to the model without removing them all...

    Everytime between solving the Mip i add a constraint like this

    arr[i]+=something...
    model.add(arr[i]<=x[n])<br />
    Where arr is an IloExprArray

    Let's say I would like to modify the last constraint that I added before solving the model.
    Is there a way I can do that directly!
    Thanks for the help

    /Bux


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: removing/changing constraint

    Posted 06/30/09 07:33 PM

    Originally posted by: SystemAdmin


    [prubin said:]

    This is the C++ API, right?

    Create the initial constraint as an IloRange, as in

    IloRange myConstraint = new IloRange(...);
    model.add(myConstraint);

    After solving the model, modify the coefficients of the constraint with myConstraint.setLinearCoef(...) or myConstraint.setLinearCoefs(...), or just replace the left side with myConstraint.setExpr(...).  To mess with the right-hand side, use myConstraint.setUB(...).

    /Paul
    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: removing/changing constraint

    Posted 07/01/09 03:24 PM

    Originally posted by: SystemAdmin


    [Mr.Buxley said:]

    Yes, C++API.
    Thanks man that really helped...
    /Bux

    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: removing/changing constraint

    Posted 07/01/09 03:55 PM

    Originally posted by: SystemAdmin


    [Mr.Buxley said:]

    Can I do the same thing if I use an IloRangeArray instead of IloRange?
    e.g.
    can I change the coefs of MyConstraint[3]
    where MyConstraint is of type IloRangeArray?
    Thanks
    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: removing/changing constraint

    Posted 07/01/09 11:23 PM

    Originally posted by: SystemAdmin


    [prubin said:]

    MyConstraint[3] is class IloRange, so yes.
    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: removing/changing constraint

    Posted 07/08/09 12:39 PM

    Originally posted by: SystemAdmin


    [Mr.Buxley said:]

    OOops yes of course,my mistake...

    What I ment to ask was can I add or remove something from the coeff without knowing the value of the coeff.
    For example

    IloRange myCon=  x1+x2<=3<br />setLinerarCoef  (
    Here I would like to add 3 to the coef before x1 so myCon would become 3x1+x2<=3 and if it would have been 2x it would become 5x and so on...<br />
    However I have many,many constraints and don't know the different values for the coeffs in the differnet constraints.
    I would like to add or remove 3 to the current value for every coeff before x1 in every constraint...
    How do I do that?


    [b]Thanks again![/b]
    /Bux
    #CPLEXOptimizers
    #DecisionOptimization


  • 7.  Re: removing/changing constraint

    Posted 07/09/09 12:15 AM

    Originally posted by: SystemAdmin


    [prubin said:]

    [quote author=Mr.Buxley link=topic=1238.msg3536#msg3536 date=1247038735]
    What I ment to ask was can I add or remove something from the coeff without knowing the value of the coeff.
    For example

    IloRange myCon=  x1+x2<=3<br />setLinerarCoef  (
    Here I would like to add 3 to the coef before x1 so myCon would become 3x1+x2<=3 and if it would have been 2x it would become 5x and so on...<br />
    However I have many,many constraints and don't know the different values for the coeffs in the differnet constraints.


    Store them somewhere (either at the time you compute them or at the time you read them in, whichever applies), then update the stored values at the same time you change them in the constraints.

    The CPLEX programmers have an odd affinity for asymmetry.  There's a method to set an individual coefficient directly but not (at least as of version 11) a method to get one directly.  The only alternative I know to storing them yourself is to use a IloLinearNumExprIterator, but that requires that you iterate over every term in each expression until you find the one you want.  Storing the coefficients is much less painful.
    #CPLEXOptimizers
    #DecisionOptimization


  • 8.  Re: removing/changing constraint

    Posted 07/09/09 12:21 PM

    Originally posted by: SystemAdmin


    [Mr.Buxley said:]

    The CPLEX programmers have an odd affinity for asymmetry.  There's a method to set an individual coefficient directly but not (at least as of version 11) a method to get one directly.

    That is pretty odd...

    Thanks a lot
    /Bux
    #CPLEXOptimizers
    #DecisionOptimization