Rule

Struct Rule 

Source
pub struct Rule {
    pub antecedent: Antecedent,
    pub consequent: Vec<Consequent>,
}
Expand description

Full fuzzy rule pairing an antecedent with one or more consequents.

  • antecedent encodes the IF-part as an expression tree of atomic predicates combined with AND/OR/NOT using the default Min–Max family.
  • consequent lists one or more THEN-part outputs; each is evaluated over its variable domain during implication.

Fields§

§antecedent: Antecedent

IF-part expressed as an Antecedent AST over input variables/terms.

§consequent: Vec<Consequent>

THEN-parts listing output variable/term pairs to implicate.

Implementations§

Source§

impl Rule

Source

pub fn activation<KI, KV>( &self, input: &HashMap<KI, Float>, vars: &HashMap<KV, Variable>, ) -> Result<Float>
where KI: Eq + Hash + Borrow<str>, KV: Eq + Hash + Borrow<str>,

Evaluate the antecedent against crisp inputs to obtain activation.

Type parameters

  • KI: key type for input, must borrow as str (e.g., &str).
  • KV: key type for vars, must borrow as str.

Returns the activation degree alpha ∈ [0, 1] for this rule.

Errors

  • FuzzyError::NotFound if an input or variable is missing.
  • FuzzyError::TypeMismatch if the antecedent references an unknown term.
  • FuzzyError::OutOfBounds if an input value lies outside a variable’s domain.
Source

pub fn implicate<KV>( &self, alpha: Float, vars: &HashMap<KV, Variable>, sampler: &UniformSampler, ) -> Result<HashMap<String, Vec<Float>>>
where KV: Eq + Hash + Borrow<str>,

Apply implication to produce discretized membership outputs.

For each Consequent, this function:

  1. retrieves the target variable’s domain, 2) builds an evenly spaced grid of sampler.n points, 3) evaluates the consequent term’s membership μ_B(x) on that grid, and 4) applies clipping via min(alpha, μ_B(x)).

The result is a map from variable name to the vector of sampled values.

Errors

  • FuzzyError::NotFound if a variable or term cannot be found.
  • FuzzyError::OutOfBounds if evaluation occurs outside the domain.

Note

  • The x-grid spacing is (max - min) / (sampler.n - 1) so the vector always includes both domain endpoints.
Source

pub fn get_vars(self)

Placeholder: check if a given variable exists within a rule.

Source

pub fn validate<KV>(&self, vars: &HashMap<KV, Variable>) -> Result<()>
where KV: Eq + Hash + Borrow<str>,

Validate that this rule references only existing variables and terms.

Ensures all antecedent atoms and consequents point to variables present in vars and that the referenced term labels exist within those variables’ term maps. Returns Ok(()) on success, or NotFound errors identifying the missing Var or Term.

Trait Implementations§

Source§

impl Clone for Rule

Source§

fn clone(&self) -> Rule

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl Freeze for Rule

§

impl RefUnwindSafe for Rule

§

impl Send for Rule

§

impl Sync for Rule

§

impl Unpin for Rule

§

impl UnwindSafe for Rule

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