Class ImmutableNeatCombination
- All Implemented Interfaces:
CombinationPolicy,NeatCombination
NeatCombination.
Use the builder to create immutable instances:
new NeatCombination.Builder().
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilds instances of typeNeatCombination.private final class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final doubleprivate final ParentComparisonPolicyprivate final doubleprivate static final byteprivate static final byteprivate static final byteFields inherited from interface net.bmahe.genetics4j.neat.spec.combination.NeatCombination
DEFAULT_INHERITANCE_THRESHOLD, DEFAULT_REENABLE_GENE_INHERITANCE_THRESHOLD -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateImmutableNeatCombination(double inheritanceThresold, double reenableGeneInheritanceThresold, ParentComparisonPolicy parentComparisonPolicy) private -
Method Summary
Modifier and TypeMethodDescriptionstatic NeatCombinationcopyOf(NeatCombination instance) Creates an immutable copy of aNeatCombinationvalue.booleanThis instance is equal to all instances ofImmutableNeatCombinationthat have equal attribute values.private booleanequalsByValue(ImmutableNeatCombination another) inthashCode()Computes a hash code from attributes:inheritanceThresold,reenableGeneInheritanceThresold,parentComparisonPolicy.doubleReturns the inheritance threshold for biasing gene selection toward fitter parents.private doubleReturns the policy used to compare parent fitness for inheritance decisions.private ParentComparisonPolicydoubleReturns the threshold for re-enabling disabled genes during crossover.private doubletoString()Prints the immutable valueNeatCombinationwith attribute values.private static ImmutableNeatCombinationvalidate(ImmutableNeatCombination instance) final ImmutableNeatCombinationwithInheritanceThresold(double value) Copy the current immutable object by setting a value for theinheritanceThresoldattribute.final ImmutableNeatCombinationCopy the current immutable object by setting a value for theparentComparisonPolicyattribute.final ImmutableNeatCombinationwithReenableGeneInheritanceThresold(double value) Copy the current immutable object by setting a value for thereenableGeneInheritanceThresoldattribute.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface net.bmahe.genetics4j.neat.spec.combination.NeatCombination
check
-
Field Details
-
inheritanceThresold
private final double inheritanceThresold -
reenableGeneInheritanceThresold
private final double reenableGeneInheritanceThresold -
parentComparisonPolicy
-
STAGE_INITIALIZING
private static final byte STAGE_INITIALIZING- See Also:
-
STAGE_UNINITIALIZED
private static final byte STAGE_UNINITIALIZED- See Also:
-
STAGE_INITIALIZED
private static final byte STAGE_INITIALIZED- See Also:
-
initShim
-
-
Constructor Details
-
ImmutableNeatCombination
-
ImmutableNeatCombination
private ImmutableNeatCombination(double inheritanceThresold, double reenableGeneInheritanceThresold, ParentComparisonPolicy parentComparisonPolicy)
-
-
Method Details
-
inheritanceThresoldInitialize
private double inheritanceThresoldInitialize() -
reenableGeneInheritanceThresoldInitialize
private double reenableGeneInheritanceThresoldInitialize() -
parentComparisonPolicyInitialize
-
inheritanceThresold
public double inheritanceThresold()Returns the inheritance threshold for biasing gene selection toward fitter parents.This threshold controls the probability of inheriting genes from the fitter parent during crossover. Higher values bias inheritance toward the better performing parent, while lower values provide more equal inheritance or even bias toward the less fit parent.
Inheritance behavior:
- 0.5 (default): Unbiased inheritance, equal probability from both parents
- > 0.5: Bias toward fitter parent, promotes convergence to good solutions
- < 0.5: Bias toward less fit parent, increases population diversity
- 1.0: Always inherit from fitter parent when fitness differs
- 0.0: Always inherit from less fit parent when fitness differs
- Specified by:
inheritanceThresoldin interfaceNeatCombination- Returns:
- inheritance threshold value between 0.0 and 1.0 (inclusive)
-
reenableGeneInheritanceThresold
public double reenableGeneInheritanceThresold()Returns the threshold for re-enabling disabled genes during crossover.When a gene (connection) is disabled in one parent but enabled in the other, this threshold determines the probability that the gene will be enabled in the offspring. This mechanism prevents permanent loss of potentially useful connections and allows rediscovery of structural innovations.
Re-enabling behavior:
- 0.25 (default): 25% chance to re-enable disabled connections
- 0.0: Never re-enable disabled connections
- 1.0: Always re-enable connections that are enabled in either parent
- Higher values: More aggressive topology exploration
- Lower values: More conservative structural preservation
- Specified by:
reenableGeneInheritanceThresoldin interfaceNeatCombination- Returns:
- re-enabling threshold value between 0.0 and 1.0 (inclusive)
-
parentComparisonPolicy
Returns the policy used to compare parent fitness for inheritance decisions.The parent comparison policy determines which parent is considered "fitter" for the purposes of biased gene inheritance. This affects how disjoint and excess genes are inherited and how the inheritance threshold is applied.
Available comparison strategies:
- FitnessComparison (default): Compare parents based on their fitness values
- Custom policies: Pluggable strategies for domain-specific comparisons
- Multi-objective: Specialized comparisons for multi-objective optimization
- Equal fitness handling: Specific behavior when parents have identical fitness
- Specified by:
parentComparisonPolicyin interfaceNeatCombination- Returns:
- the parent comparison policy (defaults to fitness-based comparison)
-
withInheritanceThresold
Copy the current immutable object by setting a value for theinheritanceThresoldattribute. A value strict bits equality used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for inheritanceThresold- Returns:
- A modified copy or the
thisobject
-
withReenableGeneInheritanceThresold
Copy the current immutable object by setting a value for thereenableGeneInheritanceThresoldattribute. A value strict bits equality used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for reenableGeneInheritanceThresold- Returns:
- A modified copy or the
thisobject
-
withParentComparisonPolicy
Copy the current immutable object by setting a value for theparentComparisonPolicyattribute. A shallow reference equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for parentComparisonPolicy- Returns:
- A modified copy or the
thisobject
-
equals
This instance is equal to all instances ofImmutableNeatCombinationthat have equal attribute values. -
equalsByValue
-
hashCode
public int hashCode()Computes a hash code from attributes:inheritanceThresold,reenableGeneInheritanceThresold,parentComparisonPolicy. -
toString
Prints the immutable valueNeatCombinationwith attribute values. -
validate
-
copyOf
Creates an immutable copy of aNeatCombinationvalue. Uses accessors to get values to initialize the new immutable instance. If an instance is already immutable, it is returned as is.- Parameters:
instance- The instance to copy- Returns:
- A copied immutable NeatCombination instance
-