Package edu.cnu.mdi.sim.ga
Record Class GAState
java.lang.Object
java.lang.Record
edu.cnu.mdi.sim.ga.GAState
- Record Components:
generation- generation number, starting at zerobestFitness- highest fitness observed over the entire runmeanFitness- mean fitness of the current populationworstFitness- lowest fitness in the current populationdiversityIndex- population diversity measure, or zero when unavailable
public record GAState(long generation, double bestFitness, double meanFitness, double worstFitness, double diversityIndex)
extends Record
Immutable statistics snapshot for a genetic algorithm generation.
-
Constructor Summary
ConstructorsConstructorDescriptionGAState(long generation, double bestFitness, double meanFitness, double worstFitness, double diversityIndex) Creates an instance of aGAStaterecord class. -
Method Summary
Modifier and TypeMethodDescriptiondoubleReturns the value of thebestFitnessrecord component.doubleReturns the value of thediversityIndexrecord component.final booleanIndicates whether some other object is "equal to" this one.longReturns the value of thegenerationrecord component.final inthashCode()Returns a hash code value for this object.doubleReturns the value of themeanFitnessrecord component.final StringtoString()Returns a string representation of this record class.doubleReturns the value of theworstFitnessrecord component.
-
Constructor Details
-
GAState
public GAState(long generation, double bestFitness, double meanFitness, double worstFitness, double diversityIndex) Creates an instance of aGAStaterecord class.- Parameters:
generation- the value for thegenerationrecord componentbestFitness- the value for thebestFitnessrecord componentmeanFitness- the value for themeanFitnessrecord componentworstFitness- the value for theworstFitnessrecord componentdiversityIndex- the value for thediversityIndexrecord component
-
-
Method Details
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with '=='. -
generation
public long generation()Returns the value of thegenerationrecord component.- Returns:
- the value of the
generationrecord component
-
bestFitness
public double bestFitness()Returns the value of thebestFitnessrecord component.- Returns:
- the value of the
bestFitnessrecord component
-
meanFitness
public double meanFitness()Returns the value of themeanFitnessrecord component.- Returns:
- the value of the
meanFitnessrecord component
-
worstFitness
public double worstFitness()Returns the value of theworstFitnessrecord component.- Returns:
- the value of the
worstFitnessrecord component
-
diversityIndex
public double diversityIndex()Returns the value of thediversityIndexrecord component.- Returns:
- the value of the
diversityIndexrecord component
-