View Javadoc
1   package net.bmahe.genetics4j.core.spec;
2   
3   import java.util.Arrays;
4   
5   import org.immutables.value.Value;
6   
7   import net.bmahe.genetics4j.core.Fitness;
8   import net.bmahe.genetics4j.core.spec.chromosome.ChromosomeSpec;
9   import net.bmahe.genetics4j.core.spec.mutation.MutationPolicy;
10  
11  /**
12   * Evolutionary Algorithm Configuration.
13   * <p>This describe the set of strategies to use. They describe the genotype, the different policies for selection,
14   * combination as well as mutation, and other relevant parameters such as how to determine the fitness of a given
15   * individual.
16   * 
17   * @param <T> Type of the fitness measurement
18   */
19  @Value.Immutable
20  public abstract class EAConfiguration<T extends Comparable<T>> extends AbstractEAConfiguration<T> {
21  
22  	/**
23  	 * Defines how should individuals' fitness be assessed
24  	 * 
25  	 * @return
26  	 */
27  	public abstract Fitness<T> fitness();
28  
29  	public static class Builder<T extends Comparable<T>> extends ImmutableEAConfiguration.Builder<T> {
30  
31  		public final EAConfiguration.Builder<T> chromosomeSpecs(final ChromosomeSpec... elements) {
32  			return this.chromosomeSpecs(Arrays.asList(elements));
33  		}
34  
35  		public final EAConfiguration.Builder<T> mutationPolicies(final MutationPolicy... elements) {
36  			return this.mutationPolicies(Arrays.asList(elements));
37  		}
38  	}
39  }