LearnedRule

Struct LearnedRule 

Source
pub struct LearnedRule<C = f32, Q = usize, S = usize>
where Q: RawState,
{ pub confidence: C, pub rule: Rule<Q, S>, }
Expand description

A LearnedRule is an extension of the basic Rule structure, incorporating a confidence metric to quantify the reliability or certainty of the rule within the scope of a learning context. This is particularly useful in scenarios where rules are derived from data or experience, allowing for a more nuanced application of rules based on their confidence levels.

Fields§

§confidence: C§rule: Rule<Q, S>

Implementations§

Source§

impl<T, Q, S> LearnedRule<T, Q, S>
where Q: RawState,

Source

pub const fn new(head: Head<Q, S>, tail: Tail<Q, S>, confidence: T) -> Self

create a new LearnedRule using the given head, tail, and confidence

Source

pub const fn from_rule(rule: Rule<Q, S>, confidence: T) -> Self

returns a new instance using the given rule and confidence

Source

pub const fn from_parts( state: Q, symbol: S, direction: Direction, next_state: Q, write_symbol: S, confidence: T, ) -> Self

returns a new instance from its constituent parts

Source

pub const fn confidence(&self) -> &T

returns an immutable reference to the confidence of the rule

Source

pub const fn confidence_mut(&mut self) -> &mut T

returns a mutable reference to the confidence of the rule

Source

pub const fn rule(&self) -> &Rule<Q, S>

returns an immutable reference to the learned rule

Source

pub const fn rule_mut(&mut self) -> &mut Rule<Q, S>

returns a mutable reference to the learned rule

Source

pub fn set_confidence(&mut self, confidence: T)

update the confidence level of the rule

Source

pub fn set_rule(&mut self, rule: Rule<Q, S>)

update the rule

Source

pub const fn head(&self) -> &Head<Q, S>

returns an immutable reference to the head of the rule

Source

pub const fn head_mut(&mut self) -> &mut Head<Q, S>

returns a mutable reference to the head of the rule

Source

pub const fn tail(&self) -> &Tail<Q, S>

returns an immutable reference to the tail of the rule

Source

pub const fn tail_mut(&mut self) -> &mut Tail<Q, S>

returns a mutable reference to the tail of the rule

Methods from Deref<Target = Rule<Q, A>>§

Source

pub fn head(&self) -> &Head<Q, A>

returns an immutable reference to the Head

Source

pub fn tail(&self) -> &Tail<Q, A>

returns an immutable reference to the Tail of the [Instruction]

Source

pub fn head_view(&self) -> Head<&Q, &A>

returns an instance of the Head whose elements are immutable references

Source

pub fn tail_view(&self) -> Tail<&Q, &A>

returns an instance of the Tail whose elements are immutable references

Source

pub fn direction(&self) -> Direction

returns the direction of the shift

Source

pub fn state(&self) -> &State<Q>

returns the current State of the system

Source

pub fn symbol(&self) -> &A

returns the symbol of the Head

Source

pub fn next_state(&self) -> &State<Q>

returns the next State of the system

Source

pub fn next_symbol(&self) -> &A

returns the symbol which will be written by the Head

Source

pub fn next_head(&self) -> Head<&Q, &A>

returns the next Head of the system

Source

pub fn write_symbol(&self) -> &A

returns the value which for which the current object will be replaced with

Source

pub fn cloned(&self) -> Rule<Q, A>
where Q: Clone, A: Clone,

returns a new instance of the Rule with cloned elements

Source

pub fn copied(&self) -> Rule<Q, A>
where Q: Clone, A: Clone,

returns a new instance of the Rule with copied elements

Trait Implementations§

Source§

impl<C: Clone, Q, S: Clone> Clone for LearnedRule<C, Q, S>
where Q: RawState + Clone,

Source§

fn clone(&self) -> LearnedRule<C, Q, S>

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
Source§

impl<C: Debug, Q, S: Debug> Debug for LearnedRule<C, Q, S>
where Q: RawState + Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<C: Default, Q, S: Default> Default for LearnedRule<C, Q, S>
where Q: RawState + Default,

Source§

fn default() -> LearnedRule<C, Q, S>

Returns the “default value” for a type. Read more
Source§

impl<Q, A, T> Deref for LearnedRule<T, Q, A>
where Q: RawState,

Source§

type Target = Rule<Q, A>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<'de, C, Q, S> Deserialize<'de> for LearnedRule<C, Q, S>
where Q: RawState + Deserialize<'de>, C: Deserialize<'de>, S: Deserialize<'de>,

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<Q, S, T> From<Rule<Q, S>> for LearnedRule<T, Q, S>
where Q: RawState, T: Default,

Source§

fn from(rule: Rule<Q, S>) -> Self

Converts to this type from the input type.
Source§

impl<C: Hash, Q, S: Hash> Hash for LearnedRule<C, Q, S>
where Q: RawState + Hash,

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<C: Ord, Q, S: Ord> Ord for LearnedRule<C, Q, S>
where Q: RawState + Ord,

Source§

fn cmp(&self, other: &LearnedRule<C, Q, S>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<C: PartialEq, Q, S: PartialEq> PartialEq for LearnedRule<C, Q, S>
where Q: RawState + PartialEq,

Source§

fn eq(&self, other: &LearnedRule<C, Q, S>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<C: PartialOrd, Q, S: PartialOrd> PartialOrd for LearnedRule<C, Q, S>
where Q: RawState + PartialOrd,

Source§

fn partial_cmp(&self, other: &LearnedRule<C, Q, S>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<C, Q, S> Serialize for LearnedRule<C, Q, S>

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<C: Copy, Q, S: Copy> Copy for LearnedRule<C, Q, S>
where Q: RawState + Copy,

Source§

impl<C: Eq, Q, S: Eq> Eq for LearnedRule<C, Q, S>
where Q: RawState + Eq,

Source§

impl<C, Q, S> StructuralPartialEq for LearnedRule<C, Q, S>
where Q: RawState,

Auto Trait Implementations§

§

impl<C, Q, S> Freeze for LearnedRule<C, Q, S>
where C: Freeze, S: Freeze, Q: Freeze,

§

impl<C, Q, S> RefUnwindSafe for LearnedRule<C, Q, S>

§

impl<C, Q, S> Send for LearnedRule<C, Q, S>
where C: Send, S: Send,

§

impl<C, Q, S> Sync for LearnedRule<C, Q, S>
where C: Sync, S: Sync,

§

impl<C, Q, S> Unpin for LearnedRule<C, Q, S>
where C: Unpin, S: Unpin, Q: Unpin,

§

impl<C, Q, S> UnwindSafe for LearnedRule<C, Q, S>
where C: UnwindSafe, S: UnwindSafe, Q: 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> 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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,