Decision Optimization

Decision Optimization

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

 View Only
  • 1.  Lazy constraints + logical constraints

    Posted Mon September 10, 2012 11:02 AM

    Originally posted by: LeandroCC


    Is it possible to have a logical constraint (IloIfThen in my case) as a lazy constraint?

    When creating my model I have:

    IloConstraintArray lazy(env);
    //add bunch of constraints to lazy as
    lazy.add(constraint);
     
    IloCplex cplex(model);
    for (int i=0 ; i < lazy.getSize() ; i++)
       cplex.addLazyConstraint(lazy[i]);
     
    for (int i=0 ; i < lazy.getSize() ; i++)
       lazy[i].end();
    lazy.end();
    


    Some of these constraints are logical ones, using IloIfThen.

    When running, the program crashes in the line cplex.addLazyConstraint(lazy[i]); with the following error:

    Warning: Lazy constraints freed during column deletion.
    terminate called after throwing an instance of 'IloCplex::InvalidCutException'
    Aborted (core dumped)
    What is it trying to delete?? Is the invalid cut a lazy constraint containing a logical one?

    Is there a way to do it?

    Thanks
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Lazy constraints + logical constraints

    Posted Tue September 11, 2012 05:30 PM

    Originally posted by: SystemAdmin


    If you print lazy[i] immediately before you add it, does it look correct?

    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: Lazy constraints + logical constraints

    Posted Tue September 11, 2012 07:25 PM

    Originally posted by: LeandroCC


    Yes, it looks correct:

    IloIfThenI (57157)
      left (my if statement)
      right (my then statement)
     
    Warning:  Lazy constraints freed during column deletion.
    terminate called after throwing an instance of 'IloCplex::InvalidCutException'
    


    Other information:

    I added a regular constraint to the same array, which is added normally to the model.
    If I add the IloIfThen constraint via model.add instead of addLazyConstraint then it works fine.
    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: Lazy constraints + logical constraints

    Posted Wed September 12, 2012 07:18 PM

    Originally posted by: SystemAdmin


    Does the exception occur with i = 0? If yes, does switching lazy[0] with lazy[1] before adding cause the exception to remain at i = 0 or switch to i = 1? (I'm trying to ascertain whether it's a specific constraint causing problems or just the first encounter with a lazy if-then. p

    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


  • 5.  Re: Lazy constraints + logical constraints

    Posted Wed September 12, 2012 08:02 PM

    Originally posted by: SystemAdmin


    It may not be possible to do this after all.

    Both the C++ and Java API docs (for CPLEX 12.4) say that ifThen generates an instance of IloConstraint and that addLazyConstraint adds an instance of IloConstraint. I just tried doing essentially the same thing you did, but in Java. It threw an exception, but not the one you saw. The Java exception was
    java.lang.ClassCastException: ilog.cplex.CpxIfThen cannot be cast to ilog.cplex.CpxRange
    
    That suggests that, documentation notwithstanding, addLazyConstraint is limited to instances of IloRange, and if-then constraints do not convert to ranges. (That last part is totally plausible to me.)

    If I'm right, then (a) the docs are a bit less than totally forthcoming and (b) the C++ exception is a bit more cryptic than one might hope.

    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


  • 6.  Re: Lazy constraints + logical constraints

    Posted Wed September 12, 2012 08:33 PM

    Originally posted by: LeandroCC


    Answering your previous post, i=1 continues to throw the exception. It happens in the first IloIfThen, not a particular one.

    Following your second post, I guess we will have to wait for someone from IBM to answer this one. I really don't see why this shouldn't be possible.

    Thanks for the interest, Paul!
    #CPLEXOptimizers
    #DecisionOptimization


  • 7.  Re: Lazy constraints + logical constraints

    Posted Mon September 17, 2012 04:21 PM

    Originally posted by: SystemAdmin


    Lazy constraints must be linear constraints. Logical constraints are not allowed here. That the function signature says 'IloConstraint' is actually a bug in the API that we fixed recently. The functions accept only 'IloRange' arguments. Everything else will result in runtime errors.
    #CPLEXOptimizers
    #DecisionOptimization