Fitness
Fitness functions evaluate how well a given solution meets the problem's objectives, guiding the genetic algorithm toward optimal solutions by assigning a numerical score to each candidate of the population.
GeneticAlgorithms.rosenbrock_fitness
— Methodrosenbrock_fitness(chromosome::Chromosome{Float64})::Float64
Calculates the fitness of the chromosome
regarding the Rosenbrock function.
The Rosenbrock function gets the genes of the chromosome as input. The result of the function is transformed to a fitness value by dividing 100 by the result plus 1. Throws an ArgumentError
if the number of genes is less than 2.
GeneticAlgorithms.sudoku_fitness
— Methodsudoku_fitness(chromosome::Chromosome{Vector{Int64}})::Float64
Calculates the fitness of a Sudoku puzzle represented by the chromosome
.
The fitness value is the sum of the number of distinct values in each row and each 3x3 subgrid. This results in a maximal fitness value of 162. The function expects a chromosome with 9 genes, each representing a row in the Sudoku puzzle. The genes are expected to have no duplicates and values between 1 and 9.