Skip to content

[Medium] Clearing-GA diverse backfill recomputes distances from scratch instead of incrementally #40

Description

@gratus907

Severity: Medium (performance)

Clearing-GA's diversity-based survival step recomputes distances from scratch on every farthest-point selection iteration instead of maintaining a running minimum, making it O(count × overflow × anchors) metric calls per generation.

Locationsrc/variopt/algorithms/population/clearing_ga/optimizer.py:528-582

_clearing_occupancy performs O(pool × selected) Python-level diversity_metric.distance calls, and _build_diverse_backfill recomputes _minimum_distance_to_population against the full anchor set from scratch on every farthest-point iteration — even though the anchor set only grows by exactly one member per backfill iteration.

Scenario

population_size=200 → pool of 400; a single generation triggers on the order of 10^5-10^6 metric calls, even though classic incremental farthest-point selection would need far fewer.

Fix direction

Cache each overflow member's running minimum distance and update it only against the newly chosen anchor each iteration (classic incremental farthest-point selection), rather than recomputing against the full anchor set. Optionally cache pairwise distances computed during clearing for reuse in backfill.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions