pub struct EarlyStopHandler {
pub threshold: F,
pub warmup: usize,
pub patience: usize,
/* private fields */
}Expand description
Requests early termination when improvement stalls.
Tracks fdist + frest total violation. After warmup iterations, if the
relative improvement drops below threshold for patience consecutive
steps, sets the stop flag.
Added as a default handler by crate::packer::Molpack::new.
Fields§
§threshold: FRelative improvement threshold.
warmup: usizeIterations to skip before tracking. Default: 5.
patience: usizeConsecutive stall iterations before stopping. Default: 3.
Implementations§
Source§impl EarlyStopHandler
impl EarlyStopHandler
pub fn new(threshold: F) -> Self
pub fn with_warmup(self, warmup: usize) -> Self
pub fn with_patience(self, patience: usize) -> Self
Trait Implementations§
Source§impl Default for EarlyStopHandler
impl Default for EarlyStopHandler
Source§impl Handler for EarlyStopHandler
impl Handler for EarlyStopHandler
Source§fn on_initialized(&mut self, _sys: &PackContext)
fn on_initialized(&mut self, _sys: &PackContext)
Called once after initialization completes, with valid
xcart positions.
Use this to write the initial conformation (e.g. XYZHandler).Source§fn on_phase_start(&mut self, _info: &PhaseInfo)
fn on_phase_start(&mut self, _info: &PhaseInfo)
Called at the start of each packing phase (per-type and all-types).
Allows stateful handlers to reset between phases.
Source§fn on_step(&mut self, info: &StepInfo, _sys: &PackContext)
fn on_step(&mut self, info: &StepInfo, _sys: &PackContext)
Called after each outer optimization loop iteration.
Source§fn should_stop(&self) -> bool
fn should_stop(&self) -> bool
Return
true to request early termination of the packing loop.Source§fn on_start(&mut self, _ntotat: usize, _ntotmol: usize)
fn on_start(&mut self, _ntotat: usize, _ntotmol: usize)
Called immediately at the start of
pack,
before any computation. Use this for immediate user feedback.Source§fn on_finish(&mut self, _sys: &PackContext)
fn on_finish(&mut self, _sys: &PackContext)
Called once after the packing loop finishes (convergence or max loops).
Source§fn on_inner_iter(&mut self, _iter: u32, _f: F, _sys: &PackContext)
fn on_inner_iter(&mut self, _iter: u32, _f: F, _sys: &PackContext)
Source§fn on_phase_end(&mut self, _info: &PhaseInfo, _report: &PhaseReport)
fn on_phase_end(&mut self, _info: &PhaseInfo, _report: &PhaseReport)
Called at the end of each packing phase, with a summary report. Read more
Auto Trait Implementations§
impl Freeze for EarlyStopHandler
impl RefUnwindSafe for EarlyStopHandler
impl Send for EarlyStopHandler
impl Sync for EarlyStopHandler
impl Unpin for EarlyStopHandler
impl UnsafeUnpin for EarlyStopHandler
impl UnwindSafe for EarlyStopHandler
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