Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  To plot the trade-off between the objectives

    Posted 12/08/17 05:13 AM

    Originally posted by: ShaCplex


    Dear Alex sir,

    I am modelling an LP with two objectives using weighted sum. My objective function look like;

    minimize  w1 C(x) + w2 U(x)

    C(x) is my cost function and U(x) is my non-utilization function which are conflicting in nature.

    where w1 and w2 are the weights to the objectives respectively.

    I would like to solve the problem for different set of weight combination for (w1,w2)  such as (0.9,0.1), (0.8,0.2), (0.7,0.3), (0.6, 0.4), (0.5,0.5) (0.4,0.6), (0.3,0.7), (0.2,0.8), (0.1,0.9).

     

    How can I write a OPL script in the same .mod file to automate this? At each run, it should take different weights and run.

    Please help me.

     

     

     

     

    Regards,

    shahul

     


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 2.  Re: To plot the trade-off between the objectives

    Posted 12/08/17 05:31 AM

    Hi,

    let me adapt a bit https://www.ibm.com/developerworks/community/forums/html/topic?id=193ecefc-757c-4c66-9905-7ac0dd81dc8f&ps=25

    to your need

     

        int n=10;
        int m=25;
        
        {float} coefs={0.1*i | i in 1..10};

        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();
           
           for(var c1 in thisOplModel.coefs) for(var c2 in thisOplModel.coefs)
           {
               cplex.setObjCoef(thisOplModel.obj1,c1);
               cplex.setObjCoef(thisOplModel.obj2,c2);
               cplex.solve();
               writeln("c1 = ",c1," and c2 = ",c2);
               thisOplModel.postProcess();
         }           
            
         }

     

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 3.  Re: To plot the trade-off between the objectives

    Posted 12/08/17 11:09 AM

    Originally posted by: ShaCplex


    thank you very much sir..!!

     

     

     

     

     

    Regards,

    shahul


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 4.  Re: To plot the trade-off between the objectives

    Posted 12/13/17 01:49 AM

    Originally posted by: ShaCplex


    Sir,

    I found a small issue in this;

    To illustrate,

    say, the objective function gives the value -9 when obj1 = 5, obj2 = 5  & weights c1 = 0.1 , c2 = 0.1.

    minimize (obj1-1)*n+obj2;

    ideally, i think it should be,

    (5*0.1-1)*10 + 5*0.1 = - 4.5

    instead,

    it multiplies c1(=0.1) twice. i.e,

    (5*0.1*0.1 - 1)*10 - 5*0.1 = -9

    where is it going wrong ?

     

     

     

     

    Regards,

    shahul


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 5.  Re: To plot the trade-off between the objectives

    Posted 12/13/17 03:23 AM

    Hi,

    can you try with

    int n=10;
        int m=25;
        
        {float} coefs={0.1*i | i in 1..10};

        range position = 1..n;

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

        minimize 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," combined objective ",cplex.getObjValue());

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

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

         main
         {
           thisOplModel.generate();
           
           for(var c1 in thisOplModel.coefs) for(var c2 in thisOplModel.coefs)
           {
               cplex.setObjCoef(thisOplModel.obj1,c1);
               cplex.setObjCoef(thisOplModel.obj2,c2);
               cplex.solve();
               writeln("c1 = ",c1," and c2 = ",c2);
               thisOplModel.postProcess();
         }           
            
         }

    ?

    regards


    #DecisionOptimization
    #OPLusingCPLEXOptimizer


  • 6.  Re: To plot the trade-off between the objectives

    Posted 12/13/17 04:15 AM

    Originally posted by: ShaCplex


    Sir,

    this works perfectly alright. may be earlier we had more terms in the objective function I suspect.

     

    Thank you again..

     

     

     

    shahul


    #DecisionOptimization
    #OPLusingCPLEXOptimizer