pub struct GridSampler { /* private fields */ }Expand description
Exhaustive search over a caller-provided discrete grid.
Unlike crate::RandomSampler, which can sample continuous distributions
directly, GridSampler only makes sense for parameters with a finite,
pre-specified set of values — you must register each parameter’s grid up
front with GridSampler::add_grid (or the typed helpers). The trials are
enumerated as a mixed-radix odometer over the registered grids: trial n
maps deterministically to one point in the Cartesian product, in the order
the grids were added.
Notes / limitations:
- Because this is define-by-run, a given trial may not request every registered parameter (conditional spaces). Enumeration still ranges over the full product; unused coordinates simply don’t get read that trial.
- If more trials are run than there are grid points, the odometer wraps
(trial
nuses combinationn % total). - A parameter that is suggested but was never registered has no grid to draw from, so it falls back to a random draw (seeded, for reproducibility) and is documented as such rather than silently returning a constant.
Implementations§
Source§impl GridSampler
impl GridSampler
Sourcepub fn add_grid(self, name: &str, values: Vec<Value>) -> Self
pub fn add_grid(self, name: &str, values: Vec<Value>) -> Self
Register a parameter’s grid of explicit values. Order of registration defines the odometer axis order.
Sourcepub fn add_float_grid(self, name: &str, values: &[f64]) -> Self
pub fn add_float_grid(self, name: &str, values: &[f64]) -> Self
Register a float-valued grid.
Sourcepub fn add_int_grid(self, name: &str, values: &[i64]) -> Self
pub fn add_int_grid(self, name: &str, values: &[i64]) -> Self
Register an integer-valued grid.
Sourcepub fn add_categorical_grid(self, name: &str, values: &[&str]) -> Self
pub fn add_categorical_grid(self, name: &str, values: &[&str]) -> Self
Register a categorical grid.
Trait Implementations§
Source§impl Default for GridSampler
impl Default for GridSampler
Source§impl Sampler for GridSampler
impl Sampler for GridSampler
fn suggest( &mut self, _study_state: &StudyState, trial: &Trial, param_name: &str, distribution: &Distribution, ) -> Value
Auto Trait Implementations§
impl Freeze for GridSampler
impl RefUnwindSafe for GridSampler
impl Send for GridSampler
impl Sync for GridSampler
impl Unpin for GridSampler
impl UnsafeUnpin for GridSampler
impl UnwindSafe for GridSampler
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more