Skip to main content

Deadline

Struct Deadline 

Source
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

Source

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.

Source

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.

Source

pub fn max_wall(&self) -> Number

The wall-clock budget this deadline was built with.

Source

pub fn max_cpu(&self) -> Number

The CPU-time budget this deadline was built with.

Source

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.

Source

pub fn remaining_cpu(&self) -> Number

CPU-time counterpart of Self::remaining_wall.

Trait Implementations§

Source§

impl Clone for Deadline

Source§

fn clone(&self) -> Deadline

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 Debug for Deadline

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.