Decision Optimization

 View Only
  • 1.  Removing constraints CP

    Posted Wed November 17, 2021 06:56 AM
    Hello,

    Once I have the model written (CP with C++ API), if there's no solution, I would like to remove some constraints. I've see the model.remove(obj) but it seems is only valid for removing objectives but not constraints. Which is the right way to do it? The constraints are defined with IloConstraint in order to give them a name.

    Cheers

    ------------------------------
    javier rodrigo
    ------------------------------

    #DecisionOptimization


  • 2.  RE: Removing constraints CP

    Posted Wed November 17, 2021 11:58 AM
    Dear Javier,

    You should be able to use the "remove" method of the "IloModel" class: https://www.ibm.com/docs/en/icos/20.1.0?topic=classes-ilomodel

    Its signatures accept IloExtractable objects which can be anything added to the model.

    Cheers,

    ------------------------------
    Renaud Dumeur
    ------------------------------



  • 3.  RE: Removing constraints CP

    Posted Thu November 18, 2021 06:14 AM
    Edited by System Fri January 20, 2023 04:17 PM
    My fault. The constraint was defined inside a loop so it was local. Fixed. I guess once I remove the constraint, I have to call again the cp.solve or cp.StartewSearch, is that correct?

    What if I try to modify the bounds of the constraint? It looks like with cplex is possible but with cp is not.
    ct.add(IloBound(10, IloBound::Lower)); is fine with cplex but with cp it does not recognize the IloBound.

    thanks so much

    ------------------------------
    javier rodrigo
    ------------------------------



  • 4.  RE: Removing constraints CP

    Posted Fri November 19, 2021 05:52 AM
    Dear Javier,

    - Yes you have to perform  a new search so that the change to the model can be taken into account.
    - No IloBound isn't understood by CPO. It is a cplex-specific construct defined in ilocplex.h (and it takes a variable, not a constant).

    Cheers,

    ------------------------------
    Renaud Dumeur
    ------------------------------