#[non_exhaustive]pub struct Config<B = Limits, O = ()> {
pub epsilon: f64,
pub dead_ends: DeadEnds,
pub seed: u64,
pub max_trial_length: usize,
pub budget: B,
pub observer: O,
pub progress_interval: Option<u64>,
pub divergence_window: usize,
}Expand description
Settings shared by all algorithms.
Build one with Config::default and the with_* methods, which swap one setting
each; Config::with_budget and Config::with_observer also change the type. The
struct is #[non_exhaustive], so new settings can be added without a breaking change;
outside this crate, the fields can be read and assigned but not listed in a struct
expression.
use stochastic_search::{Config, DeadEnds, Stats};
let config = Config::default()
.with_epsilon(1e-4)
.with_dead_ends(DeadEnds::Penalty(100.0))
.with_budget(|stats: &Stats| stats.backups >= 1_000_000);Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.epsilon: f64Convergence threshold on Bellman residuals. Must be finite and greater than zero.
Default 1e-6.
dead_ends: DeadEndsDead-end semantics. Default DeadEnds::Infinite.
seed: u64Seed of the successor sampler used by LRTDP, RTDP, BRTDP and VPI-RTDP trials (and FRTDP’s fallback trials). A seed reproduces a run exactly.
Default 0.
max_trial_length: usizeLRTDP, RTDP and the bounded algorithms cut a trial off after this many steps and start the next one.
At least 1.
Guards against trials that circle a dead-end trap forever. Default 10_000.
budget: BStops a run early. Default Limits::DEFAULT (10^8 backups, 10^6 stored states,
about 250 MB for typical states), which is finite, so a run with the default
configuration always returns. Raise a cap with
Config::default().with_budget(Limits { max_states: Some(n), ..Limits::DEFAULT });
Limits documents the memory per stored state.
observer: OReceives Events during the run. Default (), which ignores them
at no cost.
progress_interval: Option<u64>Emit Event::Progress every this many backups. None
never emits it. Default Some(1_000_000); ignored by the default observer.
divergence_window: usizeThe number of consecutive LRTDP or RTDP trials (iLAO* passes, LAO* expansion steps) over which
Event::SuspectedDivergence looks for steady
growth of the initial value. At least 1. Default 16; ignored by the default
observer.
Implementations§
Source§impl<B, O> Config<B, O>
impl<B, O> Config<B, O>
Sourcepub fn with_epsilon(self, epsilon: f64) -> Self
pub fn with_epsilon(self, epsilon: f64) -> Self
Returns the same configuration with another Config::epsilon.
Sourcepub fn with_dead_ends(self, dead_ends: DeadEnds) -> Self
pub fn with_dead_ends(self, dead_ends: DeadEnds) -> Self
Returns the same configuration with other Config::dead_ends semantics.
Sourcepub fn with_seed(self, seed: u64) -> Self
pub fn with_seed(self, seed: u64) -> Self
Returns the same configuration with another Config::seed.
Sourcepub fn with_max_trial_length(self, max_trial_length: usize) -> Self
pub fn with_max_trial_length(self, max_trial_length: usize) -> Self
Returns the same configuration with another Config::max_trial_length.
Sourcepub fn with_progress_interval(self, progress_interval: Option<u64>) -> Self
pub fn with_progress_interval(self, progress_interval: Option<u64>) -> Self
Returns the same configuration with another Config::progress_interval.
Sourcepub fn with_divergence_window(self, divergence_window: usize) -> Self
pub fn with_divergence_window(self, divergence_window: usize) -> Self
Returns the same configuration with another Config::divergence_window.
Sourcepub fn with_budget<B2: Budget<Stats>>(self, budget: B2) -> Config<B2, O>
pub fn with_budget<B2: Budget<Stats>>(self, budget: B2) -> Config<B2, O>
Returns the same configuration with another budget.
Sourcepub fn with_observer<O2: Observer>(self, observer: O2) -> Config<B, O2>
pub fn with_observer<O2: Observer>(self, observer: O2) -> Config<B, O2>
Returns the same configuration with another observer.