Skip to main content

TrainingEvent

Enum TrainingEvent 

Source
pub enum TrainingEvent {
    ForwardPassComplete {
        iteration: u64,
        scenarios: u32,
        ub_mean: f64,
        ub_std: f64,
        elapsed_ms: u64,
    },
    ForwardSyncComplete {
        iteration: u64,
        global_ub_mean: f64,
        global_ub_std: f64,
        sync_time_ms: u64,
    },
    BackwardPassComplete {
        iteration: u64,
        cuts_generated: u32,
        stages_processed: u32,
        elapsed_ms: u64,
    },
    CutSyncComplete {
        iteration: u64,
        cuts_distributed: u32,
        cuts_active: u32,
        cuts_removed: u32,
        sync_time_ms: u64,
    },
    CutSelectionComplete {
        iteration: u64,
        cuts_deactivated: u32,
        stages_processed: u32,
        selection_time_ms: u64,
        allgatherv_time_ms: u64,
    },
    ConvergenceUpdate {
        iteration: u64,
        lower_bound: f64,
        upper_bound: f64,
        upper_bound_std: f64,
        gap: f64,
        rules_evaluated: Vec<StoppingRuleResult>,
    },
    CheckpointComplete {
        iteration: u64,
        checkpoint_path: String,
        elapsed_ms: u64,
    },
    IterationSummary {
        iteration: u64,
        lower_bound: f64,
        upper_bound: f64,
        gap: f64,
        wall_time_ms: u64,
        iteration_time_ms: u64,
        forward_ms: u64,
        backward_ms: u64,
        lp_solves: u64,
    },
    TrainingStarted {
        case_name: String,
        stages: u32,
        hydros: u32,
        thermals: u32,
        ranks: u32,
        threads_per_rank: u32,
        timestamp: String,
    },
    TrainingFinished {
        reason: String,
        iterations: u64,
        final_lb: f64,
        final_ub: f64,
        total_time_ms: u64,
        total_cuts: u64,
    },
    SimulationProgress {
        scenarios_complete: u32,
        scenarios_total: u32,
        elapsed_ms: u64,
        mean_cost: f64,
        std_cost: f64,
        ci_95_half_width: f64,
    },
    SimulationFinished {
        scenarios: u32,
        output_dir: String,
        elapsed_ms: u64,
    },
}
Expand description

Typed events emitted by an iterative optimization training loop and simulation runner.

The enum has 12 variants: 8 per-iteration events (one per lifecycle step) and 4 lifecycle events (emitted once per training or simulation run).

§Per-iteration events (steps 1–7 + 4a)

StepVariantWhen emitted
1Self::ForwardPassCompleteLocal forward pass done
2Self::ForwardSyncCompleteGlobal allreduce of bounds done
3Self::BackwardPassCompleteBackward sweep done
4Self::CutSyncCompleteCut allgatherv done
4aSelf::CutSelectionCompleteCut selection done (conditional on should_run)
5Self::ConvergenceUpdateStopping rules evaluated
6Self::CheckpointCompleteCheckpoint written (conditional on checkpoint interval)
7Self::IterationSummaryEnd-of-iteration aggregated summary

§Lifecycle events

VariantWhen emitted
Self::TrainingStartedTraining loop entry
Self::TrainingFinishedTraining loop exit
Self::SimulationProgressSimulation batch completion
Self::SimulationFinishedSimulation completion

Variants§

§

ForwardPassComplete

Step 1: Forward pass completed for this iteration on the local rank.

Fields

§iteration: u64

Iteration number (1-based).

§scenarios: u32

Number of forward scenarios evaluated on this rank.

§ub_mean: f64

Mean total forward cost across local scenarios.

§ub_std: f64

Standard deviation of total forward cost across local scenarios.

§elapsed_ms: u64

Wall-clock time for the forward pass on this rank, in milliseconds.

§

ForwardSyncComplete

Step 2: Forward synchronization (allreduce) completed.

Emitted after the global reduction of local bound estimates across all participating ranks.

Fields

§iteration: u64

Iteration number (1-based).

§global_ub_mean: f64

Global upper bound mean after allreduce.

§global_ub_std: f64

Global upper bound standard deviation after allreduce.

§sync_time_ms: u64

Wall-clock time for the synchronization, in milliseconds.

§

BackwardPassComplete

Step 3: Backward pass completed for this iteration.

Emitted after the full backward sweep that generates new cuts for each stage.

Fields

§iteration: u64

Iteration number (1-based).

§cuts_generated: u32

Number of new cuts generated across all stages.

§stages_processed: u32

Number of stages processed in the backward sweep.

§elapsed_ms: u64

Wall-clock time for the backward pass, in milliseconds.

§

CutSyncComplete

Step 4: Cut synchronization (allgatherv) completed.

Emitted after new cuts from all ranks have been gathered and distributed to every rank via allgatherv.

Fields

§iteration: u64

Iteration number (1-based).

§cuts_distributed: u32

Number of cuts distributed to all ranks via allgatherv.

§cuts_active: u32

Total number of active cuts in the approximation after synchronization.

§cuts_removed: u32

