Decision Optimization

Decision Optimization

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

 View Only
  • 1.  multi-objective with Flow control script

    Posted Fri October 23, 2020 07:51 AM
    Edited by System Admin Fri January 20, 2023 04:09 PM
    I am solving a multi-objective problem with a lexicographic objective. I try to access the solution and print it out in an organized way to an excel file.
    The printed solution shows only the first objective function and the second is not printed to the output .txt file. 
    here is my main script:
    main {
    thisOplModel.convertAllIntVars();
    var source = new IloOplModelSource("TAS-CRP_Full.mod"); //load the model
    var cplex = new IloCplex();
    var def = new IloOplModelDefinition(source);
    var opl = new IloOplModel(def,cplex);
    var data=new IloOplDataSource("D:/TAS-CRP INSTANCES/6 x 4/Low/Full_Low_2.dat")
    var opl = new IloOplModel(def,cplex);
    opl.addDataSource(data);
    opl.generate();
    cplex.TiLim=3600;
    cplex.solve();
    var time=cplex.getSolvedTime();
    var ofile = new IloOplOutputFile("TAS-CRP_main.txt");
    if (cplex.solve()){
    //ofile.writeln (" Obj ", cplex.getObjValue()," Time ",time );
    ofile.writeln (opl.printSolution());
    }
    else {ofile.writeln(" Obj ", "Infeasible"," Time ",time);}
    opl.end();
    data.end();
    def.end();
    source.end();
    }

    Thanks In advance


    ------------------------------
    Ahmed Azab
    ------------------------------

    #DecisionOptimization


  • 2.  RE: multi-objective with Flow control script
    Best Answer

    Posted Sat October 24, 2020 10:49 AM
    Edited by System Admin Fri January 20, 2023 04:24 PM
    Hi,

    with writeln or SheetWrite you can write the 2nd KPI as can be seen at

    https://github.com/AlexFleischerParis/zooopl/blob/master/zoomultiobjective.mod

    that you can also rewrite with a main block:

    int nbKids=200;
    float costBus40=500;
    float costBus30=400;
    float costBus50=625;

    dvar int+ nbBus40;
    dvar int+ nbBus30;
    dvar int+ nbBus50;

    dvar float cost;
    dvar float co2emission;

    minimize
    staticLex(cost,co2emission);

    subject to
    {
    cost==costBus40*nbBus40 +nbBus30*costBus30+nbBus50*costBus50;
    co2emission==nbBus50+nbBus40*1.1+nbBus30*1.2;

    40*nbBus40+nbBus30*30+nbBus50*50>=nbKids;
    }

    execute DISPLAY_After_SOLVE
    {
    writeln("The minimum cost is ",cost);
    writeln("CO2 emission is ",co2emission);
    writeln("We will use ",nbBus40," 40 seats buses ",nbBus30,
    " 30 seats buses and ", nbBus50," buses 50 seats");
    }

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

    regards

    ------------------------------
    ALEX FLEISCHER
    ------------------------------



  • 3.  RE: multi-objective with Flow control script

    Posted Sun October 25, 2020 11:10 AM
    Thanks, ALEX, This worked as I needed.

    ------------------------------
    Ahmed Azab
    ------------------------------