summaryrefslogtreecommitdiff
path: root/examples/mamdani/octave/mamdani_tip_calculator.fcl
diff options
context:
space:
mode:
Diffstat (limited to 'examples/mamdani/octave/mamdani_tip_calculator.fcl')
-rw-r--r--examples/mamdani/octave/mamdani_tip_calculator.fcl55
1 files changed, 55 insertions, 0 deletions
diff --git a/examples/mamdani/octave/mamdani_tip_calculator.fcl b/examples/mamdani/octave/mamdani_tip_calculator.fcl
new file mode 100644
index 0000000..3ea903a
--- /dev/null
+++ b/examples/mamdani/octave/mamdani_tip_calculator.fcl
@@ -0,0 +1,55 @@
+FUNCTION_BLOCK Mamdani-Tip-Calculator
+
+VAR_INPUT
+ FoodQuality: REAL;
+ Service: REAL;
+END_VAR
+
+VAR_OUTPUT
+ Tip: REAL;
+ CheckPlusTip: REAL;
+END_VAR
+
+FUZZIFY FoodQuality
+ RANGE := (1.000 .. 10.000);
+ TERM Bad := Trapezoid 0.000 1.000 3.000 7.000;
+ TERM Good := Trapezoid 3.000 7.000 10.000 11.000;
+END_FUZZIFY
+
+FUZZIFY Service
+ RANGE := (1.000 .. 10.000);
+ TERM Bad := Trapezoid 0.000 1.000 3.000 7.000;
+ TERM Good := Trapezoid 3.000 7.000 10.000 11.000;
+END_FUZZIFY
+
+DEFUZZIFY Tip
+ RANGE := (0.000 .. 30.000);
+ TERM AboutTenPercent := Gaussian 10.000 2.000;
+ TERM AboutFifteenPercent := Gaussian 15.000 2.000;
+ TERM AboutTwentyPercent := Gaussian 20.000 2.000;
+ METHOD : COG;
+ ACCU : ASUM;
+ DEFAULT := nan;
+END_DEFUZZIFY
+
+DEFUZZIFY CheckPlusTip
+ RANGE := (1.000 .. 1.300);
+ TERM PlusAboutTenPercent := Gaussian 1.100 0.020;
+ TERM PlusAboutFifteenPercent := Gaussian 1.150 0.020;
+ TERM PlusAboutTwentyPercent := Gaussian 1.200 0.020;
+ METHOD : COG;
+ ACCU : ASUM;
+ DEFAULT := nan;
+END_DEFUZZIFY
+
+RULEBLOCK
+ AND : PROD;
+ OR : MAX;
+ ACT : MIN;
+ RULE 1 : if FoodQuality is Bad and Service is Bad then Tip is AboutTenPercent and CheckPlusTip is PlusAboutTenPercent
+ RULE 2 : if FoodQuality is Bad and Service is Good then Tip is AboutFifteenPercent and CheckPlusTip is PlusAboutFifteenPercent
+ RULE 3 : if FoodQuality is Good and Service is Bad then Tip is AboutFifteenPercent and CheckPlusTip is PlusAboutFifteenPercent
+ RULE 4 : if FoodQuality is Good and Service is Good then Tip is AboutTwentyPercent and CheckPlusTip is PlusAboutTwentyPercent
+END_RULEBLOCK
+
+END_FUNCTION_BLOCK