Differential Evolution › Visualizing Differential Evolution

Michael BrenndoerferOctober 29, 202610 min read
Machine Learning from ScratchAll chapters
Part 15 of 15Heuristic and Evolutionary Optimization
Chapter 92Differential Evolution › Visualizing Differential Evolution
Reading section 7 of 10 · Visualizing Differential Evolution · 10 minSection 7 of 10 · 10 min

Section 7 of 10 · 10 min read

Differential Evolution › Visualizing Differential EvolutionSection view · Sections in this chapter7 / 10 ↓
Reading tools Definitions, links & notes

Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.

Article links

Make inline references clickable

Notes & comments

When we call scipy.optimize.differential_evolution, a few of its arguments map onto the mechanics we derived:

  • init="random" uses random box initialization. SciPy also offers Latin hypercube initialization or an explicit initial population.
  • polish=False disables the additional local-polishing phase in our reference comparison. If polishing is enabled, count its evaluations as well.
  • tol and atol test population-energy spread against atol+tol ∣mean⁡(energies)∣atol+tol\,|\operatorname{mean}(energies)|, not against the best value or distance to the optimum. Setting both to zero still allows termination when the spread is exactly zero.
  • updating="deferred" uses the old population for the generation. Parallel or vectorized evaluation requires this convention.
  • rng controls SciPy's random-number generator. Reproducibility also depends on the runtime, objective, and execution settings.

For seeds 0 through 19, all three methods evaluate exactly 3000 candidates. A vectorized objective call evaluating 20 rows counts as 20 candidate evaluations, not one Python invocation. The Nelder-Mead baseline uses the same box bounds, limits each local restart to at most 200 evaluations, and keeps a global incumbent across restarts. This restart cap is a disclosed baseline choice, not a tuned guarantee.

VisualizationOut [13]
CollapseExpand
Three step curves show median incumbent objective against candidate evaluations on a logarithmic scale, using the same twenty seeds and budget for each method.
Median incumbent objective over twenty seeds on 2-D Rastrigin. Each method evaluates exactly 3000 candidates, including initialization. Values are floored at 1e-12 for the logarithmic display; lower values are better.

These are median incumbent traces on one synthetic two-dimensional objective. Read the curve together with the final-value distribution: an early improvement in a median trace does not mean every seed reached that value. The random-search baseline continues drawing across the box, while the restarted local baseline divides its budget among local searches. Their relative outcomes describe this particular box, objective, restart cap, and budget.

ConsoleOut [14]
CollapseExpand
                method min/max evaluations  median best  worst best  success rate (<1e-6)
         DE/rand/1/bin           3000/3000    1.228e-20   9.950e-01             9.000e-01
         Random search           3000/3000    1.118e+00   2.041e+00             0.000e+00
Multistart Nelder-Mead           3000/3000    9.950e-01   3.980e+00             5.000e-02

The table reports actual per-seed evaluation counts, median and worst observed final values, and the fraction below the prespecified 10−610^{-6} threshold. That threshold means a small objective value on this example, not an optimality certificate. A worst observed value is the maximum among these seeds, not a bound on future runs.

Individual final values expose the variation hidden by a median. The plot uses the same twenty seeds and 3000-candidate budget as the comparison. Values below the display floor share a plotted level even when their computed values differ.

VisualizationOut [16]
CollapseExpand
Three groups of twenty seed outcomes on a logarithmic objective axis, with a horizontal median bar in each group.
Individual final values and median bars over twenty seeds per method at exactly 3000 candidate evaluations. Values below 1e-12 share the logarithmic display floor; the table retains computed values.

The next four snapshots show one recorded seed at initialization, after ten and thirty generations, and at the end. They use the same axes so contraction remains visible; a small display margin outside the contour box prevents boundary markers from being clipped. This is one trajectory, not a claim that every seed follows the same basins or timing. The 300-by-300 contour grid requires 90,000 visualization-only candidate evaluations. Those values are not available to any search method and are separate from every search budget.

VisualizationsOut [18]
CollapseExpand
Twenty initial population points over the Rastrigin contour background.
Initial population, before mutation; 20 candidates have been evaluated.
Population positions after ten generations on the same contour axes.
Population after ten deferred generations; 220 candidates have been evaluated.
Population positions after thirty generations on the same contour axes.
Population after thirty deferred generations; 620 candidates have been evaluated.
Final population positions on the same contour axes.
Final population for seed zero after 3000 candidate evaluations.

Compare the four snapshots with the recorded evaluation indices. If the points concentrate, their donor differences become shorter without changing FF. The contour background supplies objective context, but the snapshots alone do not identify which proposal caused an improvement or establish a general convergence rate.

The final heatmap varies FF and CRCR at a fixed budget of 1500 candidates, including initialization. Every cell is a median over seeds 0 through 4 on the same synthetic objective. It shows local sensitivity to these choices; it does not estimate a universal best setting.

VisualizationOut [20]
CollapseExpand
A four-by-three heatmap of five-seed median final objective values across mutation factor F and crossover rate CR, using a logarithmic color scale.
Median final objective over five seeds for each F and CR combination on 2-D Rastrigin, with exactly 1500 candidates per run. Darker cells indicate lower values; the sweep is specific to this objective and budget.

The cells summarize measured outcomes, not an assumed explanation for them. A small median difference across five seeds is weak evidence for a ranking. A poor result can reflect the starting population, finite budget, bounds, and operator settings together; this sweep does not isolate a universal causal rule.

Comments

Add to the conversation

A question, a correction, or an example from your own work.

No comments yet. Be the first to share your thoughts!

Newsletter

Stay up to date

Get new articles, book updates, and notes on AI and technology.

Unsubscribe at any time. Privacy policy