Crate radiate

Source

Modules§

alter
botzmann
builder
codecs
crossovers
diversity
domain
elite
engine
epoch
evaluator
genome
linear_rank
mutators
nsga2
objectives
prelude
problem
random_selector
rank
replacement
roulette
selector
stats
steady_state
stochastic_sampling
tournament

Macros§

alters
bench
build_engine
dbg_ctx
engine
experiment
filter_alters
histogram
impl_integer
labels
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.
BitCodec
A Codec 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.
CharCodec
A Codec 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.
CompositeFitnessFn
Context
CosineDistance
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.
EngineProblem
EngineProblem is a generic, base level concrete implementation of the Problem trait that is the default problem used by the engine if none other is specified during building. We take the Codec and the fitness function from the user and simply wrap them into this struct.
EuclideanDistance
Implementation of the Diversity trait that calculates the Euclidean distance between two Genotypes. The Euclidean distance is the square root of the sum of the squared differences between the corresponding genes’ alleles, normalized by the number of genes.
EvaluateStep
Event
EventBus
FitnessEvaluator
FloatChromosome
Represents a chromosome composed of floating-point genes.
FloatCodec
A Codec 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 [MIN] and [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 [MAX] and [MIN] respectively.
FnCodec
A Codec that uses functions to encode and decode a Genotype to and from a type T. Most of the other codecs 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.
HammingDistance
A concrete implementation of the Diversity trait that calculates the Hamming distance between two Genotypes. The Hamming distance is the number of positions at which the corresponding genes are different normalized by the total number of genes.
Histogram
IntChromosome
Represents a chromosome composed of integer genes.
IntCodec
A Codec 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
Metric
MetricInner
MetricLabel
MetricQuery
MetricSet
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’
NoveltySearch
PMXCrossover
ParetoFront
PermutationChromosome
PermutationCodec
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:
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.
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
Statistic
SteadyStateSelector
StochasticUniversalSamplingSelector
SubSetCodec
A Codec 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
TournamentNSGA2Selector
TournamentSelector
UniformCrossover
UniformMutator

Enums§

Aggregate
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.
EngineEvent
Executor
GroupBy
Limit
MetricType
MetricUpdate
Objective
Optimize
QueryResult
SubsetMode

Constants§

AGE
DIVERSITY_RATIO
EVALUATION_COUNT
FRONT
GENOME_SIZE
REPLACE_AGE
REPLACE_INVALID
SCORES
SCORE_IMPROVEMENT_RATE
SCORE_VOLATILITY
SPECIES_AGE
SPECIES_AGE_FAIL
SPECIES_COUNT
SPECIES_CREATED
SPECIES_DIED
SPECIES_DISTANCE_DIST
TIME
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.
Chromosome
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 a chromosome
Codec
The Codec 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
Trait for measuring diversity between two Genotypes. Within radiate this is mostly used for speciation and determining how genetically similar two individuals are. Through this, the engine can determine whether two individuals belong to the same species or not.
Engine
EngineExt
EngineIteratorExt
Evaluator
EventHandler
FitnessFunction
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
Problem represents the interface for the fitness function or evaluation and encoding/decoding of a genotype to a phenotype within the genetic algorithm framework.
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.
ToSnakeCase
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.

Functions§

format_metrics_table
get_thread_pool
intern