Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  CPLEX Gap

    Posted 06/26/20 03:08 AM
    Hi,

    I am trying to understand the optimality gap that CPLEX gave me and how it works.
    Specially, I am wondering how the solver can give me a solution if it is not the optimal one. Does it mean that the program leaves some constraints out so that it can find feasible solutions? Or are all the feasible solutions with a gap 'correct' (i.e. all the constraints are taken into account) but there are still maybe better solutions to be found?

    I am solving a large model and sometimes when I get a solution with a gap, not all constraints are working correctly anymore. I am trying to understand if CPLEX is ignoring these constraints or if I modelled something wrong.

    Thank you in advance!

    ------------------------------
    Floor M
    ------------------------------

    #DecisionOptimization


  • 2.  RE: CPLEX Gap

    Posted 06/26/20 03:34 AM
    Edited by System Admin 01/20/23 04:31 PM
    Hi

    "all the constraints are taken into account  but there are still maybe better solutions to be found"

    is true in what you wrote.

    If you re relying on the OPL API, if your model is not feasible then CPLEX will automatically try to find some relaxation / conflicts

    regards

    PS:

    See https://www.ibm.com/support/knowledgecenter/SSSA5P_12.10.0/ilog.odms.ide.help/OPL_Studio/usroplide/topics/opl_ide_relax.html for more



    ------------------------------
    ALEX FLEISCHER
    ------------------------------



  • 3.  RE: CPLEX Gap

    Posted 06/26/20 03:48 AM
    Any solution that CPLEX reports as feasible should satisfy all constraints.If you observe otherwise then please provide an example because that then smells like a bug.

    ------------------------------
    Daniel Junglas
    ------------------------------



  • 4.  RE: CPLEX Gap

    Posted 06/26/20 04:12 AM
    Yes indeed, CPLEX indicates that the solution is feasible but does not satisfy all constraints. 
    I made a VRP, and I see that some of the arrival times at different locations are equal, which is not possible because there is travel time between these locations. 
    I am a beginner in using CPLEX so it could be that I made mistakes.
    CPLEX gives an 'out of memory' error after several hours (my laptop does not have a huge working memory), some feasible solutions were given in the meantime but then, as explained above, some of my arrival times (which are one of my decision variables) are not working accordingly.
    I put my files in the appendix.
    Thank you in advance!

    ------------------------------
    Floor M
    ------------------------------



  • 5.  RE: CPLEX Gap

    Posted 06/26/20 06:21 AM
    Could it be that your model is lacking some constraints? When I run your model here, it is perfectly feasible. How do you determine that a constraint is not satisfied? Do you plug in the solution values and with them the constraint is not satisfied? Are you sure that the values produced by CPLEX indeed violate the constraint as it is written in the .mod? Which is the offending constraint?

    ------------------------------
    Daniel Junglas
    ------------------------------



  • 6.  RE: CPLEX Gap

    Posted 06/26/20 06:24 AM
    There are some suspicious things in your .mod file:
    forall (i in S, v in V, r in R) sum (i, j in S : i != j) y[i][j][v][r] == sum (i, j in S : i != j) y[j][i][v][r];

    Here you use index 'i' twice! You use it once in the forall and once in the sum. This is most likely not what you want to do since the latter shadows the former. Maybe what you wanted to write was this
    forall (i in S, v in V, r in R) sum (j in S : i != j) y[i][j][v][r] == sum (j in S : i != j) y[j][i][v][r];

    That would be a standard flow conservation constraint.
    The same issue exists for several other constraints.



    ------------------------------
    Daniel Junglas
    ------------------------------