Class ListOperator<T>

  • Type Parameters:
    T - The element type of the lists to be mutated.
    All Implemented Interfaces:
    EvolutionaryOperator<List<T>>

    public class ListOperator<T>
    extends Object
    implements EvolutionaryOperator<List<T>>

    A higher-order evolutionary operator that is applied to populations made up of lists. In such populations, each candidate solution is itself a list and this operator is applied to the list contents rather than the candidate. It is analogous to the map function in functional programming languages.

    For example, if the evolved population consists of candidates that are lists of strings, we could use a ListOperator to wrap an operator of type String and convert it to an operator that works with lists of Strings.

    • Constructor Detail

      • ListOperator

        public ListOperator​(EvolutionaryOperator<T> delegate)
        Parameters:
        delegate - The evolutionary operator that will be applied to each list candidate.
    • Method Detail

      • apply

        public List<List<T>> apply​(List<List<T>> selectedCandidates,
                                   Random rng)
        Applies the configured operator to each list candidate, operating on the elements that make up a candidate rather than on the list of candidates. candidates and returns the results.
        Specified by:
        apply in interface EvolutionaryOperator<T>
        Parameters:
        selectedCandidates - A list of list candidates.
        rng - A source of randomness.
        Returns:
        The result of applying the configured operator to each element in each list candidates.