Decision Optimization

Decision Optimization

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

 View Only
  • 1.  IloConstraint

    Posted Sat June 12, 2010 01:04 PM

    Originally posted by: JFCote


    Hi guys,
    I'm doing a Branch-And-Cut algorithm for a MIP problem. At each node of the B&B, I would like to check if the solution satisfies or not a set of constraints contained into a IloConstraintArray.

    My call back method is something like ILOCUTCALLBACK1

    I tryed to call the method getValue( IloConstraintArray [i] ) but it returned a runtime error :

    terminate called after throwing an instance of 'IloNotImplemented'
    Aborted
    Can somebody help to do what I wish to do?

    Thank you very much

    Jean-François
    PS. I would like to try this into my code without having to change
    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: IloConstraint

    Posted Mon June 14, 2010 01:30 AM

    Originally posted by: SystemAdmin


    Can you figure out the exact message of the exception? That is, can you catch the exception and write out the exception message?

    What type of constraints do you have in your array? Are these all linear inequalities or are there higher-level constraints like 'or', 'and' etc. What is the constraint that triggers the exception?
    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: IloConstraint

    Posted Mon June 14, 2010 02:48 AM

    Originally posted by: JFCote


    Here's a piece of code similar to what I want to do.

    ILOCUTCALLBACK1(CutCallBackMethod,IloNumVarArray,x)
    {
    for(int i=0;i<globalCutSet.getSize();i++)
    {
    try
    {
    double l = getValue(globalCutSet[i]);
    }
    catch(IloException exp)
    {
    std::cout << exp.getMessage() << std::endl;
    exit(1);
    }
    addLocal(globalCutSet[i]);
    }
    }
    And here's the message I get which does not say much.. :

    IloAlgorithm::getValue(IloConstraint) is not implemented
    All the constraints that I create are linear inequalities. They are created this way :

    IloExpr constraint(x.getEnv());
    //Add some boolean variables to the IloExpr

    array.add(expr <= s); //s is generally an integer
    Thank you!

    Jean-François
    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: IloConstraint

    Posted Wed June 16, 2010 06:48 AM

    Originally posted by: JFCote


    I found that getValue(IloConstraintArray[i]) on Cplex 10 does not work. I moved to Cplex 12 and it works.

    It seems that Cplex returns 0.00000 when a constraint is violated and 1.00000 when it is not.
    However, now I have an another problem.

    I add some of these violated constraints to Cplex as a local cut and sometimes does not call the CutCallBack method after solving the LP relaxation which is problematic because I can not find violated inequalities with my algorithms. And Cplex thinks he found a feasible solution which is not..
    Other times, it seems the constraint is violated but it makes no difference to the objective function so the constraint is added over and over..
    Can somebody give me some hints on how I can solve this problem?

    Thank you very much

    JF
    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: IloConstraint

    Posted Wed June 16, 2010 08:30 AM

    Originally posted by: SystemAdmin


    > JFCote wrote:
    > I found that getValue(IloConstraintArray[i]) on Cplex 10 does not work. I moved to Cplex 12 and it works.
    >
    > It seems that Cplex returns 0.00000 when a constraint is violated and 1.00000 when it is not.

    If you prefer to see the slack in the constraint, you can use the getSlack(IloRange) method.
    >
    >
    > However, now I have an another problem.
    >
    > I add some of these violated constraints to Cplex as a local cut and sometimes does not call the CutCallBack method after solving the LP relaxation which is problematic because I can not find violated inequalities with my algorithms.

    Are you sure about this? I've never heard of CPLEX failing to call the cut callback at a node. You should note, though, that if CPLEX gets a fractional solution to the node LP (after calling the cut callback) and then finds a potential incumbent via a heuristic, it will call the incumbent callback (if there is one) but I do not believe it will call the cut callback again at that node.
    > And Cplex thinks he found a feasible solution which is not..
    >
    >
    > Other times, it seems the constraint is violated but it makes no difference to the objective function so the constraint is added over and over..

    Are you saying the same cut is added repeatedly +at the same node+? If so, either the cut is not violated by the node LP solution (so you are adding a redundant cut) or the LP solution is changing (the cut is not redundant) but somehow your cut generator is repeating the same cut anyway.

    /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: IloConstraint

    Posted Wed June 16, 2010 12:13 PM

    Originally posted by: JFCote


    Thanks for your reply Paul,

    I moved all my code to use IloRangeArray instead of IloConstraintArray.

    I tryed using your method getSlack but I'm getting a IloAlgorithm::NotExtractedException. I don't exactly understand what it is..
    I'm creating my constraint this way :

    //array is a IloRangeArray
    IloExpr expr(x.getEnv()); //x is a array of variables

    //Here I add some variables

    IloRange range(x.getEnv(), expr, NodeListSize-1, "SubtourConstraint");
    array.add(range);

    What do I do wrong to get this error?

    Thank you

    JF
    #CPLEXOptimizers
    #DecisionOptimization


  • 7.  Re: IloConstraint

    Posted Wed June 16, 2010 02:20 PM

    Originally posted by: SystemAdmin


    You have not added 'range' to the instance of IloModel that you are trying to solve.

    /Paul
    #CPLEXOptimizers
    #DecisionOptimization