01 /*
02 * Java Genetic Algorithm Library (jenetics-1.6.0).
03 * Copyright (c) 2007-2014 Franz Wilhelmstötter
04 *
05 * Licensed under the Apache License, Version 2.0 (the "License");
06 * you may not use this file except in compliance with the License.
07 * You may obtain a copy of the License at
08 *
09 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 * Author:
18 * Franz Wilhelmstötter (franz.wilhelmstoetter@gmx.at)
19 */
20 package org.jenetics;
21
22
23 /**
24 * The Alterer is responsible for the changing/recombining the Population.
25 * Alterers can be chained by appending a list of alterers with the
26 * {@link GeneticAlgorithm#setAlterers(Alterer...)} method.
27 *
28 * [code]
29 * final GeneticAlgorithm〈DoubleGene, Double〉 ga = ...
30 * ga.setAlterers(
31 * new Crossover〈DoubleGene〉(0.1),
32 * new Mutator〈DoubleGene〉(0.05),
33 * new MeanAlterer〈DoubleGene〉(0.2)
34 * );
35 * [/code]
36 *
37 * The order of the alterer calls is: Crossover, Mutation and MeanAlterer.
38 *
39 * @param <G> the gene type.
40 *
41 * @author <a href="mailto:franz.wilhelmstoetter@gmx.at">Franz Wilhelmstötter</a>
42 * @since 1.0
43 * @version 1.0 — <em>$Date: 2014-02-15 $</em>
44 */
45 public interface Alterer<G extends Gene<?, G>> {
46
47
48 /**
49 * Alters (recombine) a given population. If the {@code population}
50 * is empty, nothing is altered.
51 *
52 * @param population The Population to be altered. If the
53 * {@code population} is {@code null} or empty, nothing is altered.
54 * @param generation the date of birth (generation) of the altered phenotypes.
55 * @return the number of genes that has been altered.
56 * @throws NullPointerException if the given {@code population} is
57 * {@code null}.
58 */
59 public <C extends Comparable<? super C>> int alter(
60 final Population<G, C> population,
61 final int generation
62 );
63
64 }
|