Skip to main content

Patient

Struct Patient 

pub struct Patient { /* private fields */ }
Expand description

A decorator that delays an inner scheduler’s prune until a trial has stopped improving.

It forwards every call to the wrapped Scheduler, with one change: an inner Decision::Prune is suppressed (turned into Decision::Continue) until the trial has gone patience consecutive reports without improving its own best objective value. Pause, Fork and Continue pass through untouched, as does everything from on_trial_end and state (Patient adds no persistent state of its own).

This dampens the failure mode the design warns about — a noisy RL curve that dips for one report and is pruned by an over-eager inner rule even though it was about to recover (prune and schedule). Compose it over any pruner: Patient::new(3, Arc::new(AshaPruner::new(1, 27, 3)?)).

§Why it tracks per-trial state

“Improving its own best” needs the trial’s own report history, which the ask-time StudyView does not contain (the reporting trial is not in it) and which no storage handle is offered for. Patient therefore keeps a tiny {best, stale} record per live trial behind a mutex, cleared on on_trial_end — transient bookkeeping, not study state.

§Determinism

The improvement count is a deterministic function of the trial’s own reports (which arrive in order on one worker); the inner decision carries whatever determinism the inner scheduler has. Replayable, not pre-determined, under parallelism.

Implementations§

§

impl Patient

pub fn new(patience: u32, inner: Arc<dyn Scheduler>) -> Self

Wraps inner, honoring its prunes only after patience non-improving reports.

pub fn with_objective(self, obj: usize) -> Self

Selects which objective dimension defines “improvement” (default 0).

Trait Implementations§

§

impl Debug for Patient

§

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

Formats the value using the given formatter. Read more
§

impl Scheduler for Patient

§

fn on_trial_end( &self, study: &StudyView, trial: &FrozenTrial, ) -> Result<Vec<Command>>

Forwards to the inner scheduler and clears the finished trial’s tracker.

§

fn state(&self) -> Result<Option<SchedulerState>>

The inner scheduler’s state — Patient adds none of its own.

§

fn resume_candidates(&self, study: &StudyView) -> Result<Vec<Command>>

Forwards slot-driven wakeups without changing the inner scheduler’s command semantics.

§

fn restore_state(&self, blob: &SchedulerState) -> Result<()>

Restores the wrapped scheduler’s state; Patient has no state of its own.

§

fn scripted_capability(&self) -> ScriptedSchedulerCapability

Declares whether scripted ask/tell can recreate this scheduler. Read more
§

fn fan_report_mode(&self) -> FanReportMode

Declares whether this scheduler accepts aligned aggregate fan reports. Read more
§

fn on_report( &self, study: &StudyView, trial: &TrialMeta, step: u64, values: &[f64], ) -> Result<Decision>

Called on every intermediate report. 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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more