Originally posted by: ouaigooo
Hi,
I've got a dexpr in the objective function that I cannot access after solving.
When running the model file below (details ommitted), OPL crashes when invoking "writeln("profit_scenario: ", profit_scenario);", with the following error
OPL cannot extract expression: profit_scenario
How come ?
Has it something to do with model simplifications that CPLEX performs before solving ? Can we switch them off ?
Thanks for your help !
model file:
...
{string} MARKET_NAMES =
({x.name | x in PRICES_MAPPING} inter {x.name | x in PRICE_PEX})
union
({x.name | x in PRICES_MAPPING_RES} inter {x.name | x in PRICE_RES});
dexpr float profit_market[y in MARKET_NAMES, i in SCENARII] =
sum(x in PRICE_PEX: x.name==y) x.value*power_PEX[i,x]*item(PRICES_MAPPING,<x.name>).sign*(x.stop-x.start)/3600
+ ((WITH_RES==0) ? 0 : sum(x in PRICE_RES: x.name==y) x.value*power_RES[i,x]);
{string} OBJ_FCT_COMPONENTS = MARKET_NAMES union
{"network","storage","building","min/max on/off","forced","legio","final"};
dexpr float obj_fct_components[y in OBJ_FCT_COMPONENTS][i in SCENARII] =
(y == "network") ? sum(x in NETWORK_COSTS) network_cost[i,x] :
(y == "storage") ? -sum(x in STORAGES) penalty_storage[x,i] :
(y == "building") ? -sum(x in BUILDINGS) penalty_building[x,i] :
(y == "min/max on/off") ? -sum(x in PMMOO_SOFT) penalty_PMMOO[x,i] :
(y == "forced") ? -penalty_forced_schedule :
(y == "legio") ? -sum(x in BOILERS_legio) penalty_legio[x,i] :
(y == "final") ? value_final_state[i] :
(y == "legio") ? sum(x in NETWORK_COSTS) network_cost[i,x] :
(y in MARKET_NAMES) ? profit_market[y,i] :
0;
dexpr float profit_scenario[i in SCENARII] = sum(x in OBJ_FCT_COMPONENTS) obj_fct_components[x,i];
maximize sum(i in SCENARII) SCENARIO_WEIGHT[i]*profit_scenario[i];
subject to { ... }
float ps[i in SCENARII] = 0;
execute {
for (var i in SCENARII) for (var x in OBJ_FCT_COMPONENTS) ps[i] += obj_fct_components[x][i];
writeln("obj_fct_components: ", obj_fct_components);
writeln("ps: ", ps);
writeln("profit_scenario: ", profit_scenario);
}
#DecisionOptimization#OPLusingCPLEXOptimizer