mirror of
https://github.com/marcin-szczepanski/jFuzzyLogic.git
synced 2024-12-18 16:35:27 +01:00
41 lines
933 B
Plaintext
41 lines
933 B
Plaintext
|
|
||
|
FUNCTION_BLOCK testDeMorgan2
|
||
|
|
||
|
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 : BDIF; // Use 'BDIF' for 'and' (also implicit use 'BSUM' 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
|
||
|
|