FRAMES NO FRAMES

Class IloMetaHeuristicI

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

This implementation class comprises methods that allow you to define your own a metaheuristic which can then be used within local search procedures. When you define a metaheuristic, you define a filtering of the set of possible moves that can be taken, and thus can provide search guidance.

The member functions IloMetaHeuristicI::isFeasible, IloMetaHeuristicI::notify, IloMetaHeuristicI::start, and IloMetaHeuristicI::test are called within search, and the solver calling these is passed as the first parameter of these member functions.

See Also:

Constructor and Destructor Summary
public IloMetaHeuristicI(IloEnv env, const char * name=0)
public ~IloMetaHeuristicI()
Method Summary
public virtual IloBoolcomplete()
public IloSolutionDeltaCheckgetDeltaCheck() const
public char *getName() const
public IloAnygetObject()
public virtual IloBoolisFeasible(IloSolver solver, IloSolution delta) const
public virtual voidnotify(IloSolver solver, IloSolution delta)
public voidoperator delete(void * p, size_t size)
public virtual voidreset()
public voidsetName(const char * name)
public voidsetObject(IloAny object)
public virtual IloBoolstart(IloSolver solver, IloSolution solution)
public virtual IloBooltest(IloSolver solver, IloSolution delta)
Constructor and Destructor Detail

IloMetaHeuristicI

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

This constructor creates an instance of IloMetaHeuristicI associated with the environment env. The optional parameter name, if supplied, becomes the name of the metaheuristic.


~IloMetaHeuristicI

public ~IloMetaHeuristicI()

Since IloMetaHeuristicI is an abstract class that can be sub-classed, a virtual destructor is provided.


Method Detail

complete

public virtual IloBool complete()

This member should be called by local search procedures 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 default behavior), the metaheuristic wants to end local search at this point.


getDeltaCheck

public IloSolutionDeltaCheck getDeltaCheck() const

Metaheuristics are capable of performing "pre-filtering" of solution deltas to be applied to a solution. This member function returns an object that performs the pre-filtering for the metaheuristic.

The implementation of the IloSolutionDeltaCheckI::ok method for this object is to call the IloMetaHeuristicI::isFeasible method in the invoking object with the proposed delta. Thus, the behavior of the delta check here is defined by the behavior of the IloMetaHeuristicI::isFeasible method.


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 IloMetaHeuristicI::setName.


getObject

public IloAny getObject()

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


isFeasible

public virtual 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 to that the delta is feasible.


notify

public virtual 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 default behavior is to do nothing.

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 information is not absolutely necessary, as variable changes can be worked out from an examination of the variables themselves. Thus, delta may be an empty handle, for example when this method is called from the IloNotify goal without the delta parameter. However, when IloSingleMove is used, delta always represents the delta of the move to be taken.

If delta is not empty, the information it contains can be used to accelerate the notification process for some metaheuristics or to hold additional information on the move.


operator delete

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

This operator deletes the memory for the metaheuristic pointed to by p as if its memory was allocated using the environment handed to the metaheuristic when it was created.

If you want to allocate your metaheuristics 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()

You should define this member function to reset the metaheuristic to the state in which it was first created, unless your metaheuristic does not have state which it carries from move to move. (All Solver metaheuristics have state except IloImprove.)


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


start

public virtual IloBool start(IloSolver solver, IloSolution solution)

This member function should be called when 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 virtual IloBool test(IloSolver solver, IloSolution delta)

This member function is the principal way in which the metaheuristic guides search by filtering neighbors.

This member function is called when all solution variables have been instantiated in local search, 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 information is not absolutely necessary, as variable changes can be worked out from an examination of the variables themselves. Thus, delta may be an empty handle, for example when this method is called from the IloTest goal without the delta parameter. However, when IloSingleMove is called, delta always represents the delta to be tested.

If delta is not empty, the information it contains can be used to accelerate the notification process for some metaheuristics or to hold additional information on the move.