Package edu.cnu.mdi.sim.ga
Record Class GAConfig
java.lang.Object
java.lang.Record
edu.cnu.mdi.sim.ga.GAConfig
- Record Components:
populationSize- number of individuals; must be positivemaxGenerations- generation limit; must be non-negativecrossoverRate- probability of applying crossover, in[0,1]mutationRate- probability of invoking the mutation operator for each offspring, in[0,1]; gene-level operators may interpret it as a per-gene rateprogressEveryGens- progress interval, or zero to disable progress postsrefreshEveryGens- refresh interval, or zero to disable refresh requestsrandomSeed- deterministic seed, or zero for a nondeterministic seed
public record GAConfig(int populationSize, int maxGenerations, double crossoverRate, double mutationRate, long progressEveryGens, long refreshEveryGens, long randomSeed)
extends Record
A record to hold the configuration parameters for a genetic algorithm. This includes population size,
number of generations, crossover and mutation rates, and notification intervals.
The GA will use these parameters to control the evolution process.
-
Constructor Summary
ConstructorsConstructorDescriptionGAConfig(int populationSize, int maxGenerations, double crossoverRate, double mutationRate, long progressEveryGens, long refreshEveryGens, long randomSeed) Creates an instance of aGAConfigrecord class. -
Method Summary
Modifier and TypeMethodDescriptiondoubleReturns the value of thecrossoverRaterecord component.static GAConfigdefaults()Return a practical general-purpose configuration.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.intReturns the value of themaxGenerationsrecord component.doubleReturns the value of themutationRaterecord component.intReturns the value of thepopulationSizerecord component.longReturns the value of theprogressEveryGensrecord component.longReturns the value of therandomSeedrecord component.longReturns the value of therefreshEveryGensrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
GAConfig
public GAConfig(int populationSize, int maxGenerations, double crossoverRate, double mutationRate, long progressEveryGens, long refreshEveryGens, long randomSeed) Creates an instance of aGAConfigrecord class.- Parameters:
populationSize- the value for thepopulationSizerecord componentmaxGenerations- the value for themaxGenerationsrecord componentcrossoverRate- the value for thecrossoverRaterecord componentmutationRate- the value for themutationRaterecord componentprogressEveryGens- the value for theprogressEveryGensrecord componentrefreshEveryGens- the value for therefreshEveryGensrecord componentrandomSeed- the value for therandomSeedrecord component
-
-
Method Details
-
defaults
Return a practical general-purpose configuration.- Returns:
- default configuration
-
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 '=='. -
populationSize
public int populationSize()Returns the value of thepopulationSizerecord component.- Returns:
- the value of the
populationSizerecord component
-
maxGenerations
public int maxGenerations()Returns the value of themaxGenerationsrecord component.- Returns:
- the value of the
maxGenerationsrecord component
-
crossoverRate
public double crossoverRate()Returns the value of thecrossoverRaterecord component.- Returns:
- the value of the
crossoverRaterecord component
-
mutationRate
public double mutationRate()Returns the value of themutationRaterecord component.- Returns:
- the value of the
mutationRaterecord component
-
progressEveryGens
public long progressEveryGens()Returns the value of theprogressEveryGensrecord component.- Returns:
- the value of the
progressEveryGensrecord component
-
refreshEveryGens
public long refreshEveryGens()Returns the value of therefreshEveryGensrecord component.- Returns:
- the value of the
refreshEveryGensrecord component
-
randomSeed
public long randomSeed()Returns the value of therandomSeedrecord component.- Returns:
- the value of the
randomSeedrecord component
-