Skip to content

Conversation

@francastagna
Copy link
Collaborator

@francastagna francastagna commented Oct 21, 2025

PR Summary

We implemented changes to AbstractGeneticAlgorithmandMonotonicGeneticAlgorithm`:

  • Lifecycle hooks: generation/step observer callbacks to trace GA execution.
  • Monotonic GA: enforces pair-wise monotonic replacement and starts each generation from elites.

Main Changes

  • Base GA (AbstractGeneticAlgorithm):
    • Added lifecycle methods: beginGeneration, endGeneration, beginStep, endStep.
    • Observer API: onGenerationStart, onStepStart, onStepEnd, onGenerationEnd(population, bestScore).
    • score function: now always uses frozenTargets when present; falls back to combined fitness if empty.
  • MonotonicGeneticAlgorithm:
    • Starts next population with elites (formTheNextPopulation).
    • Uses the same lifecycle hooks as the base GA.
  • GA Recorder/Observer:
    • Introduces observer hooks to record lifecycle and operator metrics.
    • Records bestFitnessPerGeneration using the emitted bestScore (max score of the generation).

Tests

  • Monotonic GA tests added:
    • Elites + Monotonic replacement (pairwise strict improvement using score).
    • Edge cases: xoverProbability = 0 (no crossovers) and fixedRateMutation = 0 (no mutations).
    • Monotonicity across generations: assert non‑decreasing bestFitnessPerGeneration (generation score).

@francastagna francastagna changed the title MonotonicGA MonotonicGA & Lifecycle Hooks Oct 21, 2025
@francastagna francastagna requested a review from arcuri82 October 21, 2025 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant