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.
Locations — src/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).
Severity: Medium (performance)
leaf_value_at_pathandreplace_leaf_valuesre-validate the entire candidate on every call, making per-leaf traversal O(L²) — in exactly the hot loops that iterate per leaf.Locations —
src/variopt/spaces/composites/tuple_space.py:231,record_space.py:257,array_space.py:252,permutation.py:200,229,scalar.py:267Scenario
CSA uniform crossover (
csa/operators/crossover.py:68) callsleaf_value_at_pathonce 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, andactive_leaf_pathsre-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=Truefast path to skip redundant re-validation on candidates already known-valid).