pub struct Preference<F>{ /* private fields */ }Expand description
Consumer preference backed by an infallible utility function.
Implementations§
Source§impl<F> Preference<F>
impl<F> Preference<F>
Sourcepub fn new(
utility_func: F,
min_bounds: Vec<f64>,
max_bounds: Vec<f64>,
) -> Result<Self, String>
pub fn new( utility_func: F, min_bounds: Vec<f64>, max_bounds: Vec<f64>, ) -> Result<Self, String>
Constructor - enforce the Axioms of Rationality upon creation on default config
Sourcepub fn with_validation(
utility_func: F,
min_bounds: Vec<f64>,
max_bounds: Vec<f64>,
validate: bool,
) -> Result<Self, String>
pub fn with_validation( utility_func: F, min_bounds: Vec<f64>, max_bounds: Vec<f64>, validate: bool, ) -> Result<Self, String>
Constructor using the shared standard config with per-instance validation control.
Sourcepub fn with_config(
utility_func: F,
min_bounds: Vec<f64>,
max_bounds: Vec<f64>,
config: ValidationConfig,
calc_config: CalcConfig,
) -> Result<Self, String>
pub fn with_config( utility_func: F, min_bounds: Vec<f64>, max_bounds: Vec<f64>, config: ValidationConfig, calc_config: CalcConfig, ) -> Result<Self, String>
Constructor - enforce or not enforce the Axioms of Rationality on customised config
Sourcepub fn get_utility(&self, bundle: &[f64]) -> f64
pub fn get_utility(&self, bundle: &[f64]) -> f64
Getter for the utility of a specific consumption bundle
pub fn min_bounds(&self) -> &[f64]
pub fn max_bounds(&self) -> &[f64]
Sourcepub fn get_mu(&self, bundle: &[f64], good: usize) -> f64
pub fn get_mu(&self, bundle: &[f64], good: usize) -> f64
Getter for marginal utility
This method allows user to access the marginal utility for a specified good, assuming consumption for all other goods in the bundle remains equal:
mu = (U(x + ep) - U(x - ep)) / 2
§Arguments
- bundle - the bundle of goods in question
- good - index for the good to be evaluated
pub fn get_mrs( &self, bundle: &[f64], good_i: usize, good_j: usize, ) -> Result<f64, String>
Auto Trait Implementations§
impl<F> Freeze for Preference<F>where
F: Freeze,
impl<F> RefUnwindSafe for Preference<F>where
F: RefUnwindSafe,
impl<F> Send for Preference<F>where
F: Send,
impl<F> Sync for Preference<F>where
F: Sync,
impl<F> Unpin for Preference<F>where
F: Unpin,
impl<F> UnsafeUnpin for Preference<F>where
F: UnsafeUnpin,
impl<F> UnwindSafe for Preference<F>where
F: UnwindSafe,
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
Mutably borrows from an owned value. Read more