TSKFuzzyInferenceSystem

Struct TSKFuzzyInferenceSystem 

Source
pub struct TSKFuzzyInferenceSystem { /* private fields */ }

Implementations§

Source§

impl TSKFuzzyInferenceSystem

Source

pub fn new( s_norm: SNorms, t_norm: TNorms, defuzzification: TSKDefuzzifiers, ) -> Self

Examples found in repository?
examples/function_approximation.rs (line 22)
11fn main() {
12    let x1 = 0.0;
13    let x2 = 0.25;
14    let x3 = 0.5;
15    let x4 = 0.75;
16    let x5 = 1.0;
17    let original_function = |x| x * (1.0 - x);
18    let y15 = original_function(x1);
19    let y24 = original_function(x2);
20    let y3 = original_function(x3);
21
22    let mut fis = TSKFIS::new(SNorms::Max, TNorms::Min, TSKDefuzzifiers::Mean);
23
24    let mut x: InputVariable = InputVariable::new("X".to_string(), (0.0, 1.0));
25    x.add_membership(MembershipFunction::new(
26        "x1".to_string(),
27        MFKind::Gaussian(Gaussian::new(x1, 0.09)),
28    ));
29    x.add_membership(MembershipFunction::new(
30        "x2".to_string(),
31        MFKind::Gaussian(Gaussian::new(x2, 0.09)),
32    ));
33    x.add_membership(MembershipFunction::new(
34        "x3".to_string(),
35        MFKind::Gaussian(Gaussian::new(x3, 0.09)),
36    ));
37    x.add_membership(MembershipFunction::new(
38        "x4".to_string(),
39        MFKind::Gaussian(Gaussian::new(x4, 0.09)),
40    ));
41    x.add_membership(MembershipFunction::new(
42        "x5".to_string(),
43        MFKind::Gaussian(Gaussian::new(x5, 0.09)),
44    ));
45    fis.add_input(x);
46
47    let mut y: TSKOutputVariable = TSKOutputVariable::new("Y".to_string());
48    y.add_constant_membership(y15);
49    y.add_constant_membership(y24);
50    y.add_constant_membership(y3);
51
52    fis.add_output(y);
53
54    fis.add_rule(Rule::new_and(vec![0, 0], 1.0));
55    fis.add_rule(Rule::new_and(vec![1, 1], 1.0));
56    fis.add_rule(Rule::new_and(vec![2, 2], 1.0));
57    fis.add_rule(Rule::new_and(vec![3, 1], 1.0));
58    fis.add_rule(Rule::new_and(vec![4, 0], 1.0));
59    
60    let out: Vec<f64> = fis.compute_outputs(vec![0.6]);
61    println!("{:?}", out);
62}
Source

pub fn add_input(&mut self, input: InputVariable)

Examples found in repository?
examples/function_approximation.rs (line 45)
11fn main() {
12    let x1 = 0.0;
13    let x2 = 0.25;
14    let x3 = 0.5;
15    let x4 = 0.75;
16    let x5 = 1.0;
17    let original_function = |x| x * (1.0 - x);
18    let y15 = original_function(x1);
19    let y24 = original_function(x2);
20    let y3 = original_function(x3);
21
22    let mut fis = TSKFIS::new(SNorms::Max, TNorms::Min, TSKDefuzzifiers::Mean);
23
24    let mut x: InputVariable = InputVariable::new("X".to_string(), (0.0, 1.0));
25    x.add_membership(MembershipFunction::new(
26        "x1".to_string(),
27        MFKind::Gaussian(Gaussian::new(x1, 0.09)),
28    ));
29    x.add_membership(MembershipFunction::new(
30        "x2".to_string(),
31        MFKind::Gaussian(Gaussian::new(x2, 0.09)),
32    ));
33    x.add_membership(MembershipFunction::new(
34        "x3".to_string(),
35        MFKind::Gaussian(Gaussian::new(x3, 0.09)),
36    ));
37    x.add_membership(MembershipFunction::new(
38        "x4".to_string(),
39        MFKind::Gaussian(Gaussian::new(x4, 0.09)),
40    ));
41    x.add_membership(MembershipFunction::new(
42        "x5".to_string(),
43        MFKind::Gaussian(Gaussian::new(x5, 0.09)),
44    ));
45    fis.add_input(x);
46
47    let mut y: TSKOutputVariable = TSKOutputVariable::new("Y".to_string());
48    y.add_constant_membership(y15);
49    y.add_constant_membership(y24);
50    y.add_constant_membership(y3);
51
52    fis.add_output(y);
53
54    fis.add_rule(Rule::new_and(vec![0, 0], 1.0));
55    fis.add_rule(Rule::new_and(vec![1, 1], 1.0));
56    fis.add_rule(Rule::new_and(vec![2, 2], 1.0));
57    fis.add_rule(Rule::new_and(vec![3, 1], 1.0));
58    fis.add_rule(Rule::new_and(vec![4, 0], 1.0));
59    
60    let out: Vec<f64> = fis.compute_outputs(vec![0.6]);
61    println!("{:?}", out);
62}
Source

