Sampling generates candidate points from a search space or distribution. In population-based optimization, those points can form the initial population: a set of solutions to evaluate and improve. The choice of method affects how widely candidates are spread before the search begins. section 7.1
Choose an initialization method according to the coverage and cost the problem needs:
- Pseudo-random sampling is inexpensive but offers moderate diversity. It is a simple starting point when broad, even coverage is not essential. section 7.1
- Quasi-random sequences, including Sobol sequences, spread points more evenly through the sample space. Latin hypercube sampling divides the space into blocks and generates a point in each block. section 7.1
- Box–Muller and central limit theorem sampling generate normally distributed values rather than simply spreading points across a bounded space. Match the distribution to the candidates you need. section 7.1
Compare 200 candidate points
For a two-variable problem bounded between 0 and 1, create a pymoo Problem, then call FloatRandomSampling()(problem, 200).get("X") to obtain candidate points. Replace FloatRandomSampling() with LHS() and plot both sets. Compare the gaps and dispersion, not just the number of points: both methods generate 200 candidates, but they can cover the space differently. section 7.1
Compare the plotted gaps and dispersion produced by six initialization methods; each point represents a candidate solution. section 7.1
Sampling also appears later in a genetic algorithm, but with a different job. Initial-population sampling creates candidates; parent selection chooses existing individuals to reproduce. Uniform random parent selection gives each of N individuals probability 1/N, regardless of fitness. In a Python implementation, random.sample(population, num_parents) makes that choice; roulette-wheel selection instead weights choices by fitness. Random survivor selection likewise draws N individuals for the next population. section 7.3.3 section 7.4 section 7.3.5
Initialize a ticket-pricing search
One binary genetic algorithm draws starting ticket prices as integers from 75 to 235, encodes them as eight-bit chromosomes, and then evaluates their profit. A pymoo version defines the same bounds and sets GA(sampling=FloatRandomSampling(), pop_size=100). The sampling setting creates starting candidates; crossover and mutation are separate settings for subsequent search. section 7.4






















