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 class
Builds instances of typeImmutableNeatCombination
.private final class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final double
private final ParentComparisonPolicy
private final double
private static final byte
private static final byte
private static final byte
Fields inherited from interface net.bmahe.genetics4j.neat.spec.combination.NeatCombination
DEFAULT_INHERITANCE_THRESHOLD, DEFAULT_REENABLE_GENE_INHERITANCE_THRESHOLD
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
ImmutableNeatCombination
(double inheritanceThresold, double reenableGeneInheritanceThresold, ParentComparisonPolicy parentComparisonPolicy) private
-
Method Summary
Modifier and TypeMethodDescriptionstatic ImmutableNeatCombination
copyOf
(NeatCombination instance) Creates an immutable copy of aNeatCombination
value.boolean
This instance is equal to all instances ofImmutableNeatCombination
that have equal attribute values.private boolean
equalTo
(int synthetic, ImmutableNeatCombination another) int
hashCode()
Computes a hash code from attributes:inheritanceThresold
,reenableGeneInheritanceThresold
,parentComparisonPolicy
.double
Returns the inheritance threshold for biasing gene selection toward fitter parents.private double
Returns the policy used to compare parent fitness for inheritance decisions.private ParentComparisonPolicy
double
Returns the threshold for re-enabling disabled genes during crossover.private double
toString()
Prints the immutable valueNeatCombination
with attribute values.private static ImmutableNeatCombination
validate
(ImmutableNeatCombination instance) final ImmutableNeatCombination
withInheritanceThresold
(double value) Copy the current immutable object by setting a value for theinheritanceThresold
attribute.final ImmutableNeatCombination
Copy the current immutable object by setting a value for theparentComparisonPolicy
attribute.final ImmutableNeatCombination
withReenableGeneInheritanceThresold
(double value) Copy the current immutable object by setting a value for thereenableGeneInheritanceThresold
attribute.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods 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:
inheritanceThresold
in 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:
reenableGeneInheritanceThresold
in 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:
parentComparisonPolicy
in interfaceNeatCombination
- Returns:
- the parent comparison policy (defaults to fitness-based comparison)
-
withInheritanceThresold
Copy the current immutable object by setting a value for theinheritanceThresold
attribute. 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 of the
this
object
-
withReenableGeneInheritanceThresold
Copy the current immutable object by setting a value for thereenableGeneInheritanceThresold
attribute. 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 of the
this
object
-
withParentComparisonPolicy
Copy the current immutable object by setting a value for theparentComparisonPolicy
attribute. 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 of the
this
object
-
equals
This instance is equal to all instances ofImmutableNeatCombination
that have equal attribute values. -
equalTo
-
hashCode
public int hashCode()Computes a hash code from attributes:inheritanceThresold
,reenableGeneInheritanceThresold
,parentComparisonPolicy
. -
toString
Prints the immutable valueNeatCombination
with attribute values. -
validate
-
copyOf
Creates an immutable copy of aNeatCombination
value. 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
-