Skip to main content

Preference

Struct Preference 

Source
pub struct Preference<F>
where F: Fn(&[f64]) -> f64,
{ /* private fields */ }
Expand description

Consumer preference backed by an infallible utility function.

Implementations§

Source§

impl<F> Preference<F>
where F: Fn(&[f64]) -> f64,

Source

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

Source

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.

Source

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

Source

pub fn get_utility(&self, bundle: &[f64]) -> f64

Getter for the utility of a specific consumption bundle

Source

pub fn min_bounds(&self) -> &[f64]

Source

pub fn max_bounds(&self) -> &[f64]

Source

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
Source

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

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.