Crate radiate

Source

Modules§

alter
audit
botzmann
builder
codexes
config
crossovers
diversity
domain
elite
engine
epoch
genome
iter
linear_rank
mutators
nsga2
objectives
pipeline
problem
random_selector
rank
replacement
roulette
selector
stats
steady_state
steps
stochastic_sampling
thread_pool
tournament

Macros§

alters
bench
build_engine
dbg_ctx
engine
experiment
histogram
impl_integer
log_ctx
metric
metricset_to_string
print_metrics

Structs§

Adder
AlterResult
The AlterResult struct is used to represent the result of an alteration operation. It contains the number of operations performed and a vector of metrics that were collected during the alteration process.
ArithmeticMutator
Arithmetic Mutator. Mutates genes by performing arithmetic operations on them. The ArithmeticMutator takes a rate parameter that determines the likelihood that a gene will be mutated. The ArithmeticMutator can perform addition, subtraction, multiplication, and division on genes.
BitChromosome
A Chromosome that contains BitGene. A BitChromosome is a collection of BitGene that represent the genetic material of an individual in the population.
BitCodex
A Codex for a Genotype of BitGenes. The encode function creates a Genotype with num_chromosomes chromosomes and num_genes genes per chromosome. The decode function creates a Vec<Vec<bool>> from the Genotype where the inner Vec contains the alleles of the BitGenes in the chromosome - the bool values.
BitGene
A gene that represents a single bit. The allele is a bool that is randomly assigned. The allele is either true or false. This is the simplest form of a gene and in traditional genetic algorithms is the gene that is used to represent the individuals.
BlendCrossover
BoltzmannSelector
CharChromosome
A Chromosome that contains CharGene.
CharCodex
A Codex for a Genotype of CharGenes. The encode function creates a Genotype with num_chromosomes chromosomes and num_genes genes per chromosome. The decode function creates a String from the Genotype where the String contains the alleles of the CharGenes in the chromosome.
CharGene
A gene that represents a single character. The allele is a char that is randomly selected from the ALPHABET constant.
Distribution
Ecosystem
EliteSelector
EncodeReplace
Replacement strategy that replaces the individual with a new one generated by the encoder. This is the default replacement strategy used in genetic algorithms.
EngineConfig
EngineIterator
EngineParams
EngineProblem
EvaluateStep
FloatChromosome
Represents a chromosome composed of floating-point genes.
FloatCodex
A Codex for a Genotype of FloatGenes. The encode function creates a Genotype with num_chromosomes chromosomes and num_genes genes per chromosome. The decode function creates a Vec<Vec<f32>> from the Genotype where the inner Vec contains the alleles of the FloatGenes in the chromosome - the f32 values.
FloatGene
A Gene that represents a floating point number. The allele is the in the case of the FloatGene a f32. The min and max values default to f32::MIN and f32::MAX respectively. The min and max values are used to generate a random number between the min and max values, which is the allele of the FloatGene. The upper_bound and lower_bound are used to set the bounds of the FloatGene when it is used in a BoundGene context (crossover or mutation). The upper_bound and lower_bound default to f32::MAX and f32::MIN respectively.
FnCodex
A Codex that uses functions to encode and decode a Genotype to and from a type T. Most of the other codexes in this module are more specialized and are used to create Genotypes of specific types of Chromosomes. This one, however, is more general and can be used to create Genotypes of any type of Chromosome.
Front
A front is a collection of scores that are non-dominated with respect to each other. This is useful for multi-objective optimization problems where the goal is to find the best solutions that are not dominated by any other solution. This results in what is called the Pareto front.
GaussianMutator
The GaussianMutator is a simple mutator that adds a small amount of Gaussian noise to the gene.
Generation
GeneticEngine
The GeneticEngine is the core component of the Radiate library’s genetic algorithm implementation. The engine is designed to be fast, flexible and extensible, allowing users to customize various aspects of the genetic algorithm to suit their specific needs.
GeneticEngineBuilder
Parameters for the genetic engine. This struct is used to configure the genetic engine before it is created.
Genotype
The Genotype struct represents the genetic makeup of an individual. It is a collection of Chromosome instances, it is essentially a light wrapper around a Vec of Chromosomes. The Genotype struct, however, has some additional functionality and terminology that aligns with the biological concept of a genotype. In traditional biological terms, a Genotype is the set of genes in our DNA that determine a specific trait or set of traits. The Genotype is the ‘genetic’ part of the individual that is being evolved by the genetic algorithm.
IntChromosome
Represents a chromosome composed of integer genes.
IntCodex
A Codex for a Genotype of IntGenes. The encode function creates a Genotype with num_chromosomes chromosomes and num_genes genes per chromosome. The decode function creates a Vec<Vec<T>> from the Genotype where the inner Vec contains the alleles of the IntGenes in the chromosome. T must implement the Integer trait, meaning it must be one of i8, i16, i32, i64, i128, u8, u16, u32, u64, or u128.
IntGene
A Gene that represents an integer value. This gene just wraps an integer value and provides functionality for it to be used in a genetic algorithm. In this Gene implementation, the allele is the integer value itself, the min and max values are the minimum and maximum values that the integer can be generated from, and the upper and lower bounds are the upper and lower bounds the gene will be subject to during crossover and mutation. If the allele exceedes the bounds, the Gene will be considered invalid.
IntermediateCrossover
Intermediate Crossover. This crossover method takes two chromosomes and crosses them by taking a weighted average of the two alleles. The weight is determined by the alpha parameter. The new allele is calculated as:
InversionMutator
The InversionMutator is a simple mutator that inverts a random section of the chromosome.
LinearRankSelector
MeanCrossover
The MeanCrossover is a simple crossover method that replaces the genes of the first chromosome with the mean of the two genes. The mean is calculated by adding the two genes together and dividing by two.
Member
MetricAudit
Adds various metrics to the output context, including the age of individuals, the score of individuals, and the number of unique scores in the population. These metrics can be used to monitor the progress of the genetic algorithm and to identify potential issues or areas for improvement.
MetricSet
MultiObjectiveGeneration
MultiPointCrossover
The MultiPointCrossover is a crossover method that takes two chromosomes and crosses them by selecting multiple points in the chromosome and swapping the genes between the two chromosomes. The number of points to swap is determined by the num_points parameter and must be between 1 and the length of the chromosome. Note, in most cases having more than 2 points is not useful and actually reduces the effectiveness of the crossover. However, it can be useful in some cases so it is allowed.
NSGA2Selector
NSGA2 Selector. Selects individuals based on the NSGA2 algorithm. This algorithm ranks individuals based on their dominance relationships with other individuals in the population. The result is a vector of ranks, where the rank of the individual at index i is ranks[i]. Individuals are then selected based on their rank and crowding distance. The crowding distance is a measure of how close an individual is to its neighbors in the objective space. Individuals with a higher crowding distance are more desirable because they are more spread out. This is useful for selecting diverse solutions in a multi-objective optimization problem. It uses ‘fast non-dominated sorting’
PMXCrossover
PermutationChromosome
PermutationCodex
PermutationGene
The PermutationGene is a gene that represents a permutation of a set of alleles. The gene has an index that represents the position of the allele in the alleles vector. The alleles vector is a set of unique values. The gene is valid if the index is less than the length of the alleles vector. This gene is useful for representing permutations of values, such as the order of cities in a TSP problem.
Phenotype
A Phenotype is a representation of an individual in the population. It contains:
PhenotypeId
A unique identifier for a Phenotype. This is used to identify the Phenotype in the population. It is a simple wrapper around a u64 value.
Pipeline
Population
A Population is a collection of Phenotype instances. This struct is the core collection of individuals being evolved by the GeneticEngine. It can be thought of as a Vec of Phenotypes and is essentially a light wrapper around such a Vec. The Population struct, however, has some additional functionality that allows for sorting and iteration over the individuals in the population.
PopulationSampleReplace
Replacement strategy that replaces the individual with a random member of the population. This can be useful in cases where the population is large and diverse or when the chromosome grows or changes in size, thus encoding a new individual can result in a member that that lacks significant diversity.
ProbabilityWheelIterator
An iterator that generates random indices based on probabilities. This iterator is used in the RouletteWheel selection algorithm, and Boltzmann selection algorithm. This is essentially the ‘roulette wheel’ that is spun to select individuals from the population. The probability of selecting an individual is based on the fitness (probability) of the individual. The higher the fitness, the higher the probability of the individual being selected.
RandomSelector
RankSelector
RouletteSelector
Score
A score is a value that can be used to compare the fitness of two individuals and represents the ‘fitness’ of an individual within the genetic algorithm. The score can be a single value or multiple values, depending on the problem being solved. For ease of use the Score struct provides methods to convert the score to a single value, an integer, a string, or a vector of f32 values.
ScrambleMutator
ShuffleCrossover
SimulatedBinaryCrossover
Species
SpeciesId
Statistic
SteadyStateSelector
StochasticUniversalSamplingSelector
SubSetCodex
A Codex for a subset of items. This is useful for problems where the goal is to find the best subset of items from a larger set of items. The encode function creates a Genotype with a single chromosome of BitGenes where each gene represents an item in the items vector. The decode function creates a Vec<&T> from the Genotype where the Vec contains the items that are selected by the BitGenes - the true genes.
SwapMutator
TimeStatistic
TournamentSelector
UniformCrossover
UniformMutator

