Variable

Struct Variable 

Source
pub struct Variable {
    pub terms: HashMap<String, Term>,
    /* private fields */
}
Expand description

A crisp variable with an inclusive numeric domain and a set of named terms.

Fields§

§terms: HashMap<String, Term>

Mapping from term name to its labeled membership function wrapper.

Implementations§

Source§

impl Variable

Source

pub fn new(min: Float, max: Float) -> Result<Self>

Constructs a new variable, validating that min < max.

Source

pub fn insert_term(&mut self, name: &str, t: Term) -> Result<()>

Inserts a named term; rejects empty names and duplicates.

  • Empty name -> FuzzyError::EmptyInput
  • Duplicate name -> FuzzyError::TypeMismatch
Source

pub fn get(&self, name: &str) -> Option<&Term>

Returns a reference to the term for name, if present.

Source

pub fn eval(&self, name: &str, x: Float) -> Result<Float>

Evaluates the membership degree for term name at input x.

  • Unknown term -> FuzzyError::TypeMismatch
  • x out of [min, max] -> FuzzyError::OutOfBounds
Source

pub fn domain(&self) -> (Float, Float)

Returns the range of domain for the membership function.(term)

  • retunrs (min, max)

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