Skip to main content

SegmentedObjective

Struct SegmentedObjective 

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

Runs a trial as a sequence of resumable oniro run operations.

Implementations§

§

impl SegmentedObjective

pub fn new( schema: SpaceSchema, oniro_cli: impl Into<PathBuf>, base_config: impl Into<String>, run_root: impl Into<PathBuf>, plan: SegmentPlan, ) -> Result<Self>

Builds a segmented objective using the command-line runtime adapter.

§The study must declare the same space

Each trial resolves its parameters through TrialCtx::suggest_declared, which reads the range from the study’s ask-time space, not from schema — schema here only lists which names to ask for. Running this objective against a Study whose own declared space (StudyConfig::with_space) does not carry schema’s parameters is not a construction-time error: every trial instead fails with Error::UnknownParam, and since a failed trial does not fail the study, Study::optimize_with still returns Ok(()) while Study::best_trial stays None and no trial ever completes. Build the study with .with_space(schema.clone()) to avoid this.

§Errors

Returns SpikeError::Oniro for an empty executable path, SpikeError::Materialize for an oversized or malformed base config, SpikeError::Io when the invocation child or its base artifact cannot be created, or SpikeError::ResourceCap when unique allocation is exhausted.

pub fn with_runtime(self, runtime: Arc<dyn OniroRuntime>) -> Self

Uses a typed runtime for segment training and metric collection.

pub const fn objective_source(self, source: ObjectiveSource) -> Self

Reads each segment’s value from source instead of greedy evaluation.

pub fn eval_episodes(self, episodes: usize) -> Result<Self>

Sets the number of greedy evaluation episodes.

Invalid counts roll back this constructor’s empty invocation child before returning the error.

§Errors

Returns SpikeError::ResourceCap when episodes is zero or exceeds crate::runtime::MAX_EVAL_EPISODES.

pub const fn rung_floor(self, floor: RungFloor) -> Self

Sets the policy for segments below an algorithm’s learn floor.

pub const fn without_resume(self) -> Self

Runs segments cold instead of resuming the previous segment.

pub fn timeout(self, timeout: Duration) -> Result<Self>

Sets a wall-clock timeout for each train and metric operation.

This bounds one operation. The chain is bounded separately by trial_budget, which is what stops a plan of many segments from multiplying this timeout by its segment count.

An invalid duration rolls back this constructor’s empty invocation child before returning the error.

§Errors

Returns SpikeError::ResourceCap when timeout is zero or exceeds MAX_TRIAL_DURATION.

pub fn trial_budget(self, budget: Duration) -> Result<Self>

Sets the wall clock the whole segment chain may consume.

Defaults to MAX_TRIAL_DURATION. The budget is checked before each train and each metric operation, and the remaining budget is also used as that operation’s timeout when it is shorter than timeout — so an exhausted budget kills the running process rather than merely refusing the next one.

An invalid duration rolls back this constructor’s empty invocation child before returning the error.

§Errors

Returns SpikeError::ResourceCap when budget is zero or exceeds MAX_TRIAL_DURATION.

Trait Implementations§

§

impl Debug for SegmentedObjective

§

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

Formats the value using the given formatter. Read more
§

impl Objective for SegmentedObjective

§

fn evaluate(&self, ctx: &mut TrialCtx<'_>) -> Result<Outcome>

Evaluates one trial. 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<T> ByRef<T> for T

§

fn by_ref(&self) -> &T

§

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, U> Imply<T> for U
where T: ?Sized, U: ?Sized,

§

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