Random initialization per chromosome representation.
Dispatch
init_random/1 takes a config map with an :encoding key and returns
a single chromosome. Build a population by calling it repeatedly.
Reproducibility
Pass seed: integer to make initialization deterministic. This seeds the
process-local :rand module (:exsss); for concurrent evaluation, seed
per task.
Summary
Functions
Generate an initial population using Latin Hypercube Sampling.
Initialize a single random chromosome for the encoding specified in config.
Functions
Generate an initial population using Latin Hypercube Sampling.
LHS divides each dimension into population_size strata and samples
once per stratum, giving better initial coverage of the search space
than uniform random. Only meaningful for :real encoding.
Returns a list of RealChromosome structs, not a single chromosome.
Initialize a single random chromosome for the encoding specified in config.
Options by representation
:permutation
:n(required) — length; genes are a shuffle of0..n-1
:real
:bounds(required) — list of{lo, hi}tuples, one per gene
:binary
:length(required) — number of bits
:integer
:bounds(required) — list of{lo, hi}integer tuples, one per gene
Common
:seed— integer seed for:rand(optional)
Examples
iex> c = Petri.Initialization.init_random(%{encoding: :permutation, n: 5})
iex> Petri.Chromosome.valid?(c) and Petri.Chromosome.length(c) == 5
true