pub struct OptimizeBlock {
pub method: String,
pub objective: String,
pub servo: Vec<String>,
pub max_evals: usize,
pub seed: u64,
pub params: HashMap<String, f64>,
}Expand description
SRD-86 — a phase optimize: block. The optimizer maximizes the
objective wire by writing the axes input wires on the phase kernel.
Fields§
§method: StringRegistered optimizer name (cmaes, nelder_mead, … — see
nmbrs describe optimizers). Defaults to sweep (the identity: evaluate
every coordinate and report the best), so a plain “find the best by
sweeping” search omits this field; set an adaptive method to search a
large or continuous space without enumerating it.
objective: StringThe objective the optimizer maximizes (SRD-86 §10). Two forms:
a bare wire reference — a single identifier naming a phase-kernel
output (a bindings: entry), read directly; or an inline polydat
expression (anything with operators / calls, e.g.
objective: "0 - metricsql_scalar(\"sum(rate(errors_total[3s]))\")"),
which is lowered to a synthesized __objective binding on the phase
kernel (scope::objective_wire) so no separate bindings: entry is
needed. An objective reading a windowed/live metric settles per setting;
a deterministic one takes the one-shot read.
servo: Vec<String>Search axes to actuate as live controls — servoed (retargeted without
restarting the phase) rather than stepped through by re-running the phase
(SRD-86 §4). Every axis is a coordinate (step-through / re-run) by default;
naming one here opts it into servoing. Accepts a single name (servo: concurrency) or a list (servo: [concurrency, rate]). A servoed var
resolves to a control either directly (its name IS a control — servo: concurrency / servo: rate) or indirectly (it feeds one via a {var}
bind — concurrency: "{conc}", then servo: conc). It is validated: it
must resolve to a control AND the objective must be a windowed metric the
servo can settle — else a clear error, never a silent downgrade.
max_evals: usize§seed: u64§params: HashMap<String, f64>Optimizer-specific knobs (e.g. { lambda: 8 }).
Implementations§
Source§impl OptimizeBlock
impl OptimizeBlock
Sourcepub fn from_yaml_value(v: &Value) -> Result<OptimizeBlock, Error>
pub fn from_yaml_value(v: &Value) -> Result<OptimizeBlock, Error>
Parse a phase optimize: value from already-parsed JSON, applying the
string sugar (a bare string ≡ { objective: <string> }). Used by the
hand-rolled phase parser, which builds WorkloadPhase field-by-field
rather than through the derive (so it doesn’t see [de_optimize]).
Branches explicitly rather than going through the untagged
[OptimizeSpec] so a malformed map keeps its precise serde error
(e.g. missing field 'objective') instead of the untagged enum’s
generic “did not match any variant”.