Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Solving lexicographic multi-objective problems with OPL

    Posted 09/15/17 03:54 AM

    Hi

    Let 's start with a tiny example:

    suppose you have 10*10 boxes and you want to select 25 boxes (The green ones below) so that first we still have maximum spare down rows and then second maximum spare right columns.

     

    You have several ways to model this with OPL:

    1) Use weights within CPLEX

    int n=10;
    int m=25;

    range position = 1..n;

    dvar boolean x[position][position];
    dvar int obj1 in position;
    dvar int obj2 in position;

    minimize (obj1-1)*n+obj2;

    subject to
    {
      sum(i,j in position) x[i][j]==m;
     
      obj1==max(i,j in position) i*x[i][j];
      obj2==max(i,j in position) j*x[i][j];
    }

    execute
    {
    writeln("objectives : ",obj1," ",obj2);

    writeln("-----------------------------");
    writeln();

    for(var i in position)
    {
     for(j in position) write((x[i][j]==1)?"+":" ");
     writeln();
    }
    }

    2) Use flow control to solve with the first objective and then the second objective while freezing the first one (Goal programming):

    int n=10;
    int m=25;

    range position = 1..n;

    dvar boolean x[position][position];
    dvar int obj1 in position;
    dvar int obj2 in position;

    minimize (obj1-1)*n+obj2;

    subject to
    {
      sum(i,j in position) x[i][j]==m;
     
      obj1==max(i,j in position) i*x[i][j];
      obj2==max(i,j in position) j*x[i][j];
    }

    execute
    {
    writeln("objectives : ",obj1," ",obj2);

    writeln("-----------------------------");
    writeln();

    for(var i in position)
    {
     for(j in position) write((x[i][j]==1)?"+":" ");
     writeln();
    }
    }

     main
     {
       thisOplModel.generate();
       cplex.setObjCoef(thisOplModel.obj2,0);
       cplex.solve();
       thisOplModel.postProcess();
       var obj1=thisOplModel.obj1.solutionValue;
       thisOplModel.obj1.LB=obj1;
       thisOplModel.obj1.UB=obj1;
       cplex.setObjCoef(thisOplModel.obj2,1);
       cplex.solve();
       thisOplModel.postProcess();
        
     }

    3) Use the built in lexicographic objective within CPO:

    using CP;

    int n=10;
    int m=25;

    range position = 1..n;

    dvar boolean x[position][position];
    dvar int obj1 in position;
    dvar int obj2 in position;

    minimize staticLex(obj1,obj2);

    subject to
    {
      sum(i,j in position) x[i][j]==m;
     
      obj1==max(i,j in position) i*x[i][j];
      obj2==max(i,j in position) j*x[i][j];
    }

    execute
    {
    writeln("objectives : ",obj1," ",obj2);

    writeln("-----------------------------");
    writeln();

    for(var i in position)
    {
     for(j in position) write((x[i][j]==1)?"+":" ");
     writeln();
    }
    }

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: Solving lexicographic multi-objective problems with OPL

    Posted 10/07/18 12:22 PM

    Originally posted by: MachexC


    Hi Alex,

    Why using CP can not declare a dvar that is float variable? it is error.

    For example,

    using CP;

    dvar float+ X[i]; -----> error

    Thank you,

    Mac

     

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: Solving lexicographic multi-objective problems with OPL

    Posted 10/08/18 03:34 AM

    Hi,

    float decision variables are not allowed with CPO.

    But you could use float decision expressions as a workaround in many situations.

    Se the example at CPLEX_Studio128\opl\examples\opl\floatexpr

    Do not hesitate to open new threads for questions instead of using previous threads.

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: Solving lexicographic multi-objective problems with OPL

    Posted 03/27/19 08:45 AM

    and now with CPLEX 12.9 staticLex works also for Linear models:

    So we have a 4th way:

    4)

     

    int n=10;
    int m=25;

    range position = 1..n;

    dvar boolean x[position][position];
    dvar int obj1 in position;
    dvar int obj2 in position;

    minimize staticLex(obj1,obj2);

    subject to
    {
      sum(i,j in position) x[i][j]==m;
     
      obj1==max(i,j in position) i*x[i][j];
      obj2==max(i,j in position) j*x[i][j];
    }

    execute
    {
    writeln("objectives : ",obj1," ",obj2);

    writeln("-----------------------------");
    writeln();

    for(var i in position)
    {
     for(j in position) write((x[i][j]==1)?"+":" ");
     writeln();
    }
    }

     

    which gives

    // solution (multi-objective optimal) with objective 3
    objectives : 3 9
    -----------------------------

    +++++++++
    ++++++  +
    +++++++++

    and in the cplex log we see

     

    Multi-objective solve log . . .

    Index  Priority  Blend          Objective      Nodes  Time (sec.)  DetTime (ticks)
        1         1      1   3.0000000000e+00          0         0.19            49.19
        2         0      1   9.0000000000e+00          0         0.02             3.47

    regards

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer