Skip to content

fix(strategies): refuse to tighten dynamic bounds on zero-range batch#4

Open
GrigoryEvko wants to merge 1 commit into
FusionBrainLab:mainfrom
GrigoryEvko:fix/dynamic-bound-single-elite-collapse
Open

fix(strategies): refuse to tighten dynamic bounds on zero-range batch#4
GrigoryEvko wants to merge 1 commit into
FusionBrainLab:mainfrom
GrigoryEvko:fix/dynamic-bound-single-elite-collapse

Conversation

@GrigoryEvko
Copy link
Copy Markdown

A zero-range batch (single sample, or all-equal samples) collapses the dimension. _calculate_margin(0) falls back to 1e-5, so for one elite with speedup=0.964 against initial bounds [0, 100], the bins become [0.96399, 0.96401] — a 2×10⁻⁵ window across 10 bins, five orders of magnitude tighter. Subsequent optimize_space calls with still-narrow batches re-collapse on every pass. Matches the [0.000, 100.000] -> [0.964, 0.964] log line in single-elite runs.

Reproducer against current main:

from gigaevo.evolution.strategies.models import DynamicBehaviorSpace, LinearBinning

space = DynamicBehaviorSpace(
    bins={"x": LinearBinning(min_val=0.0, max_val=100.0, num_bins=10)},
    expansion_buffer_ratio=0.1,
)
print(space.calculate_optimized_bounds([{"x": 0.964}]))
# before fix: {'x': (0.96399, 0.96401)}
# after fix:  {'x': (0.0, 100.0)}

Fix: when value_range == 0, return the strategy's current bounds unchanged. Two pre-existing tests (test_batch_optimize_single_point, test_single_point_batch) encoded the collapsed bounds as expected output and are updated.

A single sample (or all-equal batch) has `obs_min == obs_max`, so `_calculate_bounds_for_batch` falls through to the `1e-5` margin fallback and collapses the dimension to a ~2e-5 window. The initial-bounds clamp then prevents re-expansion once samples diversify — MAP-Elites resolution is permanently destroyed on that axis. Return strategy.min_val/max_val unchanged in that case.

Two pre-existing tests encoded the collapsed bounds as expected output and are updated.
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