Random initialization per chromosome representation.
Dispatch
init_random/2 takes a representation tag (:permutation, :real,
:binary) and a map config, returning 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 of the given representation.
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 of the given representation.
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
Common
:seed— integer seed for:rand(optional)
Examples
iex> c = Petri.Initialization.init_random(:permutation, %{n: 5})
iex> Petri.Chromosome.valid?(c) and Petri.Chromosome.length(c) == 5
true