Originally posted by: SystemAdmin
hi:
I need call cplex12.3 in C++ to solve a LP problem repeatedly in a loop. First all is OK. But after about 1 hour, an error occurs.
error: cplex error 12: unknown error code.
what this problem caused by? beacese of memory leak? Part of program in the loop like this. Is it leak the memory in somewhere? thank you.
IloEnv env;
IloModel model(env);
IloNumVarArray x(env, x_length, 0, 1);
IloNumVarArray z(env, z_length, 0, 1);
IloNumVarArray w(env, w_length, 0, IloInfinity);
try {
model.add(IloMinimize(env, IloSum(x)
));
for(i = 0; i < z_length; i++) {
nc=fdcc(i);
dc=*(nc+LC);
IloExpr v1(env);
for(j=0;j<dc;j++)
{
v1+=x
*(nc+j);
}
model.add(v1 == 2*w[i]+z[i]);
v1.end();
}
for(i = 0; i < x_length; i++) {
nv=fdvv(i);
dv=*(nv+LE);
IloExpr v2(env);
for(j=0;j<dv;j++)
{
v2+=z
*(nv+j);
}
model.add(v2 <=floor(double(dv/2)));
v2.end();
}
model.add(IloSum(x) >= 1);
model.add(IloSum(z) <=tmax);
IloCplex cplex(env);
cplex.extract(model);
cplex.solve();
cout << "Obj " << cplex.getObjValue() << endl;
cplex.end();
cout << endl;
cout << "----------------------------------------" << endl;
}
catch (IloException& ex) {
cerr << "Error: " << ex << endl;
}
x.end();
w.end();
z.end();
model.end();
env.end();
#CPLEXOptimizers#DecisionOptimization