jFuzzyLogic/html/html_old/fcl.html
2014-12-19 08:30:46 -05:00

180 lines
6.6 KiB
HTML

<header>
<title> jFuzzyLogic: Open Source Fuzzy Logic (Java) </title>
<link rel="stylesheet" href="style.css" type="text/css" media="screen" />
<style type="text/css" media="all">
body { background: url(./images/bg_gradient.jpg) repeat-x; }
</style>
</header>
<div align="center">
<div id="wrap">
<div id="header">
<div class="logo">
<a href="http://jfuzzylogic.sourceforge.net/">jFuzzyLogic</a>
<p style="font-size: 12pt" align=right><b>Open Source Fuzzy Logic library and FCL language implementation</b></p>
</div>
</div>
<div id="menu">
<ul>
<li><a href="http://jfuzzylogic.sourceforge.net/">Home</a></li>
<li class="page_item"><a href="example_java.html" title="Documentation">Examples</a></li>
<li class="page_item"><a href="classes.html" title="Documentation">Documentation</a></li>
<li class="page_item"><a href="faq.html" title="FAQ">FAQ</a></li>
<li class="page_item"><a href="http://sourceforge.net/projects/jfuzzylogic/files/jfuzzylogic/jFuzzyLogic_v3.0.jar/download" title="Download">Download</a></li>
<li class="page_item"><a href="about.html" title="About">About</a></li>
</ul>
</div>
<div id="content">
<div id="right">
<div class="ltop"></div>
<div class="lmid">
<b>
<center><h2>jFuzzyLogic</h2></center>
<a href="http://sourceforge.net/projects/jfuzzylogic">Download</a><br>
<a href="plugin.html">Eclipse plugin</a><br>
<center>Examples</center>
<a href=example_java.html>Java example</a><br>
<a href=java.html>Java detailed example</a><br>
<a href=example_fcl.html>FCL example</a><br>
<a href=fcl.html>FCL detailed example</a><br>
<a href=example_parametric_optimization.html>Optimization example</a><br>
<center> Documentation </center>
<a href=faq.html>Faq</a><br>
<a href=classes.html>Classes</a><br>
<a href=membership.html>Membership functions</a><br>
<a href="../doc/iec_1131_7_cd1.pdf">FCL (pdf)</a><br>
<a href="about.html">About</a><br>
</b>
</div>
<div class="lbot"></div>
</div>
<div class="entry">
<center><h3> FCL example explained </h3></center>
Fuzzy Control Langage <i><b>FCL</b></i> is defined by IEC 1331 part 7.
It's a simple language to define a fuzzy inferece system.
We'll take a look at an example, for a more detailed explanation, please read the spec.
<p>
Keep in mind that FCL is defined as a 'Control language', so the main concept is a 'control block' which has some input and output variables (it's not a 'programm' in the usual way).<br>
We'll be using this <a href=example_fcl.html>example</a>, first take a look at it.
<p>
Ok, let's try to annalize each line:
<ul>
<li>First you define each <i><b>FUNCTION_BLOCK</b></i> (there may be more than one in each file)
<table border=0 bgcolor=#ccfccc><tr><td><pre> FUNCTION_BLOCK tipper </pre></td></tr></table>
<p>
<li> Then input and output variable/s are defined (variable type is only <i><b>REAL</b></i>, integer is not implemented yet)
<table border=0 bgcolor=#ccfccc><tr><td><pre>
VAR_INPUT
service : REAL;
food : REAL;
END_VAR
VAR_OUTPUT
tip : REAL;
END_VAR
</pre></td></tr></table>
<p>
<li> How each input variable is fuzzified is defined in <i><b>FUZZIFY</b></i> block. In each block we define one or more <i><b>TERMs</b></i> (also called LinguisticTerms). Each term is composed by a name and a membership function. E.g.:
<table border=0 bgcolor=#ccfccc><tr><td><pre>
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
</pre></td></tr></table>
In this lines we define how variable <i><b>service</b></i> will be fuzzified. Three terms are used, for instance term <i><b>poor</b></i> uses a piece-wise linear membership function defined by points x_0 = 0, y_0 = 1 and x_1 = 4, y_1 = 0<br>
<img src=images/service.png><p>
<i><b>food</b></i> variable fuzzify block is define likewise:<p>
<table border=0 bgcolor=#ccfccc><tr><td><pre>
FUZZIFY food
TERM rancid := (0, 1) (1, 1) (3,0) ;
TERM delicious := (7,0) (9,1);
END_FUZZIFY
</pre></td></tr></table><p>
<img src=images/food.png><br>
<p>
<li> Output variables are defuzzified to get a 'real' output number, this is defined in <i><b>DEFUZZIFY</b></i> block. Like FUZZIFY block, linguistic terms (or TERMs) are defined:
<table border=0 bgcolor=#ccfccc><tr><td><pre>
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);
</pre></td></tr></table><p>
<img src=images/tip.png><p>
Then we may define some other parameters:
<table border=0 bgcolor=#ccfccc><tr><td><pre> METHOD : COG; </pre></td></tr></table>
Use 'Center of gravity' as defuzzifier's method.<p>
<table border=0 bgcolor=#ccfccc><tr><td><pre> DEFAULT := 0; </pre></td></tr></table>
Use '0' as default value (if no rule actuvates this variable).<p>
</pre></td></tr></table>
<li> We can define now the rules. This is done using a <i><b>RULEBLOCK</b></i>. First we define some parameters:
<table border=0 bgcolor=#ccfccc><tr><td><pre>
RULEBLOCK No1
AND : MIN;
</pre></td></tr></table>
Use 'min' for 'and' (also implicit use 'max' for 'or' to fulfill DeMorgan's Law) <p>
<table border=0 bgcolor=#ccfccc><tr><td><pre> ACT : MIN; </pre></td></tr></table>
Use 'min' activation method<p>
<table border=0 bgcolor=#ccfccc><tr><td><pre> ACCU : MAX; </pre></td></tr></table>
Use 'maximum' as accumulation method.<p>
And now define some rules (3 in this case)
<table border=0 bgcolor=#ccfccc><tr><td><pre>
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
</pre></td></tr></table>
Ok, that's it, you've got a fuzzy controller.
<p style="font-size: 8pt" align=center><font color=#777777> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - </font></p>
<center><b>Author: <a class="body" href="http://www.mcb.mcgill.ca/~pcingola/">Pablo Cingolani</a> (pcingola@users.sourceforge.net</a>)</b></center>
</div>
</div>
</div>
</div>
<center>
<font color=ffffff>
Key words (for search engines): <br>
Fuzzy logic <br>
Fuzzy logic software <br>
Fuzzy logic package <br>
Fuzzy logic library <br>
Fuzzy logic sourceforge sf.net <br>
Open source <br>
GNU <br>
GPL LGPL <br>
java <br>
Windows Linux OSX <br>
FCL <br>
IEC 1131 <br>
IEC 61131 <br>
IEC 61131 part 7 <br>
IEC 61131-7 <br>
<a href="http://en.wikipedia.org/wiki/Fuzzy_logic">Fuzzy logic Wikipedia</a> <br>
</font>
</center>