pub fn add_output(&mut self, variable: TSKOutputVariable)

Examples found in repository?
examples/function_approximation.rs (line 52)
11fn main() {
12    let x1 = 0.0;
13    let x2 = 0.25;
14    let x3 = 0.5;
15    let x4 = 0.75;
16    let x5 = 1.0;
17    let original_function = |x| x * (1.0 - x);
18    let y15 = original_function(x1);
19    let y24 = original_function(x2);
20    let y3 = original_function(x3);
21
22    let mut fis = TSKFIS::new(SNorms::Max, TNorms::Min, TSKDefuzzifiers::Mean);
23
24    let mut x: InputVariable = InputVariable::new("X".to_string(), (0.0, 1.0));
25    x.add_membership(MembershipFunction::new(
26        "x1".to_string(),
27        MFKind::Gaussian(Gaussian::new(x1, 0.09)),
28    ));
29    x.add_membership(MembershipFunction::new(
30        "x2".to_string(),
31        MFKind::Gaussian(Gaussian::new(x2, 0.09)),
32    ));
33    x.add_membership(MembershipFunction::new(
34        "x3".to_string(),
35        MFKind::Gaussian(Gaussian::new(x3, 0.09)),
36    ));
37    x.add_membership(MembershipFunction::new(
38        "x4".to_string(),
39        MFKind::Gaussian(Gaussian::new(x4, 0.09)),
40    ));
41    x.add_membership(MembershipFunction::new(
42        "x5".to_string(),
43        MFKind::Gaussian(Gaussian::new(x5, 0.09)),
44    ));
45    fis.add_input(x);
46
47    let mut y: TSKOutputVariable = TSKOutputVariable::new("Y".to_string());
48    y.add_constant_membership(y15);
49    y.add_constant_membership(y24);
50    y.add_constant_membership(y3);
51
52    fis.add_output(y);
53
54    fis.add_rule(Rule::new_and(vec![0, 0], 1.0));
55    fis.add_rule(Rule::new_and(vec![1, 1], 1.0));
56    fis.add_rule(Rule::new_and(vec![2, 2], 1.0));
57    fis.add_rule(Rule::new_and(vec![3, 1], 1.0));
58    fis.add_rule(Rule::new_and(vec![4, 0], 1.0));
59    
60    let out: Vec<f64> = fis.compute_outputs(vec![0.6]);
61    println!("{:?}", out);
62}
Source

pub fn add_rule(&mut self, rule: Rule)

Examples found in repository?
examples/function_approximation.rs (line 54)
11fn main() {
12    let x1 = 0.0;
13    let x2 = 0.25;
14    let x3 = 0.5;
15    let x4 = 0.75;
16    let x5 = 1.0;
17    let original_function = |x| x * (1.0 - x);
18    let y15 = original_function(x1);
19    let y24 = original_function(x2);
20    let y3 = original_function(x3);
21
22    let mut fis = TSKFIS::new(SNorms::Max, TNorms::Min, TSKDefuzzifiers::Mean);
23
24    let mut x: InputVariable = InputVariable::new("X".to_string(), (0.0, 1.0));
25    x.add_membership(MembershipFunction::new(
26        "x1".to_string(),
27        MFKind::Gaussian(Gaussian::new(x1, 0.09)),
28    ));
29    x.add_membership(MembershipFunction::new(
30        "x2".to_string(),
31        MFKind::Gaussian(Gaussian::new(x2, 0.09)),
32    ));
33    x.add_membership(MembershipFunction::new(
34        "x3".to_string(),
35        MFKind::Gaussian(Gaussian::new(x3, 0.09)),
36    ));
37    x.add_membership(MembershipFunction::new(
38        "x4".to_string(),
39        MFKind::Gaussian(Gaussian::new(x4, 0.09)),
40    ));
41    x.add_membership(MembershipFunction::new(
42        "x5".to_string(),
43        MFKind::Gaussian(Gaussian::new(x5, 0.09)),
44    ));
45    fis.add_input(x);
46
47    let mut y: TSKOutputVariable = TSKOutputVariable::new("Y".to_string());
48    y.add_constant_membership(y15);
49    y.add_constant_membership(y24);
50    y.add_constant_membership(y3);
51
52    fis.add_output(y);
53
54    fis.add_rule(Rule::new_and(vec![0, 0], 1.0));
55    fis.add_rule(Rule::new_and(vec![1, 1], 1.0));
56    fis.add_rule(Rule::new_and(vec![2, 2], 1.0));
57    fis.add_rule(Rule::new_and(vec![3, 1], 1.0));
58    fis.add_rule(Rule::new_and(vec![4, 0], 1.0));
59    
60    let out: Vec<f64> = fis.compute_outputs(vec![0.6]);
61    println!("{:?}", out);
62}
Source

