Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only

Very simple OPL : Conflicts and relaxations

  • 1.  Very simple OPL : Conflicts and relaxations

    Posted 06/22/18 09:28 AM

    Hi,

    let us go on with

    https://www.linkedin.com/pulse/what-optimization-how-can-help-you-do-more-less-zoo-buses-fleischer/

     

    and address a new concern : infeasibility!

     

    Let us suppose we have a new challenge : use less than 7 buses overall.

    Then we write

    int nbKids=300;
    float costBus40=500;
    float costBus30=400;
     
    dvar int+ nbBus40;
    dvar int+ nbBus30;
     
    minimize
     costBus40*nbBus40  +nbBus30*costBus30;
     
    subject to
    {
     ctAllKidsNeedToGo:
         40*nbBus40+nbBus30*30>=nbKids;
     
     ctMaxTotalBuses:
         nbBus30+nbBus40<=7;
    }

    ctAllKidsNeedToGo and ctMaxTotalBuses are labels for the constraints.

     

    But then the problem gets infeasible since even with 7 buses with 40 seats you can take only 280=7*40 kids which is less than 300 kids.

    When we launch this model, we get a conflict

    which means we have a conflict within those 2 constraints and

    a relaxation

    which means that if we relax 7 buses to 8 buses then we have a feasible solution.

    This is not very useful for this tiny example but for real models this can be key.

    For more see Relaxing infeasible models in the IDE Tutorials in CPLEX documentation

    regards

    NB:

    You can also get that info through flow control in scripting:

    int nbKids=300;
    float costBus40=500;
    float costBus30=400;
     
    dvar int+ nbBus40;
    dvar int+ nbBus30;
     
    minimize
     costBus40*nbBus40  +nbBus30*costBus30;
     
    subject to
    {
     ctAllKidsNeedToGo:
         40*nbBus40+nbBus30*30>=nbKids;
     
     ctMaxTotalBuses:
         nbBus30+nbBus40<=7;
    }

    main
    {
    thisOplModel.generate();
    if (!cplex.solve())
    {
    writeln(thisOplModel.printRelaxation());
    writeln(thisOplModel.printConflict());
    }
    }

    gives

     

    ctMaxTotalBuses
        relax [-Infinity,7] to [-Infinity,8] value is -Infinity

    ctAllKidsNeedToGo
      is in conflict
    ctMaxTotalBuses
      is in conflict

     

     

     

     

     

     

     

     

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer