AddConnection.java
package net.bmahe.genetics4j.neat.spec.mutation;
import org.apache.commons.lang3.Validate;
import org.immutables.value.Value;
import net.bmahe.genetics4j.core.spec.mutation.MutationPolicy;
@Value.Immutable
public abstract class AddConnection implements MutationPolicy {
@Value.Parameter
public abstract double populationMutationProbability();
/**
* Indicates whether output nodes may be selected as the source of new connections.
*
* <p>Enabling this option allows recurrent topologies such as output-to-hidden and output-to-output connections.
* Such topologies are intended for evaluation with a recurrent network.</p>
*
* @return {@code true} when output nodes may be connection sources
*/
@Value.Default
public boolean allowOutputNodeAsSource() {
return false;
}
@Value.Check
protected void check() {
Validate.inclusiveBetween(0.0, 1.0, populationMutationProbability());
}
public static class Builder extends ImmutableAddConnection.Builder {
}
public static Builder builder() {
return new Builder();
}
/**
* Construct a new immutable {@code AddConnection} instance using feed-forward-compatible defaults.
*
* @param populationMutationProbability The value for the {@code populationMutationProbability} attribute
* @return An immutable AddConnection instance
*/
public static AddConnection of(final double populationMutationProbability) {
return ImmutableAddConnection.of(populationMutationProbability);
}
}