Decision Optimization

Decision Optimization

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

 View Only
Expand all | Collapse all

Is it possible to activate and deactivate an IloConstraint

  • 1.  Is it possible to activate and deactivate an IloConstraint

    Posted Thu June 07, 2018 02:43 PM

    Originally posted by: Can Li


    Hi folks,

     

    I'm wondering if it is possible to deactivate and then activate (not remove and add again) an IloConstraint with C++ API by the name of the constraint.

    For example, suppose I have

    IloConstraint c2(expr>=0);

    c2.setName("newconstraint");

    model.add(c2);

    Is it possible to deactivate "newconstraint"? Is it possible to make it active again after deactivating it?

    Thanks in advance!

     

    Best regards,

    Can


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Is it possible to activate and deactivate an IloConstraint

    Posted Fri June 08, 2018 03:37 AM

    First of all, if you only have the name and no reference to the constraint, then you have find back a reference to the constraint. This can be done by using an IloIterator and checking the name of each constraint. This is not very efficient, so if possible store a reference to the constraint, not its name.

    Next, there are no facilities to deactivate a constraint. What you could do is to clear its left-hand side or set the right-hand side to infinity so that the constraint becomes redundant. Both are not recommended unless absolutely necessary.

    Is there a particular reason you cannot remove/add the constraint?


    #CPLEXOptimizers
    #DecisionOptimization