Class ListOrderMutation<T>
- java.lang.Object
-
- org.uncommons.watchmaker.framework.operators.ListOrderMutation<T>
-
- Type Parameters:
T
- The component type of the lists that are mutated.
- All Implemented Interfaces:
EvolutionaryOperator<List<T>>
public class ListOrderMutation<T> extends Object implements EvolutionaryOperator<List<T>>
A special mutation implementation that instead of changing the genes of the candidate, re-orders them. A single mutation involves swapping a random element in the list with the element immediately after it. This operation can either apply a fixed number of mutations to each candidate or it can draw values from a random sequence, typically a poisson distribution (seePoissonGenerator
), to determine how many mutations to apply.
-
-
Constructor Summary
Constructors Constructor Description ListOrderMutation()
Default is one mutation per candidate.ListOrderMutation(int mutationCount, int mutationAmount)
ListOrderMutation(NumberGenerator<Integer> mutationCount, NumberGenerator<Integer> mutationAmount)
Typically the mutation count will be from a Poisson distribution.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<List<T>>
apply(List<List<T>> selectedCandidates, Random rng)
Apply the operation to each entry in the list of selected candidates.
-
-
-
Constructor Detail
-
ListOrderMutation
public ListOrderMutation()
Default is one mutation per candidate.
-
ListOrderMutation
public ListOrderMutation(int mutationCount, int mutationAmount)
- Parameters:
mutationCount
- The constant number of mutations to apply to each individual in the population.mutationAmount
- The constant number of positions by which a list element will be displaced as a result of mutation.
-
ListOrderMutation
public ListOrderMutation(NumberGenerator<Integer> mutationCount, NumberGenerator<Integer> mutationAmount)
Typically the mutation count will be from a Poisson distribution. The mutation amount can be from any discrete probability distribution and can include negative values.- Parameters:
mutationCount
- A random variable that provides a number of mutations that will be applied to each individual.mutationAmount
- A random variable that provides a number of positions by which to displace an element when mutating.
-
-
Method Detail
-
apply
public List<List<T>> apply(List<List<T>> selectedCandidates, Random rng)
Description copied from interface:EvolutionaryOperator
Apply the operation to each entry in the list of selected candidates. It is important to note that this method operates on the list of candidates returned by the selection strategy and not on the current population. Each entry in the list (not each individual - the list may contain the same individual more than once) must be operated on exactly once.
Implementing classes should not assume any particular ordering (or lack of ordering) for the selection. If ordering or shuffling is required, it should be performed by the implementing class. The implementation should not re-order the list provided but instead should make a copy of the list and re-order that. The ordering of the selection should be totally irrelevant for operators that process each candidate in isolation, such as mutation. It should only be an issue for operators, such as cross-over, that deal with multiple candidates in a single operation.
The operator should not modify any of the candidates passed in. Instead it should return a list that contains evolved copies of those candidates (umodified candidates can be included in the results without having to be copied).
- Specified by:
apply
in interfaceEvolutionaryOperator<T>
- Parameters:
selectedCandidates
- The individuals to evolve.rng
- A source of randomness for stochastic operators (most operators will be stochastic).- Returns:
- The evolved individuals.
-
-