FRAMES NO FRAMES

Class IloNHoodModifierI

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

This abstract implementation class is used to describe a neighborhood structure that depends on other “child” neighborhood structures. Solver neighborhoods such as IloConcatenate, IloRandomize, and IloContinue belong to this category of neighborhood. Such neighborhoods do not generate neighbors in their own right, but pass back neighbors produced by their children. The main job of a neighborhood modifier is to maintain a mapping between the indices of neighbors for the neighborhood modifier and the corresponding child neighborhoods and indices within these child neighborhoods. The member function IloNHoodModifierI::mapIndex performs this maintenance. Additional behaviors can be added. One example is to manipulate normally produced deltas in some way, for instance by adding additional variables, before they are returned.

See Also:

Constructor and Destructor Summary
public IloNHoodModifierI(IloEnv env, IloNHoodArray a, const char * name=0)
public IloNHoodModifierI(IloEnv env, IloNHood nh, const char * name=0)
public IloNHoodModifierI(IloEnv env, IloNHood nh1, IloNHood nh2, const char * name=0)
Method Summary
public IloSolutiondefine(IloSolver solver, IloInt index)
public voiddisplay(ostream & out) const
public IloIntgetLocalIndex(IloSolver solver, IloInt index) const
public IloNHoodI *getLocalNHood(IloSolver solver, IloInt index) const
public IloNHoodgetNHood(IloInt i) const
public IloIntgetNHoodSize(IloInt i) const
public IloIntgetNumberOfNHoods() const
public IloIntgetSize(IloSolver solver) const
public virtual voidmapIndex(IloSolver solver, IloInt index, IloNHood & nhood, IloInt & offset) const
public voidnotify(IloSolver solver, IloInt index)
public voidnotifyOther(IloSolver solver, IloSolution delta)
public voidreset()
public voidstart(IloSolver solver, IloSolution solution)
Inherited Methods from IloNHoodI
define, display, getEnv, getLocalIndex, getLocalNHood, getName, getObject, getSize, notify, notifyOther, operator delete, reset, setName, setObject, start
Constructor and Destructor Detail

IloNHoodModifierI

public IloNHoodModifierI(IloEnv env, IloNHoodArray a, const char * name=0)

This constructor builds a neighborhood modifier that combines all neighborhoods in the array a. The optional argument name, if provided, becomes the name of the neighborhood.


IloNHoodModifierI

public IloNHoodModifierI(IloEnv env, IloNHood nh, const char * name=0)

This constructor builds a neighborhood modifier that depends on just one neighborhood nh. The optional argument name, if provided, becomes the name of the neighborhood.


IloNHoodModifierI

public IloNHoodModifierI(IloEnv env, IloNHood nh1, IloNHood nh2, const char * name=0)

This constructor builds a neighborhood modifier that depends on two neighborhoods, nh1 and nh2. The optional argument name, if provided, becomes the name of the neighborhood.


Method Detail

define

public IloSolution define(IloSolver solver, IloInt index)

This member function calls IloNHoodModifierI::define on one of its child neighborhoods with an appropriately adjusted index. The computation of the child neighborhood and adjusted index are performed by the IloNHoodModifierI::mapIndex member function. If you wish define to have some additional behavior, you can redefine this function. In this case, you must still call IloNHoodModifierI::define(solver, index) in your subclass and return the delta delivered (or a modified version of it).


display

public void display(ostream & out) 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.


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. To do this, it uses the member function IloNHoodModifierI::mapIndex.


getLocalNHood

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

This member function returns the atomic neighborhood responsible for defining the neighbor indexed index. To do this, it uses the member function IloNHoodModifierI::mapIndex.


getNHood

public IloNHood getNHood(IloInt i) const

This member function delivers the ith neighborhood specified at construction time. If you constructed the neighborhood modifier with an array, this member function returns the ith element of that array. If you constructed the neighborhood modifier with two neighborhoods, getNHood(0) returns nhood0 and getNHood(1) returns nhood1. Finally, if you constructed the neighborhood modifier with only one neighborhood, getNHood(0) returns that neighborhood.


getNHoodSize

public IloInt getNHoodSize(IloInt i) const

This member function returns the size of the ith neighborhood specified at construction time. The indexing rules for neighborhoods are the same as those described in the description for the member function getNHood. Although this member function is functionally equivalent to getNHood(i).getSize(solver) (given an instance of IloSolversolver), it can be faster as the size is cached in the neighborhood modifier and not recomputed from the child neighborhood.


getNumberOfNHoods

public IloInt getNumberOfNHoods() const

This member function returns the number of neighborhoods specified at construction time. The value returned is one greater than the legal maximum value with which you can call IloNHoodModifierI::getNHood or IloNHoodModifierI::getNHoodSize.


getSize

public IloInt getSize(IloSolver solver) const

This member function returns the sum of the sizes of the child neighborhoods. You may redefine this behavior if desired.


mapIndex

public virtual void mapIndex(IloSolver solver, IloInt index, IloNHood & nhood, IloInt & offset) const

This member function maintains a mapping between the indices of neighbors for the neighborhood modifier and the corresponding child neighborhoods and indices within these child neighborhoods. You should thus redefine this member function to convert the index index to a neighborhood nhood and an index offset within that neighborhood. nhood and offset are passed by reference so that you can fill in the details. solver is the active solver. An example of how to do this for a modifier which concatenates two neighborhoods is shown in the IBM ILOG Solver User's Manual.


notify

public void notify(IloSolver solver, IloInt index)

This member function calls IloNHoodModifierI::notify on one of its child neighborhoods with an appropriately adjusted index. The computation of the child neighborhood and adjusted index are performed by the IloNHoodModifierI::mapIndex member function. For all other child neighborhoods, IloNHoodModifierI::notifyOther is called. If you wish notify to have some additional behavior, you can redefine this function. In this case, you must still call IloNHoodModifierI::notify(solver, index) in your subclass.


notifyOther

public void notifyOther(IloSolver solver, IloSolution delta)

This member function calls notifyOther on all child neighborhoods. If you wish notifyOther to have some additional behavior, you can redefine this function. In this case, you must still call IloNHoodModifierI::notifyOther(solver, delta) in your subclass.


reset

public void reset()

This member function calls IloNHoodModifierI::reset on all child neighborhoods.


start

public void start(IloSolver solver, IloSolution solution)

This member function calls start on all child neighborhoods passing the parameters it receives. It then calls getSize on all child neighborhoods and caches the values returned. These sizes can be later retrieved by getNHoodSize. If you wish start to have some additional behavior, you can redefine this function. In this case, you must still call IloNHoodModifierI::start(solver, solution) in your subclass.