jFuzzyLogic/html/html_old/example_fcl_content.html

72 lines
1.7 KiB
HTML
Raw Normal View History

2014-12-19 14:30:46 +01:00
<center><h3> FCL Example </h3></center>
This is an example of a Fuzzy Control Language (FCL) program:<p>
<table border=0><tr><td>
<table border=0 bgcolor=#ccfccc><tr><td>
<pre>
// Block definition (there may be more than one block per file)
FUNCTION_BLOCK tipper
// Define input variables
VAR_INPUT
service : REAL;
food : REAL;
END_VAR
// Define output variable
VAR_OUTPUT
tip : REAL;
END_VAR
// Fuzzify input variable 'service'
FUZZIFY service
TERM poor := (0, 1) (4, 0) ;
TERM good := (1, 0) (4,1) (6,1) (9,0);
TERM excellent := (6, 0) (9, 1);
END_FUZZIFY
// Fuzzify input variable 'food'
FUZZIFY food
TERM rancid := (0, 1) (1, 1) (3,0) ;
TERM delicious := (7,0) (9,1);
END_FUZZIFY
// Defzzzify output variable 'tip'
DEFUZZIFY tip
TERM cheap := (0,0) (5,1) (10,0);
TERM average := (10,0) (15,1) (20,0);
TERM generous := (20,0) (25,1) (30,0);
// Use 'Center Of Gravity' defuzzification method
METHOD : COG;
// Default value is 0 (if no rule activates defuzzifier)
DEFAULT := 0;
END_DEFUZZIFY
RULEBLOCK No1
// Use 'min' for 'and' (also implicit use 'max'
// for 'or' to fulfill DeMorgan's Law)
AND : MIN;
// Use 'min' activation method
ACT : MIN;
// Use 'max' accumulation method
ACCU : MAX;
RULE 1 : IF service IS poor OR food IS rancid
THEN tip IS cheap;
RULE 2 : IF service IS good
THEN tip IS average;
RULE 3 : IF service IS excellent AND food IS delicious
THEN tip is generous;
END_RULEBLOCK
END_FUNCTION_BLOCK
</pre>
</td></tr></table>
<table border=0 align=center bgcolor=#aaaaaa><tr><td align=center> See FCL code detailed explanation <a href="fcl.html"><b>here</b></a></td></tr></table>
</td></tr></table>