Skip to content

[Medium] leaf_value_at_path / replace_leaf_values re-validate the whole candidate per call (O(L^2)) #32

Description

@gratus907

Severity: Medium (performance)

leaf_value_at_path and replace_leaf_values re-validate the entire candidate on every call, making per-leaf traversal O(L²) — in exactly the hot loops that iterate per leaf.

Locationssrc/variopt/spaces/composites/tuple_space.py:231, record_space.py:257, array_space.py:252, permutation.py:200,229, scalar.py:267

Scenario

CSA uniform crossover (csa/operators/crossover.py:68) calls leaf_value_at_path once per editable path — for a 100-leaf space that's ~100 full-candidate validations (each O(100)) per offspring per generation. Structured local search (local_search/structured/runtime/search.py:62,134,192) has the same shape, and active_leaf_paths re-validates yet again (structured.py:221).

Fix direction

Validate once at the operation boundary and traverse leaves via internal unvalidated accessors (or add a validated=True fast path to skip redundant re-validation on candidates already known-valid).

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