Distance
Distance measurements are used to quantify the distance between individuals in a population. Radiate provides several built-in distance measures that can be used to maintain diversity within the genetic algorithm.
Hamming Distance
Compatible with: FloatGene<F>, IntGene<I>, BitGene, CharGene, PermuationGene<A>
Hamming distance is the most straightforward distance measure, defined as the number of positions at which the corresponding genes are different.
- Binary or discrete genetic representations
- Problems where exact matches are important
- Cases where you want to measure diversity based on exact gene differences
Euclidean Distance
Compatible with: FloatGene<F>, IntGene<I>
We define the Euclidean Distance as follows:
or, the square root of sum of squared differences between corresponding genes' alleles. This is ideal for:
- Continuous genetic representations
- Problems where the magnitude of differences matters
- Cases where you want to measure diversity based on numerical distances
Cosine Distance
Compatible with: FloatGene<F>, IntGene<I>
We define the Cosine Distance as follows:
The Cosine Distance measures diversity by calculating the cosine of the angle between two vectors of gene values, which is particularly useful for:
- High-dimensional spaces
- Problems where the direction of the vector matters more than its magnitude
- Cases where you want to measure diversity based on the orientation of the gene vectors
Neat Distance
Compatible with: GraphNode<Op<f32>>
The Neat Distance measures diversity by using the NEAT (NeuroEvolution of Augmenting Topologies) distance metric, which considers both structural and weight differences between neural network representations. This is particularly useful for:
- Neural network evolution
- Problems where both topology and weight differences matter
- Cases where you want to measure diversity based on neural network structure and weights