Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only

Very simple OPL : solution pools

  • 1.  Very simple OPL : solution pools

    Posted 11/07/18 05:45 AM

    Hi,

     

    let us go on with https://www.linkedin.com/pulse/making-decision-optimization-simple-alex-fleischer/

     

     

    But now suppose we do not need only the optimal solution but a few alternatives to share.

    Solution pools!

    Let me share a tiny example:

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

    execute
    {
    writeln("nbBus40 = ",nbBus40," and nbBus30 = ",nbBus30," and the cost is ",costBus40*nbBus40  +nbBus30*costBus30);
    }

     main {
    cplex.solnpoolintensity=2;

        thisOplModel.generate();
        cplex.solve();
        if (cplex.populate()) {
          var nsolns = cplex.solnPoolNsolns;
          
          
          writeln("Number of solutions found = ",nsolns);
          writeln();
          for (var s=0; s<nsolns; s++) {
            thisOplModel.setPoolSolution(s);
            thisOplModel.postProcess();
          }
        }
    }

     

    which gives

     

    Number of solutions found = 3

    nbBus40 = 6 and nbBus30 = 2 and the cost is 3800
    nbBus40 = 7 and nbBus30 = 1 and the cost is 3900
    nbBus40 = 8 and nbBus30 = 0 and the cost is 4000

    regards

     

    Alex Fleischer

    PS:

    Many how to with OPL at https://www.linkedin.com/pulse/how-opl-alex-fleischer/

    Many examples from a very good book : https://www.linkedin.com/pulse/model-building-oplcplex-alex-fleischer/

    Making optimization simple : https://www.linkedin.com/pulse/making-decision-optimization-simple-alex-fleischer/

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer