| 1 |
//Code automatically generated with fuzzylite 6.0. |
| 2 |
|
| 3 |
FUNCTION_BLOCK sugeno_tip_calculator |
| 4 |
|
| 5 |
VAR_INPUT |
| 6 |
FoodQuality: REAL; |
| 7 |
Service: REAL; |
| 8 |
END_VAR |
| 9 |
|
| 10 |
VAR_OUTPUT |
| 11 |
CheapTip: REAL; |
| 12 |
AverageTip: REAL; |
| 13 |
GenerousTip: REAL; |
| 14 |
END_VAR |
| 15 |
|
| 16 |
FUZZIFY FoodQuality |
| 17 |
RANGE := (1.000 .. 10.000); |
| 18 |
TERM Bad := Trapezoid 0.000 1.000 3.000 7.000; |
| 19 |
TERM Good := Trapezoid 3.000 7.000 10.000 11.000; |
| 20 |
END_FUZZIFY |
| 21 |
|
| 22 |
FUZZIFY Service |
| 23 |
RANGE := (1.000 .. 10.000); |
| 24 |
TERM Bad := Trapezoid 0.000 1.000 3.000 7.000; |
| 25 |
TERM Good := Trapezoid 3.000 7.000 10.000 11.000; |
| 26 |
END_FUZZIFY |
| 27 |
|
| 28 |
DEFUZZIFY CheapTip |
| 29 |
RANGE := (5.000 .. 25.000); |
| 30 |
TERM Low := 10.000; |
| 31 |
TERM Medium := 15.000; |
| 32 |
TERM High := 20.000; |
| 33 |
METHOD : COGS; |
| 34 |
DEFAULT := nan; |
| 35 |
END_DEFUZZIFY |
| 36 |
|
| 37 |
DEFUZZIFY AverageTip |
| 38 |
RANGE := (5.000 .. 25.000); |
| 39 |
TERM Low := 10.000; |
| 40 |
TERM Medium := 15.000; |
| 41 |
TERM High := 20.000; |
| 42 |
METHOD : COGS; |
| 43 |
DEFAULT := nan; |
| 44 |
END_DEFUZZIFY |
| 45 |
|
| 46 |
DEFUZZIFY GenerousTip |
| 47 |
RANGE := (5.000 .. 25.000); |
| 48 |
TERM Low := 10.000; |
| 49 |
TERM Medium := 15.000; |
| 50 |
TERM High := 20.000; |
| 51 |
METHOD : COGS; |
| 52 |
DEFAULT := nan; |
| 53 |
END_DEFUZZIFY |
| 54 |
|
| 55 |
RULEBLOCK |
| 56 |
AND : EPROD; |
| 57 |
RULE 1 : if FoodQuality is extremely Bad and Service is extremely Bad then CheapTip is extremely Low and AverageTip is very Low and GenerousTip is Low |
| 58 |
RULE 2 : if FoodQuality is Good and Service is extremely Bad then CheapTip is Low and AverageTip is Low and GenerousTip is Medium |
| 59 |
RULE 3 : if FoodQuality is very Good and Service is very Bad then CheapTip is Low and AverageTip is Medium and GenerousTip is High |
| 60 |
RULE 4 : if FoodQuality is Bad and Service is Bad then CheapTip is Low and AverageTip is Low and GenerousTip is Medium |
| 61 |
RULE 5 : if FoodQuality is Good and Service is Bad then CheapTip is Low and AverageTip is Medium and GenerousTip is High |
| 62 |
RULE 6 : if FoodQuality is extremely Good and Service is Bad then CheapTip is Low and AverageTip is Medium and GenerousTip is very High |
| 63 |
RULE 7 : if FoodQuality is Bad and Service is Good then CheapTip is Low and AverageTip is Medium and GenerousTip is High |
| 64 |
RULE 8 : if FoodQuality is Good and Service is Good then CheapTip is Medium and AverageTip is Medium and GenerousTip is very High |
| 65 |
RULE 9 : if FoodQuality is very Bad and Service is very Good then CheapTip is Low and AverageTip is Medium and GenerousTip is High |
| 66 |
RULE 10 : if FoodQuality is very very Good and Service is very very Good then CheapTip is High and AverageTip is very High and GenerousTip is extremely High |
| 67 |
END_RULEBLOCK |
| 68 |
|
| 69 |
END_FUNCTION_BLOCK |