Skip to content

Add pluggable Threshold-Elites and Dominated Novelty Search (DNS) database variants alongside MAP-Elites#416

Open
fangyihao wants to merge 1 commit intoalgorithmicsuperintelligence:mainfrom
fangyihao:feat-threshold-elites-and-dns
Open

Add pluggable Threshold-Elites and Dominated Novelty Search (DNS) database variants alongside MAP-Elites#416
fangyihao wants to merge 1 commit intoalgorithmicsuperintelligence:mainfrom
fangyihao:feat-threshold-elites-and-dns

Conversation

@fangyihao
Copy link

Summary

This change makes the program database implementation configurable at runtime and introduces two new database strategies—DNSProgramDatabase and ThresholdElitesProgramDatabase—while tightening several multi-island correctness edge cases (copy embedding, infinite-score handling). It also adds dedicated unit tests for both new database variants.

What changed

openevolve/config.py

  • Extended DatabaseConfig with:

    • variant: str = "DNSProgramDatabase" to select the database implementation by class name.

    • distance_threshold: float = 1.5 (used by the threshold-based elite filtering).

openevolve/controller.py

  • Switched database construction from a fixed ProgramDatabase(...) to dynamic instantiation:

    • Reads config.database.variant (defaults to "ProgramDatabase" if missing).

    • Uses importlib to load openevolve.database. and instantiate it.

  • This enables selecting different database behaviors via config without changing code.

openevolve/database.py

General robustness fixes

  • Import copy and math.

  • _update_best_program: avoid comparing / logging combined_score when either side is ±inf (prevents misleading “best program changed” logs and edge-case issues).

  • When seeding/initializing empty islands via copying the best program, the copied program now deep-copies embedding to avoid shared references across programs/islands.

  • get_island_stats: filters out ±inf scores before computing best_score / avg_score for cleaner island stats.

New database variants

  • ThresholdElitesProgramDatabase

    • Computes feature embedding + fitness-derived combined_score.

    • Runs novelty gating via existing _is_novel.

    • Applies a distance-threshold competition inside an island:

      • For programs within distance_threshold, the lower-scoring one gets combined_score = -inf (effectively removed from competition).
  • DNSProgramDatabase

    • Implements Dominated Novelty Search-style selection:

      • For each program, considers the set of dominating programs (higher combined_score).

      • Computes dominated novelty score as mean distance to those dominating programs (or +inf if none dominate).

      • Uses the median dominated novelty score as a cutoff; programs below the median get combined_score = -inf.

    • Keeps island assignment consistent and respects novelty gating before DNS filtering.

Tests

Added two new test suites:

  • tests/test_dns_database.py

  • tests/test_threshold_elites_database.py

These validate:

  • Multi-island initialization (correct island counts, per-island best tracking).

  • Targeted island insertion + metadata["island"] correctness.

  • Migration behavior: no migrant suffix IDs and migrants don’t get re-migrated.

  • Empty-island sampling creates copies (not shared references) and passes validation.

  • No program is ever assigned to multiple islands.

  • Migration validation remains stable across multiple migration cycles (prevents exponential “migrant” growth).

How to use

Set in config:

  • database.variant = "DNSProgramDatabase" (default in this diff)

  • or database.variant = "ThresholdElitesProgramDatabase"

  • optionally tune database.distance_threshold for the Threshold-Elites behavior.

Testing

  • Added unit tests for both variants (DNS + Threshold-Elites).

  • Existing database test base class is reused to ensure behavior parity where intended.

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