FRAMES NO FRAMES

Class IloNHood

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

This handle class is used to define neighborhood structures 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.

Protocol

The protocol for driving an object of type IloNHood is as follows:

For more information, see IloSolution in the IBM ILOG Concert Technology Reference Manual.

See Also:

Constructor Summary
public IloNHood()
public IloNHood(IloNHoodI * impl)
public IloNHood(const IloNHood & nhood)
Method Summary
public IloSolutiondefine(IloSolver solver, IloInt index)
public voidend(IloBool deep=IloTrue)
public IloEnvgetEnv() const
public IloNHoodI *getImpl() const
public IloIntgetLocalIndex(IloSolver solver, IloInt index) const
public IloNHoodgetLocalNHood(IloSolver solver, IloInt index) const
public const char *getName() const
public IloAnygetObject() const
public IloIntgetSize(IloSolver solver) const
public voidnotify(IloSolver solver, IloInt index) const
public voidnotifyOther(IloSolver solver, IloSolution delta) const
public voidoperator=(const IloNHood & nhood)
public voidreset()
public voidsetName(const char * name) const
public voidsetObject(IloAny obj) const
public voidstart(IloSolver solver, IloSolution current) const
Constructor Detail

IloNHood

public IloNHood()

This constructor creates a neighborhood whose implementation pointer is 0 (zero). The handle must be assigned before its methods can be used.


IloNHood

public IloNHood(IloNHoodI * impl)

This constructor creates a handle object (an instance of the class IloNHood) from a pointer to an implementation object (an instance of the class IloNHoodI).


IloNHood

public IloNHood(const IloNHood & nhood)

This constructor creates a handle object from a reference to a neighborhood. After execution, both the newly constructed handle object and nhood point to the same implementation object.


Method Detail

define

public IloSolution define(IloSolver solver, IloInt index)

This member function returns the change in the current solution to be made when making move index in the neighborhood. The neighbors are numbered from 0. If an empty handle is returned, no change is defined for this index.

The argument solver indicates the solver that is scanning the invoking neighborhood. (See IloScanNHood.)


end

public void end(IloBool deep=IloTrue)

This member function calls delete on the implementation object associated with the invoking handle and sets the implementation pointer to 0. If the invoking neighborhood has any children (for instance, if it were constructed using a + operator) then these too will be likewise deleted. If, however, deep has the value IloFalse, then the children are “disconnected” from the parent before delete is called on the implementation pointer to ensure that the children of the invoking neighborhood are not destroyed.


getEnv

public IloEnv getEnv() const

This member function returns the environment associated with the implementation class.


getImpl

public IloNHoodI * getImpl() const

This member function returns the implementation object of the invoking handle. You can use this member function to check whether a neighborhood is empty.


getLocalIndex

public IloInt getLocalIndex(IloSolver solver, IloInt index) const

This member function converts the index index to the index in the atomic neighborhood responsible for defining neighbor index. This member function is useful for finding the index in the neighborhood that defined a neighbor when the invoking neighborhood is made up of neighborhoods combined via concatenation (operator operator+ or IloConcatenate). It is also useful when the invoking neighborhood has been modified (for instance via IloRandomize). In typical usage, the index passed originates from an instance of IloNeighborIdentifier.


getLocalNHood

public IloNHood getLocalNHood(IloSolver solver, IloInt index) const

This member function returns the atomic neighborhood responsible for defining the neighbor indexed index. This member function is useful for finding the exact neighborhood that defined a neighbor when the invoking neighborhood is made up of neighborhoods combined via (operator+ or IloConcatenate). In typical usage, the index passed originates from an instance of IloNeighborIdentifier.


getName

public const char * getName() const

This member function returns a character string specifying the name of the invoking object (if there is one).


getObject

public IloAny getObject() const

This member function returns the object associated with the invoking object (if there is one). Normally, an associated object contains user data pertinent to the invoking object.


getSize

public IloInt getSize(IloSolver solver) const

This member function returns the “size” of the neighborhood, that is, one more than the maximum index that IloNHood::define can legally be called with. The argument solver indicates the solver that is scanning the invoking neighborhood. (See IloScanNHood.)


notify

public void notify(IloSolver solver, IloInt index) const

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. The argument solver indicates the solver that is scanning the invoking neighborhood. (See IloScanNHood.)

At the point of calling, the constrained variables corresponding to the solution passed to IloNHood::start should be instantiated, but not yet been saved to the current solution. This allows inspection of the differences. Default behavior is to do nothing.


notifyOther

public void notifyOther(IloSolver solver, IloSolution delta) const

This member function is a counterpart to IloNHood::notify. When neighborhoods are joined with operator+ or IloConcatenate, only one basic neighborhood can have IloNHood::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=

public void operator=(const IloNHood & nhood)

This assignment operator copies nhood into the invoking neighborhood by assigning an address to the handle pointer of the invoking object. That address is the location of the implementation object of the argument nhood.


reset

public void reset()

This member function resets the neighborhood to the state in which it was first created. For neighborhoods which have no state, calling this member function has no effect. An example of a neighborhood with state is IloContinue which, after each move, adjusts neighborhood indices to ensure that new indices are explored. When neighborhoods have state, you will typically want to call this member function between two different local searches if the neighborhood is to be reused. Most of Solver's neighborhoods are stateless.


setName

public void setName(const char * name) const

This member function assigns name to the invoking object.


setObject

public void setObject(IloAny obj) const

This member function associates obj with the invoking object. The member function getObject accesses this associated object afterward. Normally, obj contains user data pertinent to the invoking object.


start

public void start(IloSolver solver, IloSolution current) const

This member function announces to the neighborhood that neighbors will be requested of it (through IloNHood::define), and that current is the reference point of these changes. That is, all changes specified afterwards via calls to IloNHood::define (until start is called again) should relate to changes of current.

The argument solver indicates the solver that is scanning the invoking neighborhood. (See IloScanNHood.)