Class FitnessComparisonHandler

java.lang.Object
net.bmahe.genetics4j.neat.combination.parentcompare.FitnessComparisonHandler
All Implemented Interfaces:
ParentComparisonHandler

public class FitnessComparisonHandler extends Object implements ParentComparisonHandler
  • Constructor Details

    • FitnessComparisonHandler

      public FitnessComparisonHandler()
  • Method Details

    • canHandle

      public boolean canHandle(ParentComparisonPolicy parentComparisonPolicy)
      Description copied from interface: ParentComparisonHandler
      Determines whether this handler can process the given parent comparison policy.

      This method allows the handler registry to determine which handler is appropriate for a given comparison policy type, enabling polymorphic behavior in the crossover process.

      Specified by:
      canHandle in interface ParentComparisonHandler
      Parameters:
      parentComparisonPolicy - the comparison policy to check
      Returns:
      true if this handler can process the policy, false otherwise
    • compare

      public ChosenOtherChromosome compare(ParentComparisonPolicy parentComparisonPolicy, NeatChromosome first, NeatChromosome second, int fitnessComparison)
      Description copied from interface: ParentComparisonHandler
      Compares two parent chromosomes and determines which should be chosen for preferred inheritance.

      This method analyzes the two parent chromosomes and their relative fitness to determine which parent should be considered "chosen" (typically the fitter parent) and which should be "other" for the purposes of biased gene inheritance during crossover.

      The fitness comparison parameter provides the result of comparing the parents' fitness values: positive if first is fitter, negative if second is fitter, zero if equal.

      Specified by:
      compare in interface ParentComparisonHandler
      Parameters:
      parentComparisonPolicy - the comparison policy defining the comparison strategy
      first - the first parent chromosome
      second - the second parent chromosome
      fitnessComparison - result of fitness comparison (positive: first fitter, negative: second fitter, zero: equal)
      Returns:
      ChosenOtherChromosome containing the chosen parent and other parent