This object represents a single individual in a GeneticAlgorithm. To use the class GeneticAlgorithm, you must also implement a custom subclass of this class. Your custom subclass should contain the variables which will represent the genes for the genetic algorithm, and must also implement a few methods used for genetic operators.At a very minimum, you must implement your own versions of the methods compute-fitness, copy and mutate. If you intend to use the crossover genetic operator, you must also implement the method crossover. If these methods are not implemented by your subclass, the object will trigger a runtime error.
Methods to Override in Custom Subclasses
Implement this method to copy the genes from otherIndividual. This method must be implemented by your subclass.
Implement this method to make this object become a crossover of parent1 and parent2. This method must be implemented by your subclass if crossover is enabled.
Returns the fitness value associated with this individual, which has been previously assigned using set-fitness.
Implement this method to mutate the genes of this object. This method must be implemented by your subclass.
Implement this method to randomize the genes of this object. This method must be implemented by your subclass.
Assigns a fitness value to this individual. This method should be called by the user at the end of the fitness test.