pub struct Classification {
pub ode_states: Vec<String>,
pub observed_unknowns: Vec<String>,
pub inlined_unknowns: Vec<String>,
pub algebraic_unknowns: Vec<String>,
pub brownian_parameters: Vec<String>,
pub discrete_parameters: Vec<String>,
pub sampled_parameters: Vec<String>,
pub constant_parameters: Vec<String>,
pub system_kind: SystemKind,
pub observed_definitions: BTreeMap<String, Expr>,
}Expand description
One model’s complete §6.3.1 classification, computed once. Every name list is sorted.
The free functions below (ode_states, brownian_parameters, …) are
thin wrappers over this; build it directly when a caller needs several sets,
so the equation walk happens once.
Fields§
§ode_states: Vec<String>Unknowns appearing under D(·, t) on some equation LHS.
observed_unknowns: Vec<String>Unknowns defined by a bare-variable OR indexed-variable LHS (esm-spec §6.3.1) — the semantic “defined by an equation” set.
inlined_unknowns: Vec<String>The NARROWER set alongside Self::observed_unknowns: the observed
unknowns whose defining LHS is a BARE variable, so they are eliminable
by inlining (esm-spec §6.3.1, “Note that eliminable and
inlineable are not the same thing”). An ARRAYED definition
(y[i] ~ f(i)) is observed too, but it materializes into a buffer its
consumers index rather than being substituted away, so it is NOT here.
Spelled inlined_unknowns in the Python oracle; it does not narrow the
§6.3.1 partition, it sits beside it.
algebraic_unknowns: Vec<String>Unknowns constrained only implicitly.
brownian_parameters: Vec<String>Parameters whose update is wiener.
discrete_parameters: Vec<String>Parameters carrying any OTHER update.
sampled_parameters: Vec<String>Parameters with a distribution and no update.
constant_parameters: Vec<String>Parameters with neither.
system_kind: SystemKindThe DERIVED system kind.
observed_definitions: BTreeMap<String, Expr>Each observed unknown’s defining RHS, keyed by the unknown’s name — the
1.0.0 home of what used to sit in variables[v].expression.
Implementations§
Source§impl Classification
impl Classification
Sourcepub fn of(model: &Model) -> Classification
pub fn of(model: &Model) -> Classification
Classify one model node. Classification is per MODEL NODE: a subsystem’s equations classify the subsystem’s variables, never the parent’s.
Sourcepub fn from_parts(
variables: &IndexMap<String, ModelVariable>,
equations: &[Equation],
) -> Classification
pub fn from_parts( variables: &IndexMap<String, ModelVariable>, equations: &[Equation], ) -> Classification
Classify from the raw parts, for callers holding a variables map and an
equation list rather than a whole Model (the JSON-level cadence
pass, the flatten/compile pipelines).
Sourcepub fn from_json(model: &Value) -> Result<Classification, Error>
pub fn from_json(model: &Value) -> Result<Classification, Error>
Classify a model held as raw JSON — the form the cadence-partition pass and the CLI work in.
Reads only variables and equations, and IGNORES every other key, so
a model carrying the document registries merged down onto it (as
crate::cadence::model_with_loaders does) classifies the same as the
bare one.
A VARIABLE that does not deserialize is an error: mis-reading the declared type set is exactly the failure this module exists to prevent, and it would silently classify as “no variables”. An individual EQUATION that does not deserialize is SKIPPED, because the passes that call this run over partially-lowered intermediate JSON whose well-formedness is the schema layer’s business, not classification’s.
Sourcepub fn is_ode_state(&self, name: &str) -> bool
pub fn is_ode_state(&self, name: &str) -> bool
Membership test for Classification::ode_states.
Sourcepub fn is_observed(&self, name: &str) -> bool
pub fn is_observed(&self, name: &str) -> bool
Membership test for Classification::observed_unknowns.
Sourcepub fn is_inlined(&self, name: &str) -> bool
pub fn is_inlined(&self, name: &str) -> bool
Membership test for Classification::inlined_unknowns.
Sourcepub fn is_brownian(&self, name: &str) -> bool
pub fn is_brownian(&self, name: &str) -> bool
Membership test for Classification::brownian_parameters.
Sourcepub fn is_discrete_parameter(&self, name: &str) -> bool
pub fn is_discrete_parameter(&self, name: &str) -> bool
Membership test for Classification::discrete_parameters.
Sourcepub fn unknowns(&self) -> Vec<String>
pub fn unknowns(&self) -> Vec<String>
Every unknown of the model, sorted — the union of the three unknown sets.
Sourcepub fn parameters(&self) -> Vec<String>
pub fn parameters(&self) -> Vec<String>
Every parameter of the model, sorted — the union of the four parameter sets.
Sourcepub fn assert_partitions(&self, model: &Model) -> Result<(), String>
pub fn assert_partitions(&self, model: &Model) -> Result<(), String>
Assert the two §6.3.1 partition laws against the model this was derived from: the three unknown sets partition the unknowns, and the four parameter sets partition the parameters — both disjointly and totally.
Returns the first violation as an Err, so a caller can surface it as a
diagnostic rather than panicking.
Trait Implementations§
Source§impl Clone for Classification
impl Clone for Classification
Source§impl Debug for Classification
impl Debug for Classification
Auto Trait Implementations§
impl Freeze for Classification
impl RefUnwindSafe for Classification
impl Send for Classification
impl Sync for Classification
impl Unpin for Classification
impl UnsafeUnpin for Classification
impl UnwindSafe for Classification
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Context for T
impl<T> Context for T
fn vector_from_element<V>(&self, len: usize, value: <V as VectorCommon>::T) -> Vwhere
V: Vector<C = Self>,
fn vector_from_vec<V>(&self, vec: Vec<<V as VectorCommon>::T>) -> Vwhere
V: Vector<C = Self>,
fn vector_zeros<V>(&self, len: usize) -> Vwhere
V: Vector<C = Self>,
fn dense_mat_zeros<V>(
&self,
rows: usize,
cols: usize,
) -> <V as DefaultDenseMatrix>::Mwhere
V: Vector<C = Self> + DefaultDenseMatrix,
Source§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T, U> Imply<T> for U
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.