Class SwapMutationFunction

  • All Implemented Interfaces:
    Changeable, MutationFunction

    public class SwapMutationFunction
    extends AbstractMutationFunction
    This class does a sort of mutation by exchanging two positions on the chromosome. Thus it can be used for implementations where a change of the amount of one symbol is undesired, e.g. some TSP implementations
    Author:
    Susanne Merz
    • Constructor Detail

      • SwapMutationFunction

        public SwapMutationFunction​(double[] probabilities)
        Sets the mutation probabilities to the designated values.
        Parameters:
        probabilities - An array, which contains the mutation probabilities.
    • Method Detail

      • mutate

        public SymbolList mutate​(SymbolList seq)
                          throws IllegalAlphabetException,
                                 ChangeVetoException,
                                 IllegalSymbolException
        Description copied from interface: MutationFunction
        Produces a new SymbolList by mutation. Each position i in the SymbolList seq is mutated with probability getMutationProbs[i]. The new residue is selected at random from the Distribution mutation. The use of an array of probabilities allows the modelling of mutational hotspots. Position 0 in the array corresponds to the probability of the first residue of seq mutating. If the length of the array defined in getMutationProbs() is shorter than the length of the sequence the default behaivour of implementations will be to apply the last probability to each subsequence residue. A single member array will mutate all bases with equal probability.
        Parameters:
        seq - the sequence to mutate
        Returns:
        The mutated sequence.
        Throws:
        IllegalAlphabetException - If the mutationSpectrum Distribution is not emitting Symbols from the same Alphabet as seq.
        ChangeVetoException - if seq is unmodifiable
        IllegalSymbolException - if the mutationSpectrum Distribution is not conditioned with the same Alphabet as the seq Alphabet.