jenes.stage.operator
Class Mutator<T extends Chromosome>

java.lang.Object
  extended by jenes.stage.AbstractStage<T>
      extended by jenes.stage.operator.Operator<T>
          extended by jenes.stage.operator.Mutator<T>
Type Parameters:
T - The class of chromosomes to work with.
Direct Known Subclasses:
SimpleMutator, TSPMutator, TSPScrambleMutator

public abstract class Mutator<T extends Chromosome>
extends Operator<T>

A generic mutation operator. The operation is executed according to a mutation probability.

The actual operator is implemented by subclassing this abstract class and providing the mutate(Individual) implementation: the method is required to mutate an Individual according to a mutation strategy. No new individual copies have to be created during the mutation operation: the individual specified at the mutate(Individual) will take parte to the output mutator population.

A Mutator.Statistics is associated to each mutator operator.

Since:
1.0
Version:
1.2
Author:
Luigi Troiano, Pierpaolo Lombardi, Giuseppe Pascale, Thierry Bodhuin
See Also:
Individual, Population

Nested Class Summary
 class Mutator.Statistics
          A statistics object holding the number of mutation performed and the time spent to execute them.
 
Field Summary
protected  double probability
          The mutation probablility
 
Fields inherited from class jenes.stage.operator.Operator
random, statistics
 
Fields inherited from class jenes.stage.AbstractStage
biggerIsBetter, ga
 
Constructor Summary
Mutator(double probability)
          Constructs a new mutator instance with the specified mutator probability
 
Method Summary
 double getProbability()
          Returns the mutator probability
protected abstract  void mutate(Individual<T> t)
          Mutates a single individual.
 void process(Population<T> in, Population<T> out)
          Processes the input population and tranforms it into the output population.
 void setProbability(double probability)
          Sets the mutator probability
 
Methods inherited from class jenes.stage.operator.Operator
getStatistics, updateStatistics
 
Methods inherited from class jenes.stage.AbstractStage
dispose, init, isBiggerBetter, setBiggerIsBetter, setBiggerIsBetter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

probability

protected double probability
The mutation probablility

Constructor Detail

Mutator

public Mutator(double probability)
Constructs a new mutator instance with the specified mutator probability

Parameters:
probability - the mutator probability
Method Detail

getProbability

public double getProbability()
Returns the mutator probability

Returns:
the mutator probability

setProbability

public void setProbability(double probability)
Sets the mutator probability

Parameters:
probability - the new mutator probability

process

public final void process(Population<T> in,
                          Population<T> out)
                   throws StageException
Description copied from class: AbstractStage
Processes the input population and tranforms it into the output population. Note: - Out population is made of recicled individuals. There is a need of new individuals to add only when there is a need to increase the population size. For pre-initalized individual just use setAs method. This is done for an efficient memory management. - A stage can modify the input population. So input passed to process method can be mutated when the process method ends.

Specified by:
process in class AbstractStage<T extends Chromosome>
Parameters:
in - the input population
out - the output population
Throws:
StageException

mutate

protected abstract void mutate(Individual<T> t)
Mutates a single individual. This abstract method is implemented according to a mutation policy

Parameters:
t - the individual to mutate