Struct rustitude_core::amplitude::Model
source · pub struct Model {
pub cohsums: Vec<CohSum>,
pub amplitudes: Vec<Amplitude>,
pub parameters: Vec<Parameter>,
}Expand description
Fields§
§cohsums: Vec<CohSum>The set of coherent sums included in the Model.
amplitudes: Vec<Amplitude>The unique amplitudes located within all CohSums.
parameters: Vec<Parameter>The unique parameters located within all CohSums.
Implementations§
source§impl Model
impl Model
sourcepub fn print_tree(&self)
pub fn print_tree(&self)
Pretty-prints a tree diagram to show the node structure of the Model.
sourcepub fn get_amplitude(
&self,
amplitude_name: &str,
) -> Result<Amplitude, RustitudeError>
pub fn get_amplitude( &self, amplitude_name: &str, ) -> Result<Amplitude, RustitudeError>
Retrieves a copy of an Amplitude in the Model by name.
§Errors
This will throw a RustitudeError if the amplitude name is not located within the model.
sourcepub fn get_parameter(
&self,
amplitude_name: &str,
parameter_name: &str,
) -> Result<Parameter, RustitudeError>
pub fn get_parameter( &self, amplitude_name: &str, parameter_name: &str, ) -> Result<Parameter, RustitudeError>
Retrieves a copy of a Parameter in the Model by name.
§Errors
This will throw a RustitudeError if the parameter name is not located within the model
or if the amplitude name is not located within the model (this is checked first).
sourcepub fn print_parameters(&self)
pub fn print_parameters(&self)
Pretty-prints all parameters in the model
sourcepub fn constrain(
&mut self,
amplitude_1: &str,
parameter_1: &str,
amplitude_2: &str,
parameter_2: &str,
) -> Result<(), RustitudeError>
pub fn constrain( &mut self, amplitude_1: &str, parameter_1: &str, amplitude_2: &str, parameter_2: &str, ) -> Result<(), RustitudeError>
Constrains two Parameters in the Model to be equal to each other when evaluated.
§Errors
This method will yield a RustitudeError if either of the parameters is not found by
name.
sourcepub fn fix(
&mut self,
amplitude: &str,
parameter: &str,
value: f64,
) -> Result<(), RustitudeError>
pub fn fix( &mut self, amplitude: &str, parameter: &str, value: f64, ) -> Result<(), RustitudeError>
Fixes a Parameter in the Model to a given value.
This method technically sets the Parameter to be fixed and gives it an initial value of
the given value. This method also handles groups of constrained parameters.
§Errors
This method yields a RustitudeError if the parameter is not found by name.
sourcepub fn free(
&mut self,
amplitude: &str,
parameter: &str,
) -> Result<(), RustitudeError>
pub fn free( &mut self, amplitude: &str, parameter: &str, ) -> Result<(), RustitudeError>
Frees a Parameter in the Model.
This method does not modify the initial value of the parameter. This method also handles groups of constrained parameters.
§Errors
This method yields a RustitudeError if the parameter is not found by name.
sourcepub fn set_bounds(
&mut self,
amplitude: &str,
parameter: &str,
bounds: (f64, f64),
) -> Result<(), RustitudeError>
pub fn set_bounds( &mut self, amplitude: &str, parameter: &str, bounds: (f64, f64), ) -> Result<(), RustitudeError>
Sets the bounds on a Parameter in the Model.
§Errors
This method yields a RustitudeError if the parameter is not found by name.
sourcepub fn set_initial(
&mut self,
amplitude: &str,
parameter: &str,
initial: f64,
) -> Result<(), RustitudeError>
pub fn set_initial( &mut self, amplitude: &str, parameter: &str, initial: f64, ) -> Result<(), RustitudeError>
Sets the initial value of a Parameter in the Model.
§Errors
This method yields a RustitudeError if the parameter is not found by name.
sourcepub fn get_bounds(&self) -> Vec<(f64, f64)>
pub fn get_bounds(&self) -> Vec<(f64, f64)>
sourcepub fn get_initial(&self) -> Vec<f64>
pub fn get_initial(&self) -> Vec<f64>
sourcepub fn get_n_free(&self) -> usize
pub fn get_n_free(&self) -> usize
sourcepub fn deactivate(&mut self, amplitude: &str)
pub fn deactivate(&mut self, amplitude: &str)
sourcepub fn compute(
&self,
parameters: &[f64],
event: &Event,
) -> Result<f64, RustitudeError>
pub fn compute( &self, parameters: &[f64], event: &Event, ) -> Result<f64, RustitudeError>
Computes the result of evaluating the terms in the model with the given Parameters for
the given Event by summing the result of CohSum::compute for each CohSum
contained in the Model.
§Errors
This method yields a RustitudeError if any of the Amplitude::calculate steps fail.
sourcepub fn norm_int(
&self,
parameters: &[f64],
event: &Event,
) -> Result<f64, RustitudeError>
pub fn norm_int( &self, parameters: &[f64], event: &Event, ) -> Result<f64, RustitudeError>
Computes the result of evaluating the terms in the model with the given Parameters for
the given Event by summing the result of CohSum::norm_int for each CohSum
contained in the Model.
§Errors
This method yields a RustitudeError if any of the Amplitude::calculate steps fail.
sourcepub fn load(&mut self, dataset: &Dataset) -> Result<(), RustitudeError>
pub fn load(&mut self, dataset: &Dataset) -> Result<(), RustitudeError>
Registers the Model with the Dataset by Amplitude::registering each
Amplitude and setting the proper cache position and parameter starting index.
§Errors
This method will yield a RustitudeError if any Amplitude::precalculate steps fail.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Model
impl !RefUnwindSafe for Model
impl Send for Model
impl Sync for Model
impl Unpin for Model
impl !UnwindSafe for Model
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
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
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.