FRAMES NO FRAMES

Class IloEAOperatorFactory

Definition file: ilsolver/iimarrayops.h
Include file: <ilsolver/iim.h>
A factory for generating operators over arrays of variables.

This factory provides a set of parameters as well as functions that build operators based on these parameters.

Assuming that you have already created:

Then the following code creates two operators which operate on vars.

 IloEAOperatorFactory factory(env, vars);
 factory.setPrototype(prototype);
 factory.setSearchLimit(IloFailLimit(env, 100));
 IloPoolProc mut = factory.mutate(1.0 / vars.getSize(), "mutate");
 IloPoolProc xo  = factory.uniformXover(0.5, "uXover");
 
Note
Due to the backtracking abilities of available operators, it is often necessary to set a search limit to avoid lengthy searches.
Constructor Summary
public IloEAOperatorFactory(IloEAOperatorFactoryI * impl=0)

Initializes the handle.

public IloEAOperatorFactory(IloEnv env, IloIntVarArray scope)

Creates an operator factory.

public IloEAOperatorFactory(IloEnv env, IloBoolVarArray scope)

Creates an operator factory.

Method Summary
public IloEAOperatorFactoryI *getImpl() const

Returns the pointer to the implementation class.

public IloNumgetLeaveFactor() const

Returns the probability, for each variable, of being left unbound by created operators.

public IloPoolOperatormutate(IloNum mutationProb, const char * name=0) const

Creates a mutation operator.

public IloPoolOperatoronePointXover(const char * name=0) const

Creates a one-point crossover operator.

public IloPoolOperatorrandomize(const char * name=0) const

Creates a randomization operator.

public IloPoolOperatorrelax(const char * name=0) const

Creates a uniform relaxation operator.

public IloPoolOperatorrelaxSequence(IloNum breakProbability, const char * name=0) const

Relaxes random parts of the array.

public voidsetLeaveFactor(IloNum leaveFactor) const

Specifies the probability, for each variable, of being left unbound by created operators.

public IloPoolOperatorswap(const char * name=0) const

Creates a swap operator.

public IloPoolOperatortranslocate(const char * name=0) const

Creates a translocation operator.

public IloPoolOperatortranspose(const char * name=0) const

Creates a transposition operator.

public IloPoolOperatortwoPointXover(const char * name=0) const

Creates a two-point crossover operator.

public IloPoolOperatoruniformXover(const char * name=0) const

Creates a uniform crossover operator with crossover rate 0.5.

public IloPoolOperatoruniformXover(IloNum xoverRate, const char * name=0) const

Creates a uniform crossover operator.

Inherited Methods from IloPoolOperatorFactory
addAfterOperate, addBeforeOperate, addListener, end, getAfterOperate, getBeforeOperate, getEnv, getName, getObject, getPrototype, getSearchLimit, operator(), removeListener, setAfterOperate, setBeforeOperate, setName, setObject, setPrototype, setSearchLimit
Constructor Detail

IloEAOperatorFactory

public IloEAOperatorFactory(IloEAOperatorFactoryI * impl=0)
Initializes the handle.

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


IloEAOperatorFactory

public IloEAOperatorFactory(IloEnv env, IloIntVarArray scope)
Creates an operator factory.

This constructor creates an operator factory associated with the environment env which will produce operators on the array of integer variables scope.


IloEAOperatorFactory

public IloEAOperatorFactory(IloEnv env, IloBoolVarArray scope)
Creates an operator factory.

This constructor creates an array operator factory associated with the environment env which will produce operators on the array of Boolean variables scope.


Method Detail

getImpl

public IloEAOperatorFactoryI * getImpl() const
Returns the pointer to the implementation class.

This member function returns the implementation object of the invoking handle.


getLeaveFactor

public IloNum getLeaveFactor() const
Returns the probability, for each variable, of being left unbound by created operators.

This member function returns the probability, for each array cell, of being left unbound by created operators. It returns the probability set at the previous call to IloEAOperatorFactory::setLeaveFactor or to 0.0 if no probability was set.


mutate

