View Javadoc
1   package net.bmahe.genetics4j.neat.spec.mutation;
2   
3   import org.apache.commons.lang3.Validate;
4   import org.immutables.value.Value;
5   
6   import net.bmahe.genetics4j.core.spec.mutation.MutationPolicy;
7   
8   @Value.Immutable
9   public abstract class AddConnection implements MutationPolicy {
10  
11  	@Value.Parameter
12  	public abstract double populationMutationProbability();
13  
14  	/**
15  	 * Indicates whether output nodes may be selected as the source of new connections.
16  	 *
17  	 * <p>Enabling this option allows recurrent topologies such as output-to-hidden and output-to-output connections.
18  	 * Such topologies are intended for evaluation with a recurrent network.</p>
19  	 *
20  	 * @return {@code true} when output nodes may be connection sources
21  	 */
22  	@Value.Default
23  	public boolean allowOutputNodeAsSource() {
24  		return false;
25  	}
26  
27  	@Value.Check
28  	protected void check() {
29  		Validate.inclusiveBetween(0.0, 1.0, populationMutationProbability());
30  	}
31  
32  	public static class Builder extends ImmutableAddConnection.Builder {
33  	}
34  
35  	public static Builder builder() {
36  		return new Builder();
37  	}
38  
39  	/**
40  	 * Construct a new immutable {@code AddConnection} instance using feed-forward-compatible defaults.
41  	 *
42  	 * @param populationMutationProbability The value for the {@code populationMutationProbability} attribute
43  	 * @return An immutable AddConnection instance
44  	 */
45  	public static AddConnection of(final double populationMutationProbability) {
46  		return ImmutableAddConnection.of(populationMutationProbability);
47  	}
48  
49  }