pub struct SimulationResult<T: Clone> {
pub outputs: Vec<T>,
pub n_paths: usize,
pub n_steps: usize,
}Expand description
Result of a batch simulation.
Outputs are stored in structure-of-arrays layout.
Each path has n_steps + 1 entries: the initial state plus n_steps steps.
Access via: outputs[path_idx * (n_steps + 1) + entry]
Prefer the accessor methods (get, path, path_steps, terminal,
all_outputs) over computing SOA offsets manually.
Fields§
§outputs: Vec<T>All path outputs, SOA layout.
The flat slice is indexed as path_idx * (n_steps + 1) + entry,
where entry 0 is the initial state and entry n_steps is the final.
For path-agnostic iteration over every output, use all_outputs().
n_paths: usizeNumber of paths.
n_steps: usizeNumber of steps per path. Total entries per path = n_steps + 1.
Implementations§
Source§impl<T: Clone> SimulationResult<T>
impl<T: Clone> SimulationResult<T>
Sourcepub fn get(&self, path_idx: usize, entry: usize) -> Option<&T>
pub fn get(&self, path_idx: usize, entry: usize) -> Option<&T>
Get the output at a specific (path_idx, entry) where entry 0 is
the initial state and entry = n_steps is the final state.
Sourcepub fn path(&self, path_idx: usize) -> Option<&[T]>
pub fn path(&self, path_idx: usize) -> Option<&[T]>
Get all outputs for a specific path (includes initial state).
Sourcepub fn path_steps(&self, path_idx: usize) -> Option<&[T]>
pub fn path_steps(&self, path_idx: usize) -> Option<&[T]>
Get only the step outputs for a specific path (excludes initial state).
Sourcepub fn terminal(&self, path_idx: usize) -> Option<&T>
pub fn terminal(&self, path_idx: usize) -> Option<&T>
Get the final output for a specific path.
Sourcepub fn all_outputs(&self) -> &[T]
pub fn all_outputs(&self) -> &[T]
Flat access to all outputs for iteration without path-awareness.
Use this when you need to iterate over every output (e.g. checking
positivity, collecting statistics). Equivalent to reading
self.outputs but safe against accidental offset computation.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for SimulationResult<T>
impl<T> RefUnwindSafe for SimulationResult<T>where
T: RefUnwindSafe,
impl<T> Send for SimulationResult<T>where
T: Send,
impl<T> Sync for SimulationResult<T>where
T: Sync,
impl<T> Unpin for SimulationResult<T>where
T: Unpin,
impl<T> UnsafeUnpin for SimulationResult<T>
impl<T> UnwindSafe for SimulationResult<T>where
T: UnwindSafe,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more