blob: ad98f68632052626417fb8fd6ae6c75b389c2840 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
FUNCTION_BLOCK Sugeno-Tip-Calculator
VAR_INPUT
FoodQuality: REAL;
Service: REAL;
END_VAR
VAR_OUTPUT
CheapTip: REAL;
AverageTip: REAL;
GenerousTip: 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 CheapTip
RANGE := (5.000 .. 25.000);
TERM Low := 10.000;
TERM Medium := 15.000;
TERM High := 20.000;
METHOD : COGS;
DEFAULT := nan;
END_DEFUZZIFY
DEFUZZIFY AverageTip
RANGE := (5.000 .. 25.000);
TERM Low := 10.000;
TERM Medium := 15.000;
TERM High := 20.000;
METHOD : COGS;
DEFAULT := nan;
END_DEFUZZIFY
DEFUZZIFY GenerousTip
RANGE := (5.000 .. 25.000);
TERM Low := 10.000;
TERM Medium := 15.000;
TERM High := 20.000;
METHOD : COGS;
DEFAULT := nan;
END_DEFUZZIFY
RULEBLOCK
AND : EPROD;
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
RULE 2 : if FoodQuality is Good and Service is extremely Bad then CheapTip is Low and AverageTip is Low and GenerousTip is Medium
RULE 3 : if FoodQuality is very Good and Service is very Bad then CheapTip is Low and AverageTip is Medium and GenerousTip is High
RULE 4 : if FoodQuality is Bad and Service is Bad then CheapTip is Low and AverageTip is Low and GenerousTip is Medium
RULE 5 : if FoodQuality is Good and Service is Bad then CheapTip is Low and AverageTip is Medium and GenerousTip is High
RULE 6 : if FoodQuality is extremely Good and Service is Bad then CheapTip is Low and AverageTip is Medium and GenerousTip is very High
RULE 7 : if FoodQuality is Bad and Service is Good then CheapTip is Low and AverageTip is Medium and GenerousTip is High
RULE 8 : if FoodQuality is Good and Service is Good then CheapTip is Medium and AverageTip is Medium and GenerousTip is very High
RULE 9 : if FoodQuality is very Bad and Service is very Good then CheapTip is Low and AverageTip is Medium and GenerousTip is High
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
END_RULEBLOCK
END_FUNCTION_BLOCK
|