Population Generators

To initialise the population, a number of random generators are provided.

Vector-based populations

For EAs and GAs.

Discrete domains

EvoLP.binary_vector_popFunction
binary_vector_pop(n, l; rng=Random.GLOBAL_RNG)

Generate a population of n vector binary individuals, each of length l.

Examples

julia> using EvoLP

julia> binary_vector_pop(2, 5)
2-element Vector{BitVector}:
[1, 0, 1, 1, 0]
[0, 1, 0, 0, 0]
EvoLP.permutation_vector_popFunction
permutation_vector_pop(n, d, pool; replacement=false, rng=Random.GLOBAL_RNG)

Generate a population of n permutation vector individuals, of size d and with values sampled from pool. Usually d would be equal to length(pool).

Sampling is without replacement by default (generating permutations if pool is a set). When replacement=true then it generates combinations of (possibly) repeated values.

Examples

julia> permutation_vector_pop(1, 8, 1:8)
1-element Vector{Vector{Int64}}:
[7, 3, 8, 1, 5, 6, 4, 2]

julia> permutation_vector_pop(2, 5, ["a", "b", "c", "d", "e"]; replacement=false)
2-element Vector{Vector{String}}:
["e", "b", "c", "d", "a"]
["b", "d", "a", "e", "c"]

Continuous domains

EvoLP.normal_rand_vector_popFunction
normal_rand_vector_pop(n, μ, Σ; rng=Random.GLOBAL_RNG)

Generate a population of n vector individuals using a normal distribution with means μ and covariance Σ.

μ expects a vector of length l (i.e. length of an individual) while Σ expects an l x l matrix of covariances.

Examples

julia> normal_rand_vector_pop(3, [0, 0], [1 0; 0 1])
3-element Vector{Vector{Float64}}:
[-0.15290525182234904, 0.8715880371871617]
[-1.1283800329864322, -0.9256584563613383]
[-0.5384758126777555, -0.8141702145510666]
EvoLP.unif_rand_vector_popFunction
unif_rand_vector_pop(n, lb, ub; rng=Random.GLOBAL_RNG)

Generate a population of n vector individuals using a uniformly random distribution between lower bounds lb and upper bounds ub.

Both lb and ub must be arrays of the same dimensions.

Examples

julia> unif_rand_vector_pop(3, [-1, -1], [1, 1])
3-element Vector{Vector{Float64}}:
[-0.16338687344459046, 0.31576097298524064]
[-0.941510876597899, 0.8219576462978224]
[-0.377090051761797, -0.28434454028992096]

Particle-based populations

For particle-swarm optimisation.

EvoLP 1.1

Particle objects in EvoLP pre-v.1.1 had no fitness placeholders. If you use a custom Particle generator, you might want to update it. For built-in generators and algorithms, the update would not be noticeable.

EvoLP.ParticleType

A single particle in the swarm, with a position x, a velocity v, the best position it has encountered x_best and its evaluations y and y_best

EvoLP.unif_rand_particle_popFunction
unif_rand_particle_pop(n, lb, ub; rng=Random.GLOBAL_RNG)

Generate a population of n Particle individuals using a uniformly random distribution between lower bounds lb and upper bounds ub.

Both lb and ub must be arrays of the same dimensions.

Examples

julia> unif_rand_particle_pop(3, [-1, -1], [1, 1])
3-element Vector{Particle}:
Particle([1.0823301388655755, 0.1544036055233653], [0, 0], Inf, [1.0823301388655755, 0.1544036055233653], Inf)
Particle([1.0718059584439532, 1.5793257162200343], [0, 0], Inf, [1.0718059584439532, 1.5793257162200343], Inf)
Particle([1.732268523018161, 0.32172551959160556], [0, 0], Inf, [1.732268523018161, 0.32172551959160556], Inf)
EvoLP.normal_rand_particle_popFunction
normal_rand_particle_pop(n, μ, Σ; rng=Random.GLOBAL_RNG)

Generate a population of n Particle using a normal distribution with means μand covarianceΣ.

μ expects a vector of length l (i.e. number of dimensions) while Σ expects an l x l matrix of covariances.

Examples

julia> normal_rand_particle_pop(3, [0, 0], [1 0; 0 1])
3-element Vector{Particle}:
Particle([-0.6025996585348097, -1.0055548956861133], [0.0, 0.0], Inf, [-0.6025996585348097, -1.0055548956861133], Inf)
Particle([-0.7562454555135321, 1.9490439959687778], [0.0, 0.0], Inf, [-0.7562454555135321, 1.9490439959687778], Inf)
Particle([0.5687241357408321, -0.7406267072113427], [0.0, 0.0], Inf, [0.5687241357408321, -0.7406267072113427], Inf)`