pub struct CheckpointManager<R: Runtime> { /* private fields */ }Expand description
Manages checkpoints for adjoint sensitivity computation.
During forward integration, checkpoints are stored at strategic times. During backward adjoint integration, the forward solution is reconstructed by reintegrating between checkpoints as needed.
Implementations§
Source§impl<R: Runtime> CheckpointManager<R>
impl<R: Runtime> CheckpointManager<R>
Sourcepub fn new(
n_checkpoints: usize,
strategy: CheckpointStrategy,
t_span: [f64; 2],
) -> Self
pub fn new( n_checkpoints: usize, strategy: CheckpointStrategy, t_span: [f64; 2], ) -> Self
Create a new checkpoint manager.
§Arguments
n_checkpoints- Number of checkpoints to store (excluding t0 and T)strategy- Strategy for placing checkpointst_span- Integration interval [t0, T]
Sourcepub fn checkpoint_times(&self) -> &[f64]
pub fn checkpoint_times(&self) -> &[f64]
Get the planned checkpoint times.
Sourcepub fn add_checkpoint(&mut self, t: f64, y: Tensor<R>)
pub fn add_checkpoint(&mut self, t: f64, y: Tensor<R>)
Add a checkpoint at the given time and state.
Sourcepub fn checkpoints(&self) -> &[Checkpoint<R>]
pub fn checkpoints(&self) -> &[Checkpoint<R>]
Get all stored checkpoints.
Sourcepub fn find_interval(&self, t: f64) -> Option<(usize, usize)>
pub fn find_interval(&self, t: f64) -> Option<(usize, usize)>
Find the checkpoint interval containing time t.
Returns (checkpoint_before, checkpoint_after) where checkpoint_before.t <= t <= checkpoint_after.t
For backward adjoint integration, we need the checkpoint just before the current time to start reintegrating from.
Sourcepub fn get(&self, index: usize) -> Option<&Checkpoint<R>>
pub fn get(&self, index: usize) -> Option<&Checkpoint<R>>
Get checkpoint at index.
Sourcepub fn iter_reverse(&self) -> impl Iterator<Item = &Checkpoint<R>>
pub fn iter_reverse(&self) -> impl Iterator<Item = &Checkpoint<R>>
Iterate checkpoints in reverse order (for backward pass).
Sourcepub fn should_checkpoint(&self, t: f64, tol: f64) -> bool
pub fn should_checkpoint(&self, t: f64, tol: f64) -> bool
Check if a time is close to a planned checkpoint time.
Trait Implementations§
Source§impl<R: Clone + Runtime> Clone for CheckpointManager<R>
impl<R: Clone + Runtime> Clone for CheckpointManager<R>
Source§fn clone(&self) -> CheckpointManager<R>
fn clone(&self) -> CheckpointManager<R>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl<R> Freeze for CheckpointManager<R>
impl<R> RefUnwindSafe for CheckpointManager<R>
impl<R> Send for CheckpointManager<R>
impl<R> Sync for CheckpointManager<R>
impl<R> Unpin for CheckpointManager<R>
impl<R> UnwindSafe for CheckpointManager<R>
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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
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 moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.