Class RealVector
- Namespace
- Evolutionary
- Assembly
- Evolutionary.dll
Provides factory and operator methods for the RealVector<T> struct.
public static class RealVector
- Inheritance
-
RealVector
- Inherited Members
Methods
ArithmeticCrossover<T>(RealVector<T>, RealVector<T>, Random)
Creates a child by a whole arithmetic crossover. The child is the weighted mean of both parents, where the weight is a single random value between 0 and 1. The child may therefore lie outside of the interval spanned by the parents.
public static RealVector<T> ArithmeticCrossover<T>(RealVector<T> p1, RealVector<T> p2, Random random) where T : IFloatingPoint<T>
Parameters
p1RealVector<T>The first parent.
p2RealVector<T>The second parent.
randomRandomThe random number generator.
Returns
- RealVector<T>
The child.
Type Parameters
TThe floating point type of the vector elements. It is inferred from the parents.
Exceptions
- ArgumentException
Thrown if the lengths of both vectors differ.
CreateRandomly<T>(int, T, T, Random)
Creates a new vector whose values are uniformly distributed between
min (inclusive) and max
(exclusive).
public static RealVector<T> CreateRandomly<T>(int n, T min, T max, Random random) where T : IFloatingPoint<T>
Parameters
nintThe number of dimensions.
minTThe inclusive lower bound of the interval.
maxTThe exclusive upper bound of the interval.
randomRandomThe random number generator.
Returns
- RealVector<T>
The random vector.
Type Parameters
TThe floating point type of the vector elements, e.g. double or float. It is inferred from the bounds of the interval.
GaussianMutation<T>(RealVector<T>, Random, double)
Adds normally distributed noise with the given standard deviation to every dimension (Gaussian mutation). The noise is generated with the NextNormal(Random, double, double) extension method.
public static RealVector<T> GaussianMutation<T>(RealVector<T> vector, Random random, double sigma) where T : IFloatingPoint<T>
Parameters
vectorRealVector<T>The vector to mutate.
randomRandomThe random number generator.
sigmadoubleThe standard deviation of the noise.
Returns
- RealVector<T>
The mutated vector.
Type Parameters
TThe floating point type of the vector elements. It is inferred from the vector to mutate.
UniformCrossover<T>(RealVector<T>, RealVector<T>, Random)
Creates a child by a uniform crossover. Each value is taken from one of the parents with equal probability.
public static RealVector<T> UniformCrossover<T>(RealVector<T> p1, RealVector<T> p2, Random random) where T : IFloatingPoint<T>
Parameters
p1RealVector<T>The first parent.
p2RealVector<T>The second parent.
randomRandomThe random number generator.
Returns
- RealVector<T>
The child.
Type Parameters
TThe floating point type of the vector elements. It is inferred from the parents.
Exceptions
- ArgumentException
Thrown if the lengths of both vectors differ.