Strategies Module#
Available optimization strategies:
StrategyBase: Abstract base class for all strategies
StrategyRoundRobin: Simple round-robin point evaluation
StrategyRewarding: Adaptive heuristic selection based on performance (softmax multi-armed bandit)
StrategyUCB: Upper Confidence Bound (UCB1) algorithm for principled exploration/exploitation
StrategyThompsonSampling: Probabilistic selection using Thompson Sampling (Beta-Bernoulli bandit)
StrategyLinUCB: Contextual bandit using disjoint linear UCB models over budget-progress / success-rate features
StrategyPhased: Budget-phased meta-strategy composing different sub-strategies and heuristic portfolios across phases
StrategyBlockBandit: Hands a whole block of evaluations to one arm and scores it by the AOCC area it bought (experimental)
Regime gating in StrategyBlockBandit#
StrategyBlockBandit(regime_gate=...) switches arms off by regime.
The regime is four things — the noise class (clean / bounded /
outlier), the dimension, the budget per dimension and whether the
problem is constrained — looked up, first match wins, in the versioned
REGIME_TABLE_V1; every row cites the
12-seed section of planning/DISCOVERY_2026-09-09.md behind it. The
rows say: outliers → CMA-ES alone; constrained → jSO alone; bounded noise
at d ≤ 5 and budgets ≤ 200·dim → the CMA-ES + jSO sharing
portfolio; d ≥ 10 and everything else → CMA-ES alone.
regime_gate="oracle:<class>" takes the noise class as given (the
benchmark harness knows it; see Benchmarking and the Composite Score).
regime_gate="dim-budget" needs no oracle: it applies only the rows
keyed on the dimension and the budget, and only while the parallel
workers do not exceed the kept arms’ serial generation size (λ_default for
CMA-ES). On the current table that is: unconstrained, d ≥ 10,
≤ 500·dim, at most λ_default workers → CMA-ES alone; everything else is
left ungated. The benchmark harness’s headline spec
Blocks_warm_CMAES_JSO runs with it since planning/DISCOVERY_2026-09-09.md
§73 (a fresh-seed confirmation of §72); StrategyBlockBandit itself
still defaults to regime_gate=None. "table-v1", the in-run
noise probe of planning/DESIGN_regime_gating_2026-09-11.md §1, raises
NotImplementedError until the oracle has cleared its battery.
StrategyBlockBandit(first_round_fill=True) fills, before the first
result arrives, the workers the owning arm leaves idle: first with the
other arms’ queued points, then with one Latin hypercube over the box. It
only acts under a request cap (the virtual clock’s async policy or a real
pull-mode pool) and only while the arms’ first generations are smaller than
the worker count, e.g. at d = 2, 200 evaluations, 64 workers (§72).
Two contracts worth knowing. Every arm is always constructed, gate or
no gate, so the run holds the same modules in the same event-bus order
either way (module RNG streams are keyed by name, so building an arm or not
would not shift another module’s stream). The gate is a per-arm enabled bit read at one
place, the ready list of block selection, plus a filtered prologue —
regime_gate=None is byte-identical to a run without the feature, and a
gate that enables every arm is byte-identical to None. And a disabled
arm is a paused arm: it keeps receiving results and topping its queue
up, so “CMA-ES alone via the gate” is deterministic but not guaranteed
byte-identical to StrategyRoundRobin with CMA-ES (measured, it was:
all 276 runs the gate reduced to CMA-ES on the 12-seed cauchy, standard
and d = 10 batteries matched CMAES_alone bit for bit). The alternative — a gate that
picks between two pre-built strategies — is not implementable: one
strategy owns the run (the event bus, the analyzers and the evaluator are
built once and start is published once), so it is not re-proposed.
Strategies#
This part outlines the coordination between the point-producing
heuristics, the interaction with the cluster and the
DB of evaluated points.
Basically, one or more threads produce points where to search,
and another one consumes them and dispatches tasks.
Subclass the StrategyBase class to implement
a new strategy.
- class panobbgo.strategies.StrategyBlockBandit(problem, *, n_blocks: int = 50, block_evals: int | str | None = None, size: int = 10, policy: str = 'ducb', gamma: float = 0.9, ucb_c: float = 0.5, tail_frac: float = 0.25, decades: float = 2.0, reward: str = 'area', prior: str = 'none', warm_start_on_resume: bool = False, warm_start_k: int = 10, warm_start_only_if_foreign: bool = True, warm_start_only_if_better: bool = False, hysteresis: float = 1.2, regime_gate: str | None = None, first_round_fill: bool = False, **kwargs: Any)[source]#
Bases:
StrategyBaseHand a whole block of evaluations to one heuristic, then score that block by the AOCC area it bought and let a discounted UCB rule pick the owner of the next one.
- Parameters:
n_blocks – number of blocks the budget is cut into (the number of decisions, held constant across dimension and budget).
block_evals – explicit block size, or
"auto"formax(2*dim, 4*lambda_ref)— four reference generations, the parametrisationplanning/DISCOVERY_2026-09-09.md§26 points at. Either form overridesn_blocks.size – points requested per main-loop pass, exactly
StrategyRoundRobin’ssize. With a single arm this makes the two strategies emit the identical evaluation sequence.policy –
"ducb"(discounted UCB) or"uniform"(round-robin over blocks, no learning).gamma – discount of the per-arm statistics at each block close.
ucb_c – exploration weight;
0in the tail.tail_frac – fraction of the budget that is exploit-only.
decades – log-precision decades that earn the full reward.
reward –
"area"(anytime, default) or"endpoint".prior –
"none";"dim"(per-dimension priors from the evaluation battery) is not implemented yet.warm_start_on_resume – warm-start an arm that is re-acquired after a gap — via its
warm_start(results)method if it has one, else viawarm_start_now(). Its stale queue is cleared first.warm_start_k – how many results a
warm_start(results)offer carries, and the depth of thewarm_start_only_if_foreigntest (warm_start_nowarms query theArchivethemselves).warm_start_only_if_foreign – skip the warm start when every one of the top-k results is the arm’s own — re-seeding an arm from itself buys nothing and costs its in-flight generation.
warm_start_only_if_better – skip the warm start unless the archive’s best penalty value beats the arm’s own best. The sharper of the two guards on paper, but it measured slightly negative on the 12-seed roster (-0.007, §30), so it is off by default; available as an opt-in, and it composes with the foreign guard.
hysteresis – a challenger must beat the incumbent by this factor.
regime_gate –
None(default) — no gate, today’s behaviour, byte-identical to a run without the feature."oracle:<class>"withclassinNOISE_CLASSES— take the noise class as given (the benchmark harness knows it; a library user does not), read the dimension, the budget per dimension and the constrained flag at the firstexecute(), look the four up inREGIME_TABLE_V1and disable every arm the matching row does not name."table-v1"— the in-run noise probe of design §1 — is not built yet and raisesNotImplementedError; it is step 3 of the design’s plan and only worth building if the oracle clears the §4 battery. Anything else is aValueError.If the row names roles the strategy has no arm for, whatever does match is enabled; if nothing matches at all the mask is left fully enabled and a warning is logged — the gate must never silently switch every arm off. The decision is logged at INFO and kept in
regime_decision."dim-budget"(DIM_BUDGET_GATE, DISCOVERY §72) is the gate without the oracle: only what is known before the first evaluation. It looks the table up as for a noiseless run and applies the row only if it is a dimension / budget row (is_dim_budget_row()), every arm plays a role the table names, and the parallel workers do not exceed the kept arms’ serial generation size; otherwise nothing is disabled. OnREGIME_TABLE_V1that is: unconstrained,dim >= 10,bpd <= 500, at most λ_default workers → CMA-ES alone (see_apply_dim_budget_gate()).first_round_fill – before the first result arrives, fill the workers the owner leaves idle — first with the other enabled arms’ queued points (no block switch, no warm start), then with one Latin hypercube over the box, sized to the workers idle at that moment (
who=INITIAL_DESIGN_WHO, no arm is credited). Only under a request cap (the virtual clock’s async policy, or a real pull-mode pool) and only while the arms’ first generations are smaller than the worker count; everywhere else a run is bit-identical toFalse. DISCOVERY §72: at d = 2, 100·d, q = 64 CMA-ES (λ capped at 20) and jSO (NP 6) fill 26 of 64 workers until the first results return, the idle start that made the d2/q64 Holm loss to qLogEI. The design’s results land in the open (prologue) block’s trace, so that block’s reward includes their progress; underpolicy="uniform"rewards decide nothing. A run that starts with results (a resume,preload_results) is past its first round and never fills.
@type problem: panobbgo.lib.Problem @param problem: @param parse_args: @param testing_mode: @param kwargs: Additional configuration parameters (e.g. max_eval, max_evaluations)
- GENERATION_ATTRS: Tuple[str, ...] = ('_lam', '_NP_current', 'NP_init', 'NP')#
Attributes an arm may expose to report its generation size, best first. CMA-ES sets
_laminon_start(and again after every IPOP restart); the L-SHADE family carries the LPSR-shrunk_NP_currentalongside the constructor’sNP_init; PSO and the plain DE useNP._lamis the raised λ when CMA-ES’s worker floor binds (popsize_min_workers, DISCOVERY §63), soblock_evals="auto"then means four generations of the size actually dispatched, not of the serial λ (CMAES._serial_lam). Deliberate: a block should not cut a generation, whatever its size. Not measured — the §63 specs usen_blocks, not"auto".
- INITIAL_DESIGN_WHO: str = 'initial_design'#
whoof the first-round design’s points. No arm has this name, so no arm is credited with them (_credit_arm_best()) and none ranks them as its own offspring; they reach every arm through the shared archive, i.e. through the warm starts.
- LAMBDA_REF_DEFAULT: int = 5#
Fallback generation size when no arm reports one — the ~20-evaluation block
planning/DISCOVERY_2026-09-09.md§26 measured, over 4.
- add_heuristic(h: Heuristic) None[source]#
Add a heuristic to the strategy.
- Parameters:
h (Heuristic) – The heuristic instance to add
- property block_evals: int#
Evaluations per block, resolved lazily on first use.
Both forms need state that does not exist at construction time: the budget is regularly assigned afterwards (
s.config.max_eval = ...) and"auto"needs the arms, whose generation sizes are only known once they have handledon_start. First access is fromexecute(), by which time both hold.
- on_meta_region(arm: Any = None, box: Any = None, **_: Any) None[source]#
Record a region request from
MetaAnalyst; do not act on it.planning/DESIGN_meta_level_2026-09-10.md§2: this runs on the event-bus dispatcher thread whileexecute()runs on the main loop’s.warm_start_nowclears the arm’s output queue, whichexecutemay be draining at that instant, so the mutation is deferred to_open_block()— where it also reuses the scheduler’s existing, tested warm-start path verbatim.A second request for the same arm before the first was applied simply replaces it: the newer analysis is the better one.
- on_new_results(results: List[Result]) None[source]#
Accumulate the running best of the open block, one entry per result.
Results arrive in batches and, under
sync_evaluation, a batch is fully handled before the nextexecute(), so the trace is a deterministic function of the schedule. The log terms themselves are only formed at_close_block(): the anchor they need does not exist until the first block ends.With asynchronous evaluation a result is credited to whichever block is open when it arrives, so the previous owner’s late results can land in the next block; the lock only keeps each result and each block switch atomic.
- class panobbgo.strategies.StrategyLinUCB(problem, linucb_alpha: float = 2.0, **kwargs)[source]#
Bases:
StrategyBaseThis strategy uses the Linear Upper Confidence Bound (LinUCB) algorithm (disjoint) to select heuristics based on context features.
Context features ($x_t$): - Bias (1.0) - Budget Progress (t / T_max) - Recent Global Success Rate (last 100 evaluations)
Model for each heuristic $a$: - $theta_a^* = argmin_{theta} sum (r_t - theta^T x_{t,a})^2 + lambda |theta|^2$ - Expected reward: $hat{r}_{t,a} = x_t^T theta_a$ - UCB Score: $p_{t,a} = hat{r}_{t,a} + alpha sqrt{x_t^T A_a^{-1} x_t}$
where $A_a = sum x_s x_s^T + I$ and $b_a = sum r_s x_s$.
@type problem: panobbgo.lib.Problem @param problem: @param parse_args: @param testing_mode: @param kwargs: Additional configuration parameters (e.g. max_eval, max_evaluations)
- add_heuristic(h)[source]#
Add a heuristic to the strategy.
- Parameters:
h (Heuristic) – The heuristic instance to add
- alpha#
Exploration weight (default 2.0 to encourage exploration). An explicit parameter: read from
**kwargsit was also forwarded to StrategyBase, which rejects keys that are not config attributes.
- class panobbgo.strategies.StrategyPhased(problem, phases, **kwargs)[source]#
Bases:
StrategyBasePhased meta-strategy that composes existing strategies across budget phases.
Each phase specifies: - A fraction of the total budget (
pct, optional on last phase) - A sub-strategy class and its kwargs for selection logic - A list of heuristic classes and their kwargsExample:
StrategyPhased(problem, phases=[ { "pct": 25, "strategy": (StrategyRoundRobin, {"size": 10}), "heuristics": [(Random, {}), (LatinHypercube, {})], }, { "strategy": (StrategyRewarding, {}), "heuristics": [(GaussianProcessHeuristic, {}), (LBFGSB, {})], }, ])
At each phase boundary, bandit/selection statistics are reset for the new phase’s heuristics, but domain state (GP models, accumulated data, etc.) is preserved.
@type problem: panobbgo.lib.Problem @param problem: @param parse_args: @param testing_mode: @param kwargs: Additional configuration parameters (e.g. max_eval, max_evaluations)
- class panobbgo.strategies.StrategyRewarding(problem, credit=None, explore=None, **kwargs)[source]#
Bases:
StrategyBaseThis strategy rewards given
heuristicsby selecting those more often, which produce better search points.Two credit-assignment modes (
credit=kwarg orconfig.rewarding_credit):"ema"(default)performanceis an exponential moving average of the reward per evaluation spent by that heuristic (reward1 - exp(-improvement)when the evaluation improves the best, else 0; smoothing1 - config.discount). Selection is probability matching over the heuristics that currently have points, with an exploration floor ofexplore(config.rewarding_explore, default 0.2) spread evenly."legacy"Every point drawn from a heuristic multiplies its
performancebyconfig.discount(0.95); a new best adds1 - exp(-improvement)to the emitter’s performance. Selection is proportional toperformance + config.smooth. This credits the emitter of the best point rather than improvement per evaluation spent, so a heuristic that emits a generation of 90 points is discounted by0.95**90at once while a one-shot heuristic keeps its weight for the whole run — the strategy degenerates to a biased round-robin (planning/DISCOVERY_2026-09-09.md §6).
Measured on the standard IOH battery (mean AOCC, 12-seed decision roster, paired per seed, same arm set):
"ema"withexplore=0.2scores +0.0135 [+0.0032, +0.0238] over"legacy"(9/12 seeds), the gain sitting at 2-D (+0.0248 [+0.0049, +0.0447]) and flat at 5-D (+0.0022 [-0.0030, +0.0074]).@type problem: panobbgo.lib.Problem @param problem: @param parse_args: @param testing_mode: @param kwargs: Additional configuration parameters (e.g. max_eval, max_evaluations)
- add_heuristic(h)[source]#
Add a heuristic to the strategy.
- Parameters:
h (Heuristic) – The heuristic instance to add
- class panobbgo.strategies.StrategyRoundRobin(problem, size=10, **kwargs)[source]#
Bases:
StrategyBaseThis is a very primitive strategy for testing purposes only. It selects the heuristics based on a fixed round-robin scheme.
@type problem: panobbgo.lib.Problem @param problem: @param parse_args: @param testing_mode: @param kwargs: Additional configuration parameters (e.g. max_eval, max_evaluations)
- class panobbgo.strategies.StrategyThompsonSampling(problem, **kwargs)[source]#
Bases:
StrategyBaseThis strategy uses Thompson Sampling (Beta-Bernoulli bandit) to select heuristics.
It maintains a Beta distribution Beta(alpha, beta) for each heuristic, representing the probability of success (finding a better point).
Update rule: - Reward r in [0, 1] derived from improvement magnitude. - alpha = 1 + total_reward (successes) - beta = 1 + total_attempts - total_reward (failures)
Selection: - Sample theta ~ Beta(alpha, beta) for each heuristic. - Select heuristic with highest theta.
@type problem: panobbgo.lib.Problem @param problem: @param parse_args: @param testing_mode: @param kwargs: Additional configuration parameters (e.g. max_eval, max_evaluations)
- add_heuristic(h)[source]#
Add a heuristic to the strategy.
- Parameters:
h (Heuristic) – The heuristic instance to add
- class panobbgo.strategies.StrategyUCB(problem, ucb_c: float = 1.414, **kwargs)[source]#
Bases:
StrategyBaseThis strategy uses the Upper Confidence Bound (UCB1) algorithm to select heuristics. It balances exploration (trying less used heuristics) and exploitation (using heuristics that have performed well).
The Multi-Armed Bandit formulation here is: - Arms: Heuristics - Pull: Generating points from a heuristic - Reward: 0 if point doesn’t improve best; >0 if it improves best.
Reward calculation: R(x) = 1 - e^{-(improvement)}.
Value Q_t(a): Average reward per point generated.
@type problem: panobbgo.lib.Problem @param problem: @param parse_args: @param testing_mode: @param kwargs: Additional configuration parameters (e.g. max_eval, max_evaluations)
- add_heuristic(h)[source]#
Add a heuristic to the strategy.
- Parameters:
h (Heuristic) – The heuristic instance to add
- on_new_best(best)[source]#
Called when a new best solution is found. Updates the reward statistics for the heuristic that generated the solution.
- reward(best)[source]#
Calculate reward for a heuristic based on the improvement.
Args: -
best: new (best) result- Returns:
Reward value in [0, 1]
- Return type:
- ucb_c#
Exploration weight
c(default ≈ √2). Was read from a config key that does not exist, soStrategyUCB(ucb_c=...)was ignored.