Enums§

AlterAction
The AlterAction enum is used to represent the different types of alterations that can be performed on a population - It can be either a mutation or a crossover operation.
Metric
Objective
Optimize
SubsetMode

Constants§

AGE
EVOLUTION_TIME
FITNESS
FRONT
GENOME_SIZE
REPLACE_AGE
REPLACE_INVALID
SCORE
SPECIES_AGE
SPECIES_AGE_FAIL
SPECIES_COUNT
SPECIES_CREATED
SPECIES_DIED
SPECIES_DISTANCE_DIST
UNIQUE_MEMBERS
UNIQUE_SCORES

Traits§

Alter
This is the main trait that is used to define the different types of alterations that can be performed on a population. The Alter trait is used to define the alter method that is used to perform the alteration on the population. The alter method takes a mutable reference to the population and a generation number as parameters. The alter method returns a vector of Metric objects that represent the metrics that were collected during the alteration process.
ArithmeticGene
A Gene that represents a number. This gene can be used to represent any type of number, including integers, floats, etc. Essentially, any gene that can Add, Sub, Mul, and Div can be used as a ArithmeticGene.
Audit
Chromosome
The Chromosome struct represents a collection of Gene instances. The Chromosome is part of the genetic makeup of an individual. It is a collection of Gene instances, it is essentially a light wrapper around a Vec of Genes. The Chromosome struct, however, has some additional functionality and terminology that aligns with the biological concept of achromosome
Codex
The Codex is a core concept in Radiate, as it allows for the encoding and decoding from a Genotype to the type T (commonly called Phenotype in biology) that is being optimized.
Crossover
The Crossover trait is used to define the crossover operation for a genetic algorithm.
Diversity
Engine
EngineBuilder
EngineExt
EngineIteratorExt
EngineStep
Epoch
Gene
A Gene is a single unit of information in a Chromosome. This is the most basic building block of this entire library.
Integer
Mutate
Problem
ReplacementStrategy
Trait for replacement strategies in genetic algorithms.
Select
A trait for selection algorithms. Selection algorithms are used to select individuals from a population to be used in the next generation. The selection process is (most of the time) based on the fitness of the individuals in the population. The selection process can be based on the fitness of the individuals in the population, or it can be based on the individuals themselves.
Valid
A Valid type is a type that can be checked for validity. This is used for checking if a gene or a chromosome is valid. For example, a gene that represents a number between 0 and 1 can be checked for validity by ensuring that the allele is between 0 and 1.