Class FitnessComparisonHandler
java.lang.Object
net.bmahe.genetics4j.neat.combination.parentcompare.FitnessComparisonHandler
- All Implemented Interfaces:
ParentComparisonHandler
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
canHandle
(ParentComparisonPolicy parentComparisonPolicy) Determines whether this handler can process the given parent comparison policy.compare
(ParentComparisonPolicy parentComparisonPolicy, NeatChromosome first, NeatChromosome second, int fitnessComparison) Compares two parent chromosomes and determines which should be chosen for preferred inheritance.
-
Constructor Details
-
FitnessComparisonHandler
public FitnessComparisonHandler()
-
-
Method Details
-
canHandle
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 interfaceParentComparisonHandler
- 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 interfaceParentComparisonHandler
- Parameters:
parentComparisonPolicy
- the comparison policy defining the comparison strategyfirst
- the first parent chromosomesecond
- the second parent chromosomefitnessComparison
- result of fitness comparison (positive: first fitter, negative: second fitter, zero: equal)- Returns:
- ChosenOtherChromosome containing the chosen parent and other parent
-