Class ImmutableNeatCombination

java.lang.Object
net.bmahe.genetics4j.neat.spec.combination.ImmutableNeatCombination
All Implemented Interfaces:
CombinationPolicy, NeatCombination

@Generated("org.immutables.processor.ProxyProcessor") public final class ImmutableNeatCombination extends Object implements NeatCombination
Immutable implementation of NeatCombination.

Use the builder to create immutable instances: new NeatCombination.Builder().

  • Field Details

    • inheritanceThresold

      private final double inheritanceThresold
    • reenableGeneInheritanceThresold

      private final double reenableGeneInheritanceThresold
    • parentComparisonPolicy

      private final ParentComparisonPolicy 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

      private transient volatile ImmutableNeatCombination.InitShim initShim
  • Constructor Details

    • ImmutableNeatCombination

      private ImmutableNeatCombination(ImmutableNeatCombination.Builder builder)
    • ImmutableNeatCombination

      private ImmutableNeatCombination(double inheritanceThresold, double reenableGeneInheritanceThresold, ParentComparisonPolicy parentComparisonPolicy)
  • Method Details

    • inheritanceThresoldInitialize

      private double inheritanceThresoldInitialize()
    • reenableGeneInheritanceThresoldInitialize

      private double reenableGeneInheritanceThresoldInitialize()
    • parentComparisonPolicyInitialize

      private ParentComparisonPolicy 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 interface NeatCombination
      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 interface NeatCombination
      Returns:
      re-enabling threshold value between 0.0 and 1.0 (inclusive)
    • parentComparisonPolicy

      public ParentComparisonPolicy 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 interface NeatCombination
      Returns:
      the parent comparison policy (defaults to fitness-based comparison)
    • withInheritanceThresold

      public final ImmutableNeatCombination withInheritanceThresold(double value)
      Copy the current immutable object by setting a value for the inheritanceThresold attribute. A value strict bits equality used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for inheritanceThresold
      Returns:
      A modified copy of the this object
    • withReenableGeneInheritanceThresold

      public final ImmutableNeatCombination withReenableGeneInheritanceThresold(double value)
      Copy the current immutable object by setting a value for the reenableGeneInheritanceThresold attribute. A value strict bits equality used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for reenableGeneInheritanceThresold
      Returns:
      A modified copy of the this object
    • withParentComparisonPolicy

      public final ImmutableNeatCombination withParentComparisonPolicy(ParentComparisonPolicy value)
      Copy the current immutable object by setting a value for the parentComparisonPolicy attribute. A shallow reference equality check is used to prevent copying of the same value by returning this.
      Parameters:
      value - A new value for parentComparisonPolicy
      Returns:
      A modified copy of the this object
    • equals

      public boolean equals(Object another)
      This instance is equal to all instances of ImmutableNeatCombination that have equal attribute values.
      Overrides:
      equals in class Object
      Returns:
      true if this is equal to another instance
    • equalTo

      private boolean equalTo(int synthetic, ImmutableNeatCombination another)
    • hashCode

      public int hashCode()
      Computes a hash code from attributes: inheritanceThresold, reenableGeneInheritanceThresold, parentComparisonPolicy.
      Overrides:
      hashCode in class Object
      Returns:
      hashCode value
    • toString

      public String toString()
      Prints the immutable value NeatCombination with attribute values.
      Overrides:
      toString in class Object
      Returns:
      A string representation of the value
    • validate

      private static ImmutableNeatCombination validate(ImmutableNeatCombination instance)
    • copyOf

      public static ImmutableNeatCombination copyOf(NeatCombination instance)
      Creates an immutable copy of a NeatCombination 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