pub struct Deadline { /* private fields */ }Expand description
A monotonic wall/CPU-clock deadline for a single solve (pounce#242).
Cheaply clonable (Rc-backed) so the outer loop, the KKT solver, the
line search, and the restoration inner IPM can all check the same
global budget — not just the outer-iteration convergence check. The
motivating bug: max_wall_time was only tested between outer
iterations (in OptErrorConvCheck), so a solve whose per-iteration
cost is dominated by a single expensive step — a slow KKT
factorization, or a restoration sub-solve that runs an entire nested
IPM under one outer “iteration” — overshot the requested budget by up
to a full iteration (~7x on the reported 1611-variable NLP). Checking
this deadline at the granularity of the expensive inner steps bounds
the overshoot to roughly one such step.
The elapsed time is measured from the instant the Deadline is
constructed, using the same process clocks the timing subsystem uses.
Unlike TimedTask::live_wallclock_time it does not depend on a
start()/end() cycle, so it works inside the nested restoration
solve — whose fresh TimingStatistics has an overall_alg timer
that is never started, which is exactly why the inner loop used to run
unbounded by wall time.
Implementations§
Source§impl Deadline
impl Deadline
Sourcepub fn new(max_wall: Number, max_cpu: Number) -> Self
pub fn new(max_wall: Number, max_cpu: Number) -> Self
Create a deadline that fires once max_wall wall seconds or
max_cpu CPU seconds have elapsed from now. The pounce defaults
for both budgets are 1e6, i.e. effectively unbounded; a caller
that passes those gets a deadline that never trips in practice.
Sourcepub fn exceeded(&self) -> Option<DeadlineKind>
pub fn exceeded(&self) -> Option<DeadlineKind>
Return Some(kind) if either budget has been crossed, else
None. CPU is tested before wall to match the branch order of
upstream OptimalityErrorConvergenceCheck::CheckConvergence (and
pounce’s OptErrorConvCheck), so a solve that trips both in the
same check reports MaximumCpuTimeExceeded identically to the
coarse path.
Sourcepub fn remaining_wall(&self) -> Number
pub fn remaining_wall(&self) -> Number
Wall-clock seconds remaining before the wall budget trips.
Negative once the budget is already crossed. Unlike
Self::exceeded this exposes how much budget is left, which
the KKT solver’s predictive time guard (pounce#254) compares
against the observed cost of one factorization to decide whether
starting another would overshoot.
Sourcepub fn remaining_cpu(&self) -> Number
pub fn remaining_cpu(&self) -> Number
CPU-time counterpart of Self::remaining_wall.