FRAMES NO FRAMES

Class IloNHoodI

Definition file: ilsolver/iimnhood.h
Include file: <ilsolver/iimls.h>

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:

Constructor and Destructor Summary
public IloNHoodI(IloEnv env, const char * name=0)
public ~IloNHoodI()
Method Summary
public virtual IloSolutiondefine(IloSolver solver, IloInt index)
public virtual voiddisplay(ostream & stream) const
public IloEnvgetEnv() const
public virtual IloIntgetLocalIndex(IloSolver solver, IloInt index) const
public virtual IloNHoodI *getLocalNHood(IloSolver solver, IloInt index) const
public char *getName() const
public IloAnygetObject()
public virtual IloIntgetSize(IloSolver solver) const
public virtual voidnotify(IloSolver solver, IloInt index)
public virtual voidnotifyOther(IloSolver solver, IloSolution solution)
public voidoperator delete(void * p, size_t size)
public virtual voidreset()
public voidsetName(const char * name)
public voidsetObject(IloAny object)
public virtual voidstart(IloSolver solver, IloSolution currentSolution)
Constructor and Destructor Detail

IloNHoodI

public IloNHoodI(IloEnv env, const char * name=0)

This constructor creates a neighborhood. The optional argument name, if supplied, becomes the name of the neighborhood.


~IloNHoodI

public ~IloNHoodI()

Since IloNHoodI is an abstract class, a virtual destructor is provided.


Method Detail

define

public virtual IloSolution define(IloSolver solver, IloInt index)

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.


display

public virtual void display(ostream & stream) const

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.


getEnv

public IloEnv getEnv() const

This member function returns the environment which was passed in the constructor.


getLocalIndex

public virtual IloInt getLocalIndex(IloSolver solver, IloInt index) const

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.


getLocalNHood

public virtual IloNHoodI * getLocalNHood(IloSolver solver, IloInt index) const

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.


getName

public char * getName() const

This member function returns the name specified in the constructor of the object, or specified in the last call to setName.


getObject

public IloAny getObject()

This member function returns the object associated with the invoking neighborhood through the IloNHoodI::setObject method.


getSize

public virtual IloInt getSize(IloSolver solver) const

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.


notify

public virtual void notify(IloSolver solver, IloInt index)

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.


notifyOther

public virtual void notifyOther(IloSolver solver, IloSolution solution)

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.)


operator delete

public void operator delete(void * p, size_t size)

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.


reset

public virtual void reset()

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.


setName

public void setName(const char * name)

This member function sets the name of the invoking object to a copy of name.


setObject

public void setObject(IloAny object)

This member function associates object object with the invoking neighborhood.


start

public virtual void start(IloSolver solver, IloSolution currentSolution)

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.