Skip to main content

ExecutionUnit

Trait ExecutionUnit 

Source
pub trait ExecutionUnit:
    Send
    + Sized
    + 'static {
    type Constants: DeserializeOwned + 'static;

    // Required methods
    fn initialize(
        constants: Self::Constants,
        schema: &SystemStateSchema,
    ) -> TaskResult<Self>;
    fn model_count(&self) -> usize;
    fn model(&self, index: usize) -> Option<ModelView<'_>>;
    fn step(&mut self) -> TaskResult;

    // Provided method
    fn observation_plan(
        _constants: &Self::Constants,
    ) -> TaskResult<ObservationPlan> { ... }
}
Expand description

One schedulable scientific execution containing one or more models.

Workflow manages every implementation through the same lifecycle and does not distinguish a standalone model from a coordinated ensemble. A normal model returns one ModelView; an ensemble returns one view per member and keeps all internal parallelism, shared inputs, and synchronization private. Each exposed model owns a distinct SystemState.

Model count, index order, identities, state owners, and schema allocations must remain stable after initialization. One successful Self::step must strictly advance at least one incomplete model and must never advance a model that was already complete. Other incomplete models may wait during a coordinated step, which permits synchronized ensembles and restored members at different iterations.

Required Associated Types§

Source

type Constants: DeserializeOwned + 'static

One complete set of constants supplied by Config.

Required Methods§

Source

fn initialize( constants: Self::Constants, schema: &SystemStateSchema, ) -> TaskResult<Self>

Builds a fully initialized standalone model or ensemble.

Every state subsequently exposed through Self::model must have been created from this exact schema allocation.

Source

fn model_count(&self) -> usize

Returns the stable positive number of independently stateful models.

Source

fn model(&self, index: usize) -> Option<ModelView<'_>>

Borrows one model by stable zero-based index.

The method must be side-effect free. Workflow calls it repeatedly before and after coordinated steps. An index below Self::model_count must always return Some; all other indices must return None.

Source

fn step(&mut self) -> TaskResult

Performs one coordinated scientific transition.

A standalone model advances itself. An ensemble may advance members in parallel or share generated inputs, but it must return only after the complete logical step is visible through Self::model.

Provided Methods§

Source

fn observation_plan(_constants: &Self::Constants) -> TaskResult<ObservationPlan>

Defines the observations recorded independently for every model.

All members of one execution unit use the state schema selected by the task and this common observation plan. The default records every field at every iteration. This preflight operation must have no external side effects.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§