Originally posted by: AlpD
Thank you very much. Regarding your answer, I noticed an expression term (expr) of another Cplex instance (Cplex_obj_1) that I use in the loop. I give the outline of the code below:
Cplex Cplex_obj_1= new Cplex(); //first Cplex instance
INumExpr expr = Cplex_obj_1.NumExpr(); // expression of first Cplex instance
for(…) //for loop to solve each LP subproblem
{
Cplex Cplex_obj_2= new Cplex(); //second Cplex instance
: //model construction
:
Cplex_obj_2.Solve();
Cplex.Status status = Cplex_obj_2.GetStatus();
if (status == Cplex.Status.Optimal)
{
for(…) for loop for i indice
{
expr = Cplex_obj_2.Sum(expr, Cplex_obj_2.Prod(x[i],y)); //adding new expression terms to 'expr'
}
} //end if
Cplex_obj_2.End();
}
I think the critical point is adding on to 'expr' in the loop, because when I removed these lines from the code, memory did not leak. However, I need to sum up
expressions in each iteration (for loop iteration for each LP subproblem) and then use this 'expr' to create a cut for the master problem.
Could you help me, how can i do this task without a memory leak? Thank you in advance.
Alper.
#CPLEXOptimizers#DecisionOptimization