Skip to main content

Objective

Trait Objective 

pub trait Objective: Send + Sync {
    // Required method
    fn evaluate(&self, ctx: &mut TrialCtx<'_>) -> Result<Outcome>;
}
Expand description

The user’s code under evaluation.

§Security

An objective is arbitrary operator code executed in the host process with the same OS privileges, environment, filesystem, and network access as its caller. atune_core does not sandbox objective code. For untrusted workloads, run the whole tuner in an external OS/container/VM/job sandbox with a dedicated unprivileged identity and explicit resource and network limits; an in-process objective cannot be isolated from inside this process.

Send + Sync because optimize may run trials on several threads; the blanket implementation below covers closures, which is how most objectives are written.

use atune_core::error::Result;
use atune_core::objective::{Objective, Outcome, TrialCtx};

fn takes_an_objective(_: impl Objective) {}

takes_an_objective(|_ctx: &mut TrialCtx<'_>| -> Result<Outcome> { Ok(1.0.into()) });

Required Methods§

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

Evaluates one trial.

§Errors

Error::TrialPruned — propagated from TrialCtx::should_stop with ? — records the trial as pruned rather than failed. Any other error fails the trial, keeping the message in the trial record.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

§

impl Objective for Subprocess

§

impl<F> Objective for F
where F: Fn(&mut TrialCtx<'_>) -> Result<Outcome> + Send + Sync,