8000
Skip to content

[BUG]: OriginalDE (DE/rand/1/bin): missing j_rand in binomial crossover + asynchronous in-generation replacement #282

Description

Description of the bug

Affects mealpy/evolutionary_based/DE.py (checked at commit 48b48c3), ll. 84–85 and 104–106.

  1. Missing j_rand (ll. 84–85). The binomial crossover draws the mask without forcing one guaranteed mutant coordinate. Canonical DE/rand/1/bin (Storn & Price 1997) requires index j_rand so the trial always differs from its parent. Without it, the trial equals its parent with probability (1 − CR)^D per individual per generation — e.g. CR = 0.5, D = 10 gives ≈ 1e-3, so identical-to-parent trials occur regularly in long runs, wasting evaluations and changing the algorithm's invariants.

  2. Asynchronous replacement in single mode (ll. 104–106). Each agent is greedily replaced inside the generation loop, so mutants generated later in the same generation draw r1, r2, r3 from an already-updated population. Canonical DE/rand/1/bin is synchronous: all trials are built from the previous generation.

Steps To Reproduce

  1. Open mealpy/evolutionary_based/DE.py at 48b48c3, ll. 84–85: no j_rand index is set after the mask draw.

  2. Analytic check: P(trial == parent) = (1 − CR)^D > 0; canonical binomial crossover makes this exactly 0.

  3. ll. 104–106: self.pop[idx] is replaced inside the per-agent loop (default "single" mode) — later agents in the same generation sample the partially updated population.

  4. Compare with Storn & Price (1997), Sec. 2 (crossover definition and synchronous generation scheme).

Additional Information

Behavioural impact (matched configuration, 15 seeds): ~0.9 median log10 error units on shifted sphere versus a canonical implementation; verified in a systematic implementation-fidelity audit. Suggested fix: draw j_rand per individual and force that coordinate from the mutant; build all trials from the previous generation before any replacement (or document both deviations prominently as a variant). Preprint available on request; happy to open a PR.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

0