Expand description
Convenience weighted output selection nodes.
These are “fat” convenience nodes that combine alias sampling with value lookup in one step. They parse an inline spec string at init time and perform weighted selection at cycle time.
WeightedStrings/WeightedU64— the spec parser runs once at construction via a#[poly_const]setup function, producing a derivedWeightedStrCache/WeightedU64Cache(parallel value+alias-table). The eval body does a constant-time lookup.WeightedPick— the same spec-string surface asweighted_u64:weighted_pick(input, "v0:w0;v1:w1;..."). Thecompiled_u64/jit_constantsoverrides feed the JIT extern (jit_weighted_pick), which reads a 5-u64 (values_ptr, biases_ptr, primaries_ptr, aliases_ptr, n) constants slice.DynamicWeightedSelect— takes its spec on aConfig<T>wire (the Wire trait’sWIRE_COST = Configconst flows throughConfig<Arc<str>>to the slot’sWireCost::Configannotation, so the compiler warns when the spec is bound to a cycle-time source). The evaluating kernel state memoizes the last spec parsed and its alias table in its own scratch, so repeated evaluations with the same spec do no parsing; only a spec change re-parses.
Structs§
- Dynamic
Weighted Memo - The memo
DynamicWeightedSelectkeeps per kernel state: the last spec it parsed, with the value list and alias table built from it.tableisNonewhen the spec named no values. - Dynamic
Weighted Select - Dynamic weighted selection where the weight spec is a wire input.
- Weighted
Pick - The
weighted_picknode. - Weighted
Pick State - Derived state for
WeightedPick: parsed values, weights, and the alias table, built once at construction from the spec string and read on every cycle (both in the eval path and the compiled closure).weightsis retained alongsidevaluessoFusedNode::decomposedcan reconstruct the equivalentweighted_u64spec string. - Weighted
StrCache - Derived state for
WeightedStrings: the parsed value list and the alias table, computed once at construction from the spec string and read on every cycle. - Weighted
Strings - Weighted string selection from an inline spec.
- Weighted
U64 - Weighted u64 selection from an inline spec.
- Weighted
U64Cache - Derived state for
WeightedU64: the parsed value list and the alias table, computed once at construction from the spec string and read on every cycle.