Record Class GAConfig

java.lang.Object
java.lang.Record
edu.cnu.mdi.sim.ga.GAConfig
Record Components:
populationSize - number of individuals; must be positive
maxGenerations - generation limit; must be non-negative
crossoverRate - 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 rate
progressEveryGens - progress interval, or zero to disable progress posts
refreshEveryGens - refresh interval, or zero to disable refresh requests
randomSeed - 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 Details

    • GAConfig

      public GAConfig(int populationSize, int maxGenerations, double crossoverRate, double mutationRate, long progressEveryGens, long refreshEveryGens, long randomSeed)
      Creates an instance of a GAConfig record class.
      Parameters:
      populationSize - the value for the populationSize record component
      maxGenerations - the value for the maxGenerations record component
      crossoverRate - the value for the crossoverRate record component
      mutationRate - the value for the mutationRate record component
      progressEveryGens - the value for the progressEveryGens record component
      refreshEveryGens - the value for the refreshEveryGens record component
      randomSeed - the value for the randomSeed record component
  • Method Details

    • defaults

      public static GAConfig defaults()
      Return a practical general-purpose configuration.
      Returns:
      default configuration
    • toString

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • populationSize

      public int populationSize()
      Returns the value of the populationSize record component.
      Returns:
      the value of the populationSize record component
    • maxGenerations

      public int maxGenerations()
      Returns the value of the maxGenerations record component.
      Returns:
      the value of the maxGenerations record component
    • crossoverRate

      public double crossoverRate()
      Returns the value of the crossoverRate record component.
      Returns:
      the value of the crossoverRate record component
    • mutationRate

      public double mutationRate()
      Returns the value of the mutationRate record component.
      Returns:
      the value of the mutationRate record component
    • progressEveryGens

      public long progressEveryGens()
      Returns the value of the progressEveryGens record component.
      Returns:
      the value of the progressEveryGens record component
    • refreshEveryGens

      public long refreshEveryGens()
      Returns the value of the refreshEveryGens record component.
      Returns:
      the value of the refreshEveryGens record component
    • randomSeed

      public long randomSeed()
      Returns the value of the randomSeed record component.
      Returns:
      the value of the randomSeed record component