Originally posted by: SystemAdmin
Hi guys,
I am counting on CPLEX concert technology to solve an optimization problem that replays itself multiple times. It worked fine solving the first optimization prob, but got stuck at the model extraction step in the second one. No idea where the problem is. Am fairly new to cplex stuff. I attached the main structure of the code as follows:
for(
long
int t = 0; t < 8640; t++)
{ IloEnv env; IloModel model(env,
"resalloc"); ... IloIntVarArray n[APP_NUM]; IloIntVarArray fl[APP_NUM];
//Define two-dimensional variables ...
//Define the optimization objective IloExpr obj_expr(env); ... IloObjective obj(env, obj_expr, IloObjective::Minimize); model.add(obj);
//Define constraints IloRangeArray range[10];
for(
int i = 0; i < 10; i++)
{ range[i] = IloRangeArray(env, application[i].hosting_server_num);
for(
int j = 0; j < application[i].hosting_server_num; j++)
{ ...
//define upper bound and lower bound range[i][j] = IloRange(env, lower_bound, FREQ_LVL_PER_CPU*(n[i][j]-1) + fl[i][j], upper_bound,
"range");
} model.add(range[i]);
} IloCplex cplex(env); cplex.extract(model);
//*this is where the error prompts up in the second loop when t = 1;*
try
{ cplex.solve(); ....
}
catch (IloException& e)
{ std::cerr <<
"IloException: " << e << std::endl;
}
catch (std::exception& e)
{ std::cerr <<
"Standard exception: " << e.what() << std::endl;
} env.end();
//*this is where the whole modeling environment is ended.*
}
I was hoping that in each loop, there's a completely new opt. problem to solve. Doesn't env.end() accomplish this? How come the problem is solved fine in the first loop when t takes the value, but stuck at the model extraction step when t = 1?? confused...
Thanks for your help in advance!;)
#CPLEXOptimizers#DecisionOptimization