Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  Change a parameter and run the same model

    Posted 07/06/21 02:18 PM
    Hello,

    I have a bi-objective model and I would like to change the "lambda" parameter in my model from 0.1 to 0.9 to get the Pareto and then get the lambda, f1, and f2 as an output for all lambdas. Could you please help me in this regard?
    I think I need a main section and post-processing but I don't know how to implement it. In the main part I think I need a for loop but I am not sure. I would appreciate it if you could help me in this regard with an example. 

    execute
    {
    writeln("lambda = ",lambda);
    writeln("Objective 1 = ", f1);
    writeln("Objective 2 = ", f2);
    writeln("Objective = ", cplex.getObjValue());
    }

    main
    {
    thisOplModel.generate();
    cplex.solve();
    thisOplModel.postProcess();
    writeln();
    }

    ------------------------------
    Siamak Mushakhian
    ------------------------------

    #DecisionOptimization


  • 2.  RE: Change a parameter and run the same model

    Posted 07/07/21 02:57 AM
    Hi,
    in Making optimization Simple
    see
    Simulation and what if analysis

    
    int nbKids=300;
    
    {int} nbKidsOptions={nbKids+i*10 | i in -10..2};
    int x2[i in 1..card(nbKidsOptions)]=item(nbKidsOptions,i-1);
    int y2[i in 1..card(nbKidsOptions)];
    
    float costBus40=500;
    float costBus30=400;
     
    dvar int+ nbBus40;
    dvar int+ nbBus30;
     
    minimize
     costBus40*nbBus40  +nbBus30*costBus30;
     
    subject to
    {
     ctKids:40*nbBus40+nbBus30*30>=nbKids;
    }
    
    execute
    {
    writeln("nbBus40 = ",nbBus40);
    writeln("nbBus30 = ",nbBus30);
    }
    
    main
    {
    thisOplModel.generate();
    var k=1;
    for(var nbKids in thisOplModel.nbKidsOptions)
    
    {
    writeln("if we need to bring ",nbKids," kids  to the zoo");
        
    thisOplModel.ctKids.LB=nbKids;
    
    cplex.solve();
    thisOplModel.postProcess();
    writeln("And the cost is ",cplex.getObjValue());
    thisOplModel.y2[k]=cplex.getObjValue();
    k++;
    writeln();
    }
    
    
    
     
    
     
    
    } 
    ​


    ------------------------------
    [Alex] [Fleischer]
    [EMEA CPLEX Optimization Technical Sales]
    [IBM]
    ------------------------------



  • 3.  RE: Change a parameter and run the same model

    Posted 07/07/21 12:48 PM
    Hi Alex, 

    Thanks for your reply. 
    I added a line to the execute section as below:
    writeln("nbkids = ", nbKids);

    When I run the model, in the script log I find two different values for the nbkids, Could you possibly explain to me why it that? 

    Best regards,

    ------------------------------
    Siamak Mushakhian
    ------------------------------



  • 4.  RE: Change a parameter and run the same model

    Posted 07/08/21 03:44 AM
    Hi,

    nbKids is still 300 and does not change.

    What you should write in the postprocess is

    writeln("nbkids = ", ctKids.LB);​


    What confused you is that I used nbKids both a the constant 300 and as the variable name in the loop.

    Let me make this better:

    int nbKids=300;
    {int} nbKidsOptions={nbKids+i*10 | i in -10..2};
    int x2[i in 1..card(nbKidsOptions)]=item(nbKidsOptions,i-1);
    int y2[i in 1..card(nbKidsOptions)];
    
    float costBus40=500;
    float costBus30=400;
     
    dvar int+ nbBus40;
    dvar int+ nbBus30;
     
    minimize
     costBus40*nbBus40  +nbBus30*costBus30;
     
    subject to
    {
     ctKids:40*nbBus40+nbBus30*30>=0;
    }
    
    execute
    {
    writeln("nbBus40 = ",nbBus40);
    writeln("nbBus30 = ",nbBus30);
    writeln("nbkids = ", ctKids.LB);
    }
    
    main
    {
    thisOplModel.generate();
    var k=1;
    for(var nbKidsIter in thisOplModel.nbKidsOptions)
    
    {
    writeln("if we need to bring ",nbKidsIter," kids  to the zoo");
        
    thisOplModel.ctKids.LB=nbKidsIter;
    
    cplex.solve();
    thisOplModel.postProcess();
    writeln("And the cost is ",cplex.getObjValue());
    thisOplModel.y2[k]=cplex.getObjValue();
    
    k++;
    writeln();
    }
    }
    
    





    ------------------------------
    [Alex] [Fleischer]
    [EMEA CPLEX Optimization Technical Sales]
    [IBM]
    ------------------------------



  • 5.  RE: Change a parameter and run the same model

    Posted 07/08/21 09:05 AM
    Thank you very much.

    ------------------------------
    Siamak Mushakhian
    ------------------------------