Number of cuts removed during synchronization.

§sync_time_ms: u64

Wall-clock time for the synchronization, in milliseconds.

§

CutSelectionComplete

Step 4a: Cut selection completed.

Only emitted on iterations where cut selection runs (i.e., when should_run(iteration) returns true). On non-selection iterations this variant is skipped entirely.

Fields

§iteration: u64

Iteration number (1-based).

§cuts_deactivated: u32

Number of cuts deactivated across all stages.

§stages_processed: u32

Number of stages processed during cut selection.

§selection_time_ms: u64

Wall-clock time for the local cut selection phase, in milliseconds.

§allgatherv_time_ms: u64

Wall-clock time for the allgatherv deactivation-set exchange, in milliseconds.

§

ConvergenceUpdate

Step 5: Convergence check completed.

Emitted after all configured stopping rules have been evaluated for the current iteration. Contains the current bounds, gap, and per-rule results.

Fields

§iteration: u64

Iteration number (1-based).

§lower_bound: f64

Current lower bound (non-decreasing across iterations).

§upper_bound: f64

Current upper bound (statistical estimate from forward costs).

§upper_bound_std: f64

Standard deviation of the upper bound estimate.

§gap: f64

Relative optimality gap: (upper_bound - lower_bound) / |upper_bound|.

§rules_evaluated: Vec<StoppingRuleResult>

Evaluation result for each configured stopping rule.

§

CheckpointComplete

Step 6: Checkpoint written.

Only emitted when the checkpoint interval triggers (i.e., when iteration % checkpoint_interval == 0). Not emitted on every iteration.

Fields

§iteration: u64

Iteration number (1-based).

§checkpoint_path: String

Filesystem path where the checkpoint was written.

§elapsed_ms: u64

Wall-clock time for the checkpoint write, in milliseconds.

§

IterationSummary

Step 7: Full iteration summary with aggregated timings.

Emitted at the end of every iteration as the final per-iteration event. Contains all timing breakdowns for the completed iteration.

Fields

§iteration: u64

Iteration number (1-based).

§lower_bound: f64

Current lower bound.

§upper_bound: f64

Current upper bound.

§gap: f64

Relative optimality gap: (upper_bound - lower_bound) / |upper_bound|.

§wall_time_ms: u64

Cumulative wall-clock time since training started, in milliseconds.

§iteration_time_ms: u64

Wall-clock time for this iteration only, in milliseconds.

§forward_ms: u64

Forward pass time for this iteration, in milliseconds.

§backward_ms: u64

Backward pass time for this iteration, in milliseconds.

§lp_solves: u64

Total number of LP solves in this iteration (forward + backward stages).

§

TrainingStarted

Emitted once when the training loop begins.

Carries run-level metadata describing the problem size and parallelism configuration for this training run.

Fields

§case_name: String

Case study name from the input data directory.

§stages: u32

Total number of stages in the optimization horizon.

§hydros: u32

Number of hydro plants in the system.

§thermals: u32

Number of thermal plants in the system.

§ranks: u32

Number of distributed ranks participating in training.

§threads_per_rank: u32

Number of threads per rank.

§timestamp: String

Wall-clock time at training start as an ISO 8601 string (run-level metadata, not a per-event timestamp).

§

TrainingFinished

Emitted once when the training loop exits (converged or limit reached).

Fields

§reason: String

Termination reason (e.g., "gap_tolerance", "iteration_limit", "time_limit").

§iterations: u64

Total number of iterations completed.

§final_lb: f64

Final lower bound at termination.

§final_ub: f64

Final upper bound at termination.

§total_time_ms: u64

Total wall-clock time for the training run, in milliseconds.

§total_cuts: u64

Total number of cuts in the approximation at termination.

§

SimulationProgress

Emitted periodically during policy simulation (not during training).

Consumers can use this to display a progress indicator during the simulation phase, including live cost statistics as scenarios complete.

Fields

§scenarios_complete: u32

Number of simulation scenarios completed so far.

§scenarios_total: u32

Total number of simulation scenarios to run.

§elapsed_ms: u64

Wall-clock time since simulation started, in milliseconds.

§mean_cost: f64

Running mean of total scenario costs computed so far, in cost units.

Populated by the emitter after each batch of completed scenarios.

§std_cost: f64

Running standard deviation of total scenario costs.

Set to 0.0 when scenarios_complete < 2 (insufficient data for variance estimation).

§ci_95_half_width: f64

Half-width of the 95% confidence interval, in cost units.

Computed as 1.96 * std_cost / sqrt(scenarios_complete). Set to 0.0 when scenarios_complete < 2.

§

SimulationFinished

Emitted once when policy simulation completes.

Fields

§scenarios: u32

Total number of simulation scenarios evaluated.

§output_dir: String

Directory where simulation output files were written.

§elapsed_ms: u64

Total wall-clock time for the simulation run, in milliseconds.

Trait Implementations§

Source§

impl Clone for TrainingEvent

Source§

fn clone(&self) -> TrainingEvent

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TrainingEvent

Source§

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

Formats the value using the given formatter. 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
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.