pub fn get_s_norm(&self, fuzzified: &[f64]) -> f64

Source

pub fn get_t_norm(&self, fuzzified: &[f64]) -> f64

Source

pub fn get_rules(&self, rule_index: usize) -> &[i32]

Source

pub fn get_input_rules(&self, rule_index: usize) -> &[i32]

Source

pub fn get_output_rules(&self, rule_index: usize) -> &[i32]

Source

pub fn fuzzification(&self, input_vec: Vec<f64>) -> Vec<Vec<f64>>

Source

pub fn connect_inputs(&self, fuzzified: Vec<Vec<f64>>) -> Vec<f64>

Source

pub fn weighed_inputs(&self, connected_inputs: Vec<f64>) -> Vec<f64>

Source

pub fn get_mu(&self, input_vec: &Vec<f64>) -> Vec<Vec<f64>>

Source

pub fn compute_outputs(&self, input: Vec<f64>) -> Vec<f64>

Examples found in repository?
examples/function_approximation.rs (line 60)
11fn main() {
12    let x1 = 0.0;
13    let x2 = 0.25;
14    let x3 = 0.5;
15    let x4 = 0.75;
16    let x5 = 1.0;
17    let original_function = |x| x * (1.0 - x);
18    let y15 = original_function(x1);
19    let y24 = original_function(x2);
20    let y3 = original_function(x3);
21
22    let mut fis = TSKFIS::new(SNorms::Max, TNorms::Min, TSKDefuzzifiers::Mean);
23
24    let mut x: InputVariable = InputVariable::new("X".to_string(), (0.0, 1.0));
25    x.add_membership(MembershipFunction::new(
26        "x1".to_string(),
27        MFKind::Gaussian(Gaussian::new(x1, 0.09)),
28    ));
29    x.add_membership(MembershipFunction::new(
30        "x2".to_string(),
31        MFKind::Gaussian(Gaussian::new(x2, 0.09)),
32    ));
33    x.add_membership(MembershipFunction::new(
34        "x3".to_string(),
35        MFKind::Gaussian(Gaussian::new(x3, 0.09)),
36    ));
37    x.add_membership(MembershipFunction::new(
38        "x4".to_string(),
39        MFKind::Gaussian(Gaussian::new(x4, 0.09)),
40    ));
41    x.add_membership(MembershipFunction::new(
42        "x5".to_string(),
43        MFKind::Gaussian(Gaussian::new(x5, 0.09)),
44    ));
45    fis.add_input(x);
46
47    let mut y: TSKOutputVariable = TSKOutputVariable::new("Y".to_string());
48    y.add_constant_membership(y15);
49    y.add_constant_membership(y24);
50    y.add_constant_membership(y3);
51
52    fis.add_output(y);
53
54    fis.add_rule(Rule::new_and(vec![0, 0], 1.0));
55    fis.add_rule(Rule::new_and(vec![1, 1], 1.0));
56    fis.add_rule(Rule::new_and(vec![2, 2], 1.0));
57    fis.add_rule(Rule::new_and(vec![3, 1], 1.0));
58    fis.add_rule(Rule::new_and(vec![4, 0], 1.0));
59    
60    let out: Vec<f64> = fis.compute_outputs(vec![0.6]);
61    println!("{:?}", out);
62}

Trait Implementations§

Source§

impl Debug for TSKFuzzyInferenceSystem

Source§

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

Formats the value using the given formatter. Read more

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.