Hi,
with writeln or SheetWrite you can write the 2nd KPI as can be seen at
https://github.com/AlexFleischerParis/zooopl/blob/master/zoomultiobjective.modthat 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
------------------------------
Original Message:
Sent: Fri October 23, 2020 07:50 AM
From: Ahmed Azab
Subject: multi-objective with Flow control script
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