Overview | Group | Tree | Graph | Index | Concepts |
This abstract implementation class is used to describe a neighborhood structure that can be used by local search procedures. The central idea of the neighborhood is to define a set of solution changes, or deltas, that represent alternative moves that can be taken.
You can subclass the IloNHoodI
class to define your own
neighborhoods.
The member functions IloNHoodI::start
,
IloNHoodI::define
, IloNHoodI::getSize
, IloNHoodI::notify
, and
IloNHoodI::notifyOther
are called within search, and
the solver calling these is passed as the first parameter of these member
functions. Solver automatically deletes any deltas you return from the
define
method. Therefore, you do not need to handle the memory
management of these deltas. However, this also means that you should not
make any further reference to a delta that has been returned from the
define
.
For more information, see IloSolution
in the
IBM ILOG Concert Technology Reference Manual.
See Also:
IloNHood, IloScanDeltas, IloScanNHood
Constructor and Destructor Summary | |
---|---|
public | IloNHoodI(IloEnv env, const char * name=0) |
public | ~IloNHoodI() |
Method Summary | |
---|---|
public virtual IloSolution | define(IloSolver solver, IloInt index) |
public virtual void | display(ostream & stream) const |
public IloEnv | getEnv() const |
public virtual IloInt | getLocalIndex(IloSolver solver, IloInt index) const |
public virtual IloNHoodI * | getLocalNHood(IloSolver solver, IloInt index) const |
public char * | getName() const |
public IloAny | getObject() |
public virtual IloInt | getSize(IloSolver solver) const |
public virtual void | notify(IloSolver solver, IloInt index) |
public virtual void | notifyOther(IloSolver solver, IloSolution solution) |
public void | operator delete(void * p, size_t size) |
public virtual void | reset() |
public void | setName(const char * name) |
public void | setObject(IloAny object) |
public virtual void | start(IloSolver solver, IloSolution currentSolution) |
Constructor and Destructor Detail |
---|
This constructor creates a neighborhood. The optional argument
name
, if supplied, becomes the name of the neighborhood.
Since IloNHoodI
is an abstract class, a virtual destructor
is provided.
Method Detail |
---|
This virtual member function should return the change in the current
solution to be made when making move number index
in the
neighborhood. The neighbors are numbered from 0.
This virtual member function displays the name of the neighborhood,
if named. Otherwise, it prints "IloNHoodI
", followed by the
address of the invoking object in brackets.
This member function returns the environment which was passed in the constructor.
This member function should convert the index index
to
the index in the atomic neighborhood responsible for defining neighbor
index
. If you define a neighborhood that is a combination
of other neighborhoods, you should define this member function to produce
the correct index. By default, this member function returns
index
.
This member function should return the atomic neighborhood responsible
for defining the neighbor indexed index
. If you define a
neighborhood that is a combination of other neighborhoods, you should
define this member function to produce the correct atomic neighborhood.
By default, this member function returns the invoking neighborhood.
This member function returns the name specified in the constructor of
the object, or specified in the last call to
setName
.
This member function returns the object associated with the
invoking neighborhood through the IloNHoodI::setObject
method.
This pure virtual member function should return the “size”
of the neighborhood, that is, one more than the maximum index that
define
can be legally called with.
This member function is called when a neighborhood move is about to
be taken. It is called with index
equal to the index
of the neighbor currently being accepted by local search. If you
are using IloSingleMove
, then at the
point of calling the constrained variables are instantiated, but not
yet saved in the current solution. This permits inspection of
differences between the current solution and the one about to be
accepted. The default behavior of this member function is to do
nothing.
This member function is a counterpart to
IloNHoodI::notify
. When neighborhoods are joined
with operator+
or
IloConcatenate
, only one basic neighborhood
can have IloNHoodI::notify
called:
the one that defined the delta for the
move to be taken. For all other basic neighborhoods,
notifyOther
is called with the delta for the move to be
taken.
The argument solver indicates the solver that is scanning the invoking
neighborhood. (See IloScanNHood
.)
This operator deletes the memory for the neighborhood pointed to by
p
as if its memory was allocated using the environment
handed to the neighborhood when it was created.
If you want to allocate your neighborhoods on a different heap when subclassing, you should redefine this operator in the subclass to perform the delete operation appropriate to your heap.
If your neighborhood has state which it carries from move to move, you should define this member function to reset the neighborhood to the state in which it was first created.
This member function sets the name of the invoking object to
a copy of name
.
This member function associates object object
with
the invoking neighborhood.
This pure virtual member function announces to the neighborhood
that neighbors that neighbors will be requested of it (through
IloNHoodI::define
) and that
currentSolution
is the reference point of these
changes. That is, all changes specified afterwards via calls
IloNHoodI::define
) (until start
is called again) should related to changes of
currentSolution
.