Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Constraints ignored after adding lazy constraint

    Posted 09/16/15 10:40 AM

    Originally posted by: igelkun


    Dear Forum,

    I'm having troubles using lazy constraints in C++ with concert. Basically, I use cplex to find some paths in a graph and want to forbid cycles as they turn up using lazy constraints. Thus, I implemented a callback that turns the given solution into a graph, finds a cycle and adds the representation as (4 different) lazy constraint(s). Now, the first time the callback is invokes seems fine: I find the cycle and add the lazy constraint using add(). However, the second time the callback is invoked, it is given a solution that violates one of the initial conditions given to the model.

    What's a good way to debug this? Can I somehow get all constraints that the returned solution should satisfy? I also found the documentation a bit limited - is there a special way that I am supposed to add lazy constraints (what is "separation")?

     

    thanks and kind regards


    #CPLEXOptimizers
    #DecisionOptimization


  • 2.  Re: Constraints ignored after adding lazy constraint

    Posted 09/18/15 11:19 AM

    Originally posted by: igelkun


    I think I found the culprit:

    cout<<getValue(var)<<" translates to "<<(int)getValue(var)
    

    outputs

    1 translates to 0
    

    in the callback. So what is going on?


    #CPLEXOptimizers
    #DecisionOptimization


  • 3.  Re: Constraints ignored after adding lazy constraint

    Posted 09/18/15 03:34 PM

    I'm not positive (I last used C++ in a different millennium), but I think casing a float/double to int truncates rather than rounds. So var is something like 0.9999995, which is within integer feasibility tolerance of 1 (and which CPLEX treats as 1) but which your code truncates to 0.


    #CPLEXOptimizers
    #DecisionOptimization


  • 4.  Re: Constraints ignored after adding lazy constraint

    Posted 09/19/15 06:49 AM

    Originally posted by: igelkun


    yep, that seems to be the case. Is there a way to get the value that cplex meant to assign to the variable, instead of what it actually does assign? Something that gives me the value as which CPLEX treats the value returned by getValue()?

    For now I resorted to lround() but that will break if I change the domain to non-integer...


    #CPLEXOptimizers
    #DecisionOptimization


  • 5.  Re: Constraints ignored after adding lazy constraint

    Posted 09/19/15 04:42 PM

    The value CPLEX returns is the value it meant to assign; it just accepts floating point numbers "near enough" to an integer as meeting the integrality restriction. For binary variables, I use the rule that anything less than 0.5 is a 0 and anything greater than 0.5 is a 1. You don't have to worry about exactly 0.5, because that would not satisfy the integrality tolerance (unless you did something really silly while setting parameters). A similar rule works for general integer variables.

    If you make the variable real-valued, and CPLEX gives you 0.999997, assume that CPLEX meant 0.999997. There may be rounding/truncation error in that value, but it's what CPLEX thought was the solution when it terminated.


    #CPLEXOptimizers
    #DecisionOptimization


  • 6.  Re: Constraints ignored after adding lazy constraint

    Posted 09/20/15 09:22 AM

    Originally posted by: igelkun


    alright, thanks for the help :)


    #CPLEXOptimizers
    #DecisionOptimization