jFuzzyLogic/fcl/testDeMorgan_1.fcl

41 lines
930 B
Plaintext
Raw Permalink Normal View History

2014-12-19 14:30:46 +01:00
FUNCTION_BLOCK testDeMorgan1
VAR_INPUT
x1 : REAL;
x2 : REAL;
END_VAR
VAR_OUTPUT
y : REAL;
END_VAR
FUZZIFY x1
TERM value := (0, 1) (0, 1) ;
END_FUZZIFY
FUZZIFY x2
TERM value2 := (0, 1) (0, 1) ;
END_FUZZIFY
DEFUZZIFY y
TERM value := (0, 1) (0, 1) ;
METHOD : COG; // Use 'Center Of Gravity' defuzzification method
DEFAULT := 0; // Default value is 0 (if no rule activates defuzzifier)
END_DEFUZZIFY
RULEBLOCK No1
AND : MIN; // Use 'min' for 'and' (also implicit use 'max' for 'or' to fulfill DeMorgan's Law)
ACT : MIN; // Use 'min' activation method
ACCU : MAX; // Use 'max' accumulation method
RULE 1 : IF NOT(x1 IS value OR x2 IS value2) THEN y IS value;
RULE 2 : IF NOT(x1 IS value) AND NOT(x2 IS value2) THEN y IS value;
RULE 3 : IF NOT(x1 IS value AND x2 IS value2) THEN y IS value;
RULE 4 : IF NOT(x1 IS value) OR NOT(x2 IS value2) THEN y IS value;
END_RULEBLOCK
END_FUNCTION_BLOCK