Download ILOG CPLEX 11.0 User's Manual

Transcript
When ILOG CPLEX processes one of the subnodes that have been created by the Or goal, it
will pop and execute the first goal from the node's goal stack. As you just saw, this will be a
local cut goal. Thus ILOG CPLEX adds the constraint to the node problem and re-solves the
relaxation. Next, this will be popped from the goal stack and executed. This means that the
same search strategy as implemented in the original goal is applied at that node.
Memory Management and Goals
Java and .NET use garbage collection to handle all memory management issues. Thus the
following applies only to the C++ library. Java or .NET users may safely skip ahead to Cuts
and Goals on page 437.
To conserve memory, in the C++ API, ILOG CPLEX only stores active nodes of the tree and
deletes nodes as soon as they become inactive. When deleting nodes, ILOG CPLEX also
deletes the goal stacks associated with them, including all goals they may still contain. In
other words, ILOG CPLEX takes over memory management for goals.
It does so by keeping track of how many references to every goal are in use. As soon as this
number drops to zero (0), the goal is automatically deleted. This technique is known as
reference counting.
ILOG CPLEX implements reference counting in the handle class IloCplex::Goal. Every
IloCplex::GoalI object maintains a count of how many IloCplex::Goal handle
objects refer to it. The assignment operator, the constructors, and the destructor of class
IloCplex::Goal are implemented in such a way as to keep the reference count up-to-date.
This means that users should always access goals through handle objects, rather than
keeping their own pointers to implementation objects.
Other than that, nothing special needs to be observed when dealing with goals. In particular,
goals don't have end methods like other handle classes in the C++ API of ILOG Concert
Technology. Instead, ILOG CPLEX goal objects are automatically deleted when no more
references to them exist.
Local cut goals contain IloRange objects. Since the IloRange object is only applied when
the goal is executed, method end must not be called for a range constraint from which a
local cut goal is built. The goal will take over memory management for the constraints and
call method end when the goal itself is destroyed. Also, an IloRange object can only be
used in exactly one local cut goal. Similarly, method end must not be called for
IloRangeArray objects that are passed to local cut goals. Also such arrays must not
contain duplicate elements.
Going back to example ilogoalex1.cpp, you see that the method end is called for the
temporary arrays x, obj, and feas at the end of the execute method. Though a bit hidden,
two IloRange constraints are constructed for the goal, corresponding to the arguments of
the Or goal. ILOG CPLEX takes over memory management for these two constraints as
436
ILOG CPLEX 11.0 — USER’S MANUAL