Struct SegmentedObjective
pub struct SegmentedObjective { /* private fields */ }Expand description
Runs a trial as a sequence of resumable oniro run operations.
Implementations§
§impl SegmentedObjective
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>
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
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
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>
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
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
pub const fn without_resume(self) -> Self
Runs segments cold instead of resuming the previous segment.
pub fn timeout(self, timeout: Duration) -> Result<Self>
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>
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.