Skip to main content

Config

Struct Config 

Source
#[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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§epsilon: f64

Convergence threshold on Bellman residuals. Must be finite and greater than zero.

Default 1e-6.

§dead_ends: DeadEnds

Dead-end semantics. Default DeadEnds::Infinite.

§seed: u64

Seed 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: usize

LRTDP, 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: B

Stops 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: O

Receives 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: usize

The 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>

Source

pub fn with_epsilon(self, epsilon: f64) -> Self

Returns the same configuration with another Config::epsilon.

Source

pub fn with_dead_ends(self, dead_ends: DeadEnds) -> Self

Returns the same configuration with other Config::dead_ends semantics.

Source

pub fn with_seed(self, seed: u64) -> Self

Returns the same configuration with another Config::seed.

Source

pub fn with_max_trial_length(self, max_trial_length: usize) -> Self

Returns the same configuration with another Config::max_trial_length.

Source

pub fn with_progress_interval(self, progress_interval: Option<u64>) -> Self

Returns the same configuration with another Config::progress_interval.

Source

pub fn with_divergence_window(self, divergence_window: usize) -> Self

Returns the same configuration with another Config::divergence_window.

Source

pub fn with_budget<B2: Budget<Stats>>(self, budget: B2) -> Config<B2, O>

Returns the same configuration with another budget.

Source

pub fn with_observer<O2: Observer>(self, observer: O2) -> Config<B, O2>

Returns the same configuration with another observer.

Trait Implementations§

Source§

impl<B: Clone, O: Clone> Clone for Config<B, O>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<B: Copy, O: Copy> Copy for Config<B, O>

Source§

impl<B: Debug, O: Debug> Debug for Config<B, O>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Config

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<B, O> From<Config<B, O>> for BrtdpConfig<B, O>

Source§

fn from(base: Config<B, O>) -> Self

Converts to this type from the input type.
Source§

impl<B, O> From<Config<B, O>> for FrtdpConfig<B, O>

Source§

fn from(base: Config<B, O>) -> Self

Converts to this type from the input type.
Source§

impl<B, O> From<Config<B, O>> for VpiRtdpConfig<B, O>

Source§

fn from(base: Config<B, O>) -> Self

Converts to this type from the input type.
Source§

impl<B: PartialEq, O: PartialEq> PartialEq for Config<B, O>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<B: PartialEq, O: PartialEq> StructuralPartialEq for Config<B, O>

Auto Trait Implementations§

§

impl<B, O> Forget for Config<B, O>

§

impl<B, O> Freeze for Config<B, O>
where B: Freeze, O: Freeze,

§

impl<B, O> Move for Config<B, O>

§

impl<B, O> RefUnwindSafe for Config<B, O>

§

impl<B, O> Send for Config<B, O>
where O: Send, B: Send,

§

impl<B, O> Sync for Config<B, O>
where O: Sync, B: Sync,

§

impl<B, O> Unpin for Config<B, O>
where O: Unpin, B: Unpin,

§

impl<B, O> UnsafeUnpin for Config<B, O>
where B: UnsafeUnpin, O: UnsafeUnpin,

§

impl<B, O> UnwindSafe for Config<B, O>
where B: UnwindSafe, O: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.