Skip to main content

hydr_structures/structures/control/
trial.rs

1//! Candidate command continuation with ownership-based acceptance.
2
3use super::{ControlCommandOutput, ControlState, ControlStepDiagnostics, OperatingControlBatch};
4use crate::structures::StructureError;
5use numr::dtype::DType;
6use numr::runtime::Runtime;
7
8/// Complete immutable candidate. Dropping it preserves the accepted batch.
9#[derive(Debug)]
10pub struct OperatingControlTrial<R: Runtime<DType = DType>> {
11    pub(crate) next: OperatingControlBatch<R>,
12}
13impl<R: Runtime<DType = DType>> OperatingControlTrial<R> {
14    /// Explicitly project right-interval candidate commands.
15    pub fn commands(&self) -> Result<Vec<ControlCommandOutput>, StructureError> {
16        self.next.commands()
17    }
18    /// Explicitly project complete candidate continuation.
19    pub fn states(&self) -> Result<Vec<ControlState>, StructureError> {
20        self.next.states()
21    }
22    /// Explicitly project both interval sides and simultaneous decision receipts.
23    pub fn diagnostics(&self) -> Result<ControlStepDiagnostics, StructureError> {
24        self.next.last_step()?.ok_or_else(|| {
25            StructureError::numerical("control trial lacks its immediate step witness")
26        })
27    }
28    /// Accept this complete candidate by ownership.
29    pub fn into_next(self) -> OperatingControlBatch<R> {
30        self.next
31    }
32}