FUNCTION_BLOCK functionBlock1 ... END_FUNCTION_BLOCK FUNCTION_BLOCK functionBlock2 ... END_FUNCTION_BLOCK |
FUNCTION_BLOCK functionBlockName VAR_INPUT ... END_VAR VAR_OUTPUT ... END_VAR FUZZIFY inputVariable ... END_FUZZIFY DEFUZZIFY outputVariable ... END_DEFUZZIFY RULEBLOCK No1 ... END_RULEBLOCK END_FUNCTION_BLOCK |
RULE 1 : IF service IS poor OR food IS rancid THEN tip IS cheap; |
ACT : MIN; // Use 'min' activation method |
service IS poor OR food IS rancid |
service IS poor |
service IS NOT excellent |
FUZZIFY service // Fuzzify input variable 'service': {'poor', 'good' , 'excellent'} TERM poor := (0, 1) (4, 0) ; TERM good := (1, 0) (4,1) (6,1) (9,0); TERM excellent := (6, 0) (9, 1); END_FUZZIFY |
e.g.: For an output variable:
DEFUZZIFY tip // Defzzzify output variable 'tip' : {'cheap', 'average', 'generous' } TERM cheap := (0,0) (5,1) (10,0); TERM average := (10,0) (15,1) (20,0); TERM generous := (20,0) (25,1) (30,0); METHOD : COG; // Use 'Center Of Gravity' defuzzification method DEFAULT := 0; // Default value is 0 (if no rule activates defuzzifier) END_DEFUZZIFY |
ACCU : MAX; // Use 'max' accumulation method METHOD : COG; // Use 'Center Of Gravity' defuzzification method |