public IloPoolOperator mutate(IloNum mutationProb, const char * name=0) const
Creates a mutation operator.

This operator selects one parent and produces a solution by inheriting its values. Each inherited value is mutated with a given mutation probability mutationProb. name, if provided becomes the name of the newly created operator.


onePointXover

public IloPoolOperator onePointXover(const char * name=0) const
Creates a one-point crossover operator.

This recombination operator selects two parents and produces a new solution by inheriting values from the second parent for array indices greater than a randomly chosen cut point. Other values are inherited from the first parent. name, if provided becomes the name of the newly created operator.


randomize

public IloPoolOperator randomize(const char * name=0) const
Creates a randomization operator.

This operator instantiates variables by choosing random values in their domain. name, if provided becomes the name of the newly created operator.


relax

public IloPoolOperator relax(const char * name=0) const
Creates a uniform relaxation operator.

This operator selects one parent and produces a new solution by leaving some variables unbound. The probability of leaving a variable unbound is given by the leaveFactor parameter of this factory. name, if provided becomes the name of the newly created operator.

See Also:


relaxSequence

public IloPoolOperator relaxSequence(IloNum breakProbability, const char * name=0) const
Relaxes random parts of the array.

This operator selects one parent and produces a new solution by copying the parent values with the exception of randomly chosen value sequences. The given probability breakProbability specifies, for each array site, the likelihood of starting (or ending) a relaxed sequence. name, if provided becomes the name of the newly created operator.


setLeaveFactor

public void setLeaveFactor(IloNum leaveFactor) const
Specifies the probability, for each variable, of being left unbound by created operators.

This member function specifies the probability leaveFactor, for each cell, of being left unbound by created operators.

Note
You must specify a completion goal (with the IloPoolOperatorFactory::setAfterOperate or IloPoolOperatorFactory::addAfterOperate methods) if the leaveFactor parameter is non-zero. This goal should bind the variables that remain unbound.

swap

public IloPoolOperator swap(const char * name=0) const
Creates a swap operator.

This swap operator selects a parent solution, chooses two random locations of the accessed array, and attempts to exchange their values. Upon failure, it backtracks to choose different exchange locations and fails when all exchange points have been tried. name, if provided becomes the name of the newly created operator.


translocate

public IloPoolOperator translocate(const char * name=0) const
Creates a translocation operator.

This translocation operator selects a parent solution and then chooses a random interval of the accessed array and a random insertion point. It then attempts to create a solution in which the sequence delimited by the chosen interval will be moved to the insertion point. Upon failure, it backtracks to choose a different insertion point. When this fails, it backtracks to change the interval to try to move. It fails when all intervals and insertion points have been tried. name, if provided becomes the name of the newly created operator.


transpose

public IloPoolOperator transpose(const char * name=0) const
Creates a transposition operator.

This transposition operator selects a parent solution and chooses a random interval of the accessed array. It then attempts to create a solution in which the sequence delimited by the chosen interval will be reversed. Upon failure, it backtracks to choose a different interval and fails when all intervals have been tried. name, if provided becomes the name of the newly created operator.


twoPointXover

public IloPoolOperator twoPointXover(const char * name=0) const
Creates a two-point crossover operator.

This recombination operator selects two parents and produces a solution by inheriting values from the second parent for array indices contained between two randomly chosen cut points. Other values are inherited from the first parent. Upon failure, this goal backtracks by trying other cut points. name, if provided becomes the name of the newly created operator.


uniformXover

public IloPoolOperator uniformXover(const char * name=0) const
Creates a uniform crossover operator with crossover rate 0.5.

This recombination operator selects two parents and produces a new solution by inheriting values from the first or second parent based on a crossover rate of 0.5. This goal does not backtrack. name, if provided becomes the name of the newly created operator.


uniformXover

public IloPoolOperator uniformXover(IloNum xoverRate, const char * name=0) const
Creates a uniform crossover operator.

This recombination operator selects two parents and produces a new solution by inheriting values from the first or second parent based on the given crossover rate. This goal does not backtrack. The parameter xoverRate sets the probability of each feature being exchanged. name, if provided becomes the name of the newly created operator.