Originally posted by: EdKlotz
>
> Using Concert C++ 12.2 and trying to limit the amount of memory used for NodeData objects, the following happens:
>
> When using a CMyNodeData object, where CMyNodeData is a subclass of NodeData, that has some stack-allocated data members, an optimization run of one problem instance uses at most x MB of main memory.
>
> When changing the CMyNodeData object and allocating the data members on the heap with operator new and
not implementing the destructor to free the allocated memory, the same amount of x MB of main memory is used according to the Windows task manager.
>
> When implementing the destructor ~CMyNodeData and calling operator delete there, still the same amount of main memory is used.
>
> The destructor is actually called quite often during the optimization run, and not only at the end.
>
> According to the Cplex node log output to the console, the number of open, that is, remaining nodes, is always low (less than 100). Thus, one would expect that stack allocation and new with delete require only a comparatively small amount of memory, that this amount of memory remains more or less constant in the course of the optimization, and that the case of new without delete occupies more and more memory in the course of the optimization. What could be the reason why this is not the case?
>
But does the number of nodes left actually influence the number of times
you allocate your node data object? I would expect it depends more on
the number of nodes created.
Unfortunately I don't really have any answers to the above questions, but I
have a couple of suggestions for tests you can try that might shed more light
on the issue.
1. If the new NodeData allocations really do depend on the number of
nodes left rather than created, then try a model that generates a large number
of nodes left and see what happens. If you don't have a model of your own
that does that, you can find plenty on the MIPLIB 2010 web site that do
(e.g. liu.mps).
2. Run Purify or some other memory checking tool to check for any memory
issues in the program.
>
> A further question:
>
> If the incumbent callback rejects a solution, what branching decision does Cplex take then?
>
> Using a branch callback, under which circumstances is it possible that getNbranches(), when called in the main() function of the branch callback, returns 0 (zero)?
If CPLEX finds an integer feasible solution at a node due to branching
and you reject it in your incumbent callback, then CPLEX has no branching
to perform and getNbranches will return 0. You need to use the makeBranch
function to do the branching, unless you are willing to let CPLEX prune the
node at that point. On the other hand, if CPLEX finds a feasible solution
from a node heuristic, CPLEX will still have fractional variables (or the
equivalent for other discrete objects such as indicator constraints) and can
proceed in the case where your incumbent callback rejects the solution.
I thought this would be the case if and only if there is also an incumbent callback and this incumbent callback rejected the solution at the respective node. However, in my code, this also happens when the incumbent callback has not been called for this node before.
>
> In particular, might there be a situation where getNbranches() returns zero even when there is still a fractional variable?
I don't think that can. You can check by calling the getFeasibilities method at the point you call getNbranches and see if any fractional variables exist.
#CPLEXOptimizers#DecisionOptimization