FRAMES NO FRAMES

Class IloMetaHeuristic

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

This handle class comprises methods that describe a metaheuristic that can be used within local search procedures. The metaheuristic defines a filter for the set of possible moves that can be taken, and thus provides search guidance.

The exact choice of which legal move is to be taken is performed by search selectors (objects of type IloSearchSelector), not by the IloMetaHeuristic class.

Protocol

When used in a local search framework, metaheuristics should be called according to the following protocol:

IloSingleMove adheres to this protocol.

See Also:

Constructor Summary
public IloMetaHeuristic()
public IloMetaHeuristic(IloMetaHeuristicI * impl)
Method Summary
public IloBoolcomplete()
public voidend(IloBool deep=IloTrue)
public IloSolutionDeltaCheckgetDeltaCheck() const
public IloEnvgetEnv()
public IloMetaHeuristicI *getImpl() const
public const char *getName() const
public IloAnygetObject() const
public IloBoolisFeasible(IloSolver solver, IloSolution delta) const
public voidnotify(IloSolver solver, IloSolution delta)
public voidoperator=(const IloMetaHeuristic & mh)
public voidreset()
public voidsetName(const char * name) const
public voidsetObject(IloAny obj) const
public IloBoolstart(IloSolver solver, IloSolution solution)
public IloBooltest(IloSolver solver, IloSolution delta)
Constructor Detail

IloMetaHeuristic

public IloMetaHeuristic()

This constructor creates a metaheuristic whose handle pointer is null. This object must be assigned before it can be used.


IloMetaHeuristic

public IloMetaHeuristic(IloMetaHeuristicI * impl)

This constructor creates a handle object (an instance of IloMetaHeuristic) from a pointer to an implementation object (an instance of IloMetaHeuristicI).


Method Detail

complete

public IloBool complete()

This member function is normally called when the search has stagnated (typically when no neighborhood moves can be legally taken). This allows the metaheuristic to perform some action to allow the search to continue, if desired. If the return value is IloTrue, the metaheuristic wants to end local search at this point.


end

public void end(IloBool deep=IloTrue)

This member function calls operator delete from the class IloMetaHeuristicI on the implementation object associated with the invoking handle and sets the implementation pointer to 0. If the invoking metaheuristic 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 metaheuristic are not destroyed.


getDeltaCheck

public IloSolutionDeltaCheck getDeltaCheck() const

Meta-heuristics are capable of performing “prefiltering” of solution deltas to be applied to a solution.This member function returns an object that performs the pre-filtering for the metaheuristic. This object may be passed to IloScanNHood.


getEnv

public IloEnv getEnv()

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


getImpl

public IloMetaHeuristicI * getImpl() const

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


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.


isFeasible

public IloBool isFeasible(IloSolver solver, IloSolution delta) const

This member function is called by the ok() method of the object returned by IloMetaHeuristic::getDeltaCheck. That object is used in local search procedures to “pre-filter” some deltas before they are applied to the current solution.

The argument solver indicates the solver that is currently performing a local search using the invoking metaheuristic.

The user can define this member function to perform the pre-filtering desired. The default behavior is to return IloTrue, indicating that delta is feasible.


notify

public void notify(IloSolver solver, IloSolution delta)

Call this member function when a neighborhood move is to be taken by local search. At that point, all solution variables should be instantiated, but not yet saved, in the current solution, thus allowing differences to be calculated. This can be useful for updating metaheuristic data structures.

The argument solver indicates the solver that is currently performing a local search using the invoking metaheuristic.

The argument delta holds the solution delta of the move to be taken. This can be gleaned from the reference parameter atDelta passed to IloScanDeltas or IloScanNHood, and used in IloNotify. While this parameter can be used in custom metaheuristics, an empty handle can be passed to all of Solver's pre-defined metaheuristics, as it is not required by them.


operator=

public void operator=(const IloMetaHeuristic & mh)

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


reset

public void reset()

This member function resets the metaheuristic to the state in which it was first created. When metaheuristics have state, you will typically want to call this member function between two different local searches if the metaheuristic is to be reused. For metaheuristics which have no state, calling this member function has no effect. (All of Solver's metaheuristics have state except IloImprove.)


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 IloBool start(IloSolver solver, IloSolution solution)

Call this member function when a local search begins to search for a new move to take. The argument solver indicates the solver that is currently performing a local search using the invoking metaheuristic. The argument solution is the current solution. If it is illegal for the metaheuristic to start from this point, this member function returns IloFalse or causes a failure. Otherwise it returns IloTrue.


test

public IloBool test(IloSolver solver, IloSolution delta)

When all solution variables have been instantiated in local search, call this member function to determine whether the metaheuristic should allow or reject the solution. If the solution is rejected, this member function returns IloFalse or causes a failure. Otherwise it returns IloTrue.

The argument solver indicates the solver that is currently performing a local search using the invoking metaheuristic.

The argument delta holds the solution delta to test. This can be gleaned from the reference parameter atDelta passed to IloScanDeltas or IloScanNHood, and used in IloTest. While this parameter can be used in custom metaheuristics, an empty handle can be passed to all of Solver's pre-defined metaheuristics, as it is not required by them.