Originally posted by: SystemAdmin
>
> Thanks for your help, Dan. I've tried the code, but with those "for" loops commented out in the first two "catch" blocks, because my model would have about 100,000 constraints by the time the error came out. Also, I'm sure that the constraints added are simply linear constraints with 0,1 coefficients.
>
The for-loops would have only printed the constraint(s) that triggered the exception. They should not have printed all 100000 constraints.
> As I tested the same code on different machines, I noticed that the error showed randomly, but with the following pattern:
> Error "cannot change extractables" happens when adding constraints;
> Error "cannot extract extractables" happens at the step of "cplex(model)";
> And in some recent tests, a third error: cplex out of memory happens when cplex is actually solving the model.
>
> When the three errors happened, the application had pretty much consumed all the memory of the system. So I guess all these errors are due to out of memory.
>
OK, so the "cannot change" or "cannot extract" might be "out of memory" in disguise.
> As mentioned before, by the time the error came out, the LP model has about 100,000 constraints. However, this size is said to take about 100MB for cplex to solve, according to the "Guidelines for estimating CPLEX memory requirements based on problem size". I'm confused why it took almost all the memory. Basically, in my code there are two main problems to solve, master problem and subproblem. The master problem is solved by CPLEX, the subproblem is solved by a label setting algorithm coded myself. The most memory consuming part of the label setting algorithm is a list that dynamically stores all the labels, typically 2,0000 to 4,0000 labels with each taking about 6 bytes, which are all released when subproblem finished. And for the first couple of iterations, I did notice the memory decrease when those labels are freed. The model.add() and cplex(model) were always causing an increase of memory usage shown on the monitor. After a while, the memory kept increasing monotonically, never showed any decrease even at the point where label releasing was carried out.
>
This smells like a memory leak. You are solving the subproblem in a callback, right? Are you sure you properly release all memory before you return from the callback? In particular all Ilo*Array instances you allocated in the callback.
> Since I'm a beginner user of both C++ and CPLEX, I'm totally confused by those information. Hope those details above could provide clues for experts. If there is a need of my code, I'm more than willing to provide.
>
Could you post the callback code here? Assuming that the algorithm you use for the subproblem has no leaks the problem must be within the callback code.
#CPLEXOptimizers#DecisionOptimization