Skip to main content

Classification

Struct Classification 

Source
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: SystemKind

The 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

Source

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.

Source

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).

Source

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.

Source

pub fn is_ode_state(&self, name: &str) -> bool

Membership test for Classification::ode_states.

Source

pub fn is_observed(&self, name: &str) -> bool

Membership test for Classification::observed_unknowns.

Source

pub fn is_inlined(&self, name: &str) -> bool

Membership test for Classification::inlined_unknowns.

Source

pub fn is_brownian(&self, name: &str) -> bool

Source

pub fn is_discrete_parameter(&self, name: &str) -> bool

Source

pub fn unknowns(&self) -> Vec<String>

Every unknown of the model, sorted — the union of the three unknown sets.

Source

pub fn parameters(&self) -> Vec<String>

Every parameter of the model, sorted — the union of the four parameter sets.

Source

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

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Classification

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for Classification

Source§

fn default() -> Self

Returns the “default value” for a type. 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> ByRef<T> for T

Source§

fn by_ref(&self) -> &T

Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Context for T
where T: Clone + Default,

Source§

fn vector_from_element<V>(&self, len: usize, value: <V as VectorCommon>::T) -> V
where V: Vector<C = Self>,

Source§

fn vector_from_vec<V>(&self, vec: Vec<<V as VectorCommon>::T>) -> V
where V: Vector<C = Self>,

Source§

fn vector_zeros<V>(&self, len: usize) -> V
where V: Vector<C = Self>,

Source§

fn dense_mat_zeros<V>( &self, rows: usize, cols: usize, ) -> <V as DefaultDenseMatrix>::M
where V: Vector<C = Self> + DefaultDenseMatrix,

Source§

impl<T> DistributionExt for T
where T: ?Sized,

Source§

fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> T
where Self: Distribution<T>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Imply<T> for U
where T: ?Sized, U: ?Sized,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V