Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

9. Global Search: DE and PSO

Global search in nlopt4r runs on finite boxes, reads objective values and uses explicitly seeded random streams. The two population algorithms are synchronous differential evolution (DE/rand/1/bin) and inertia-weight global-best particle swarm optimization (PSO).

9.1 Differential evolution

The per-generation flow of global::differential_evolution:

  1. initialization: sample population_size points uniformly in the box, or validate a caller-supplied population;
  2. for each target \(i\), draw three distinct donors \(a,b,c\) with \(i\) excluded from the donor set;
  3. mutation vector
$$ v=x_a+F\,(x_b-x_c); $$
  1. binomial crossover: each coordinate takes the mutant component with probability \(CR\), with at least one coordinate forced to the mutant component, including at \(CR=0\);
  2. bound repair: a mutant component below its lower bound becomes
$$ \text{repaired}=l_j+\tfrac12\,(x_{i,j}-l_j), $$

and one above its upper bound becomes

$$ \text{repaired}=u_j+\tfrac12\,(x_{i,j}-u_j); $$
  1. selection: replace the target when the trial objective is at most the current value.

All donors read the preceding generation, giving synchronous updates. Defaults and valid ranges:

FieldDefaultValid range
population_size40\(\ge 4\)
max_generations1000Nonnegative integer
weight (\(F\))0.8\(0<F\le2\)
crossover (\(CR\))0.9\(0\le CR\le1\)
seed0Any 64-bit unsigned integer
budget.max_evaluations10000Positive integer
budget.target_valueNoneFinite value

9.2 Particle swarm

The velocity and position updates of global::particle_swarm:

$$ v_i\leftarrow w\,v_i+c_1 r_1\odot(p_i-x_i)+c_2 r_2\odot(g-x_i), $$
$$ x_i\leftarrow x_i+v_i, $$

where \(p_i\) is the personal best, \(g\) the global-best snapshot taken at the start of the generation, and \(r_1,r_2\) independent uniform draws per coordinate.

Implementation details:

  • initial velocities are zero;
  • velocity components clip to \(\pm v_{\max,j}\) with \(v_{\max,j}=c_v,(u_j-l_j)\), where velocity_limit supplies \(c_v\);
  • positions project into the box; a projected coordinate resets its velocity to zero;
  • personal bests update on a strict objective decrease; ties keep the earlier best;
  • the global best updates by generation, and all particles in a generation read one snapshot.

Defaults and valid ranges:

FieldDefaultValid range
population_size40\(\ge 2\)
max_generations1000Nonnegative integer
inertia (\(w\))0.7\(0\le w<1\)
cognitive (\(c_1\))1.5Finite nonnegative
social (\(c_2\))1.5Finite nonnegative
velocity_limit0.2\(0<v\le1\)
seed0Any 64-bit unsigned integer

9.3 Randomness and reproduction

Both entry points use the ChaCha8 stream of rand_chacha 0.9, seeded by the seed field. Initialization samples normalized coordinates:

$$ x_i=l_i+s_i\,(u_i-l_i),\qquad s_i\sim U[0,1]. $$

Reproduction conditions: identical seed, dependency versions and floating-point platform. The same seed reproduces the same sequence on the same build and platform.

9.4 Report and diversity

GlobalSolution fields:

FieldMeaning
x, valueBest evaluated point and its objective
generationsCompleted generations (initialization and an unfinished generation excluded)
evaluationsCallback counts, including initialization
termination_reasonTargetReached, MaxEvaluations, MaxIterations, Stagnated or Cancelled
seedSeed of this run
diversityMaximum over coordinates of the population spread divided by the box width

target_reached() tests for TargetReached, which corresponds to the objective reaching the caller’s target_value.

9.5 Budget and cancellation

  • the objective budget is a strict cap: exhaustion during initialization or a partial generation returns the best evaluated point;
  • _with_observer variants call the observer after each valid evaluation; Control::Stop cancels after the current evaluation; an observer error propagates with the best point retained;
  • cancellation, budget and generation caps are ordinary reports, with termination_reason recording the specific cause.

Software interface

  • DeOptions, PsoOptions, differential_evolution, particle_swarm: see chapter 17.
  • Observers and EvaluationContext: see chapter 21.
  • Benchmark protocol and measured results: see chapter 13.
  • API reference (docs.rs): global.

References

  • R. Storn, K. Price, “Differential Evolution—A Simple and Efficient Heuristic for Global Optimization over Continuous Spaces,” J. Global Optim. 11 (1997), 341–359.
  • J. Kennedy, R. Eberhart, “Particle swarm optimization,” Proc. IEEE ICNN 4 (1995), 1942–1948.
  • Y. Shi, R. Eberhart, “A modified particle swarm optimizer,” Proc. IEEE ICEC (1998), 69–73.