mirror of
https://github.com/marcin-szczepanski/jFuzzyLogic.git
synced 2024-12-26 18:30:28 +01:00
Improved support for memebership functions with variables. Universe recalculation added
This commit is contained in:
parent
fa926d1b2b
commit
8fb48650c1
1
bin/.gitignore
vendored
Normal file
1
bin/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/net/
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,37 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.3" maxVersion="1.6" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jScrollPane2" alignment="1" pref="400" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jScrollPane2" alignment="1" pref="251" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JScrollPane" name="jScrollPane2">
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JEditorPane" name="jEditorPane1">
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Form>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,63 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.3" maxVersion="1.6" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="viewPanel" alignment="1" max="32767" attributes="0"/>
|
||||
<Component id="tabPanel" alignment="0" pref="400" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="viewPanel" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="tabPanel" pref="385" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JPanel" name="viewPanel">
|
||||
<Properties>
|
||||
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
|
||||
<Border info="org.netbeans.modules.form.compat2.border.BevelBorderInfo">
|
||||
<BevelBorder bevelType="1"/>
|
||||
</Border>
|
||||
</Property>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="view;"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="396" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="360" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
</Container>
|
||||
<Container class="javax.swing.JTabbedPane" name="tabPanel">
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout"/>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Form>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,99 +0,0 @@
|
||||
<H1> Fuzzy Control Demo </H1>
|
||||
|
||||
|
||||
|
||||
<p> This demo simulates a cart with an inverted pendulum.
|
||||
The challenge is to keep the system stable by varying the force applied to the cart.
|
||||
This system is just like a unicycle or one of these segway bikes.</p>
|
||||
<br>
|
||||
|
||||
<img align="CENTRE" alt="i2.jpg" src="i2.jpg"></p>
|
||||
|
||||
<br>
|
||||
|
||||
|
||||
<h2> User control</h2>
|
||||
|
||||
<p>
|
||||
The user (that means you) can apply a force by clicking the mouse on the display.
|
||||
The force applied is proportional to the distance from the cart
|
||||
(like an elastic band). See if you can get home without falling over! </p>
|
||||
|
||||
<h2> Fuzzy Logic</h2>
|
||||
|
||||
<p> Fuzzy logic can be used for
|
||||
a wide range of practical applications ranging from what wash to use in your
|
||||
washing machine to the control of robotic limbs.
|
||||
In this demo when the fuzzy logic is enabled the program attempts to
|
||||
control the angle using a set of "fuzzy rules".
|
||||
|
||||
The inputs are:
|
||||
<ul>
|
||||
<li> phi --
|
||||
the difference between the actual angle
|
||||
and the requested angle
|
||||
</li>
|
||||
<li>
|
||||
dphidt -- rate of change of the angle.
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
The ouput of the system is the requested force value.
|
||||
|
||||
|
||||
The fuzzy inference system classifies the
|
||||
input values into degree of membership of fuzzy sets.
|
||||
In this case the sets have names like
|
||||
PB (positive big) PS (positive small) Z (zero) etc.
|
||||
Unlike classical "crisp" logic
|
||||
which only uses 2 values; true and false, the
|
||||
degree of membership of a fuzzy set can be any value between
|
||||
0 (not in the set e.g. false) and 1 (definately in the set e.g. true).</p>
|
||||
|
||||
<p> In this demo the fuzzy controller is define by an FCL (fuzzy control logic) file.
|
||||
You can examine this in the Fuzzy Control Logic tab.
|
||||
In practice this file could be compiled into
|
||||
a program for an embedded micro controller.
|
||||
</p>
|
||||
|
||||
<h2> Why fuzzy logic</h2>
|
||||
|
||||
<p> The big deal with fuzzy logic is that you can define
|
||||
your control system using rules that mean something to a human and avoid
|
||||
the complex maths required for some types of classical control. It is common
|
||||
to create fuzzy controllers by asking experts what rules they use.
|
||||
</p>
|
||||
|
||||
<p>In this demo the rule. </p>
|
||||
|
||||
<code>
|
||||
IF phi IS PS AND dphidt IS PB THEN force IS PB ;
|
||||
</code>
|
||||
|
||||
<p> says we should apply a positive big force if the
|
||||
angle is positive small and the rate of change is positive big. </p>
|
||||
|
||||
<p> All the rules for the force are combined in a process called defuzzification which
|
||||
which creates a final real value for the force from the degree of membership functions.</p
|
||||
|
||||
|
||||
<H2> Graphs tab</H2>
|
||||
|
||||
<p> The Graphs tab shows an animation of how the fuzzy system is working. The
|
||||
coloured sections are the fuzzy sets which map the crisp value
|
||||
into a degree of membership. The defuzzication of the force is done by taking the
|
||||
centre of gravity of the force graph.
|
||||
</p>
|
||||
|
||||
<p> The rule set for this demo was created in a hurry
|
||||
by the author in order to get
|
||||
the demo working.
|
||||
The rules can be edited
|
||||
(and possibly saved but this feature is untested on windows)
|
||||
using the Fuzzy Control Logic tab.
|
||||
If you manage to create a better system please let me have
|
||||
a copy :-)
|
||||
</p>
|
||||
|
||||
<p> PJ.Leonard</p>
|
@ -1,11 +0,0 @@
|
||||
<h2> Credits </h2>
|
||||
|
||||
<p>
|
||||
This demo was created by
|
||||
PJ.Leonard (Department of Electrical Engineering. Unversity of Bath).</p><p>
|
||||
The fuzzy logic engine is jFuzzyLogic an open source software maintained by
|
||||
Pablo Cingolani.</p><p> The inverted pendulum dynamic simulation is
|
||||
by Andrew Kaluzniacki.
|
||||
</p>.
|
||||
|
||||
<br><p>This program is written in JAVA</p>
|
Binary file not shown.
Before Width: | Height: | Size: 551 B |
Binary file not shown.
Before Width: | Height: | Size: 16 KiB |
@ -1,59 +0,0 @@
|
||||
FUNCTION_BLOCK IPController // control block for the angle
|
||||
|
||||
VAR_OUTPUT // define output variables
|
||||
force : REAL;
|
||||
END_VAR
|
||||
|
||||
VAR_INPUT // inputs
|
||||
phi : REAL; // the difference between the requested and real angle. We want this to be zero
|
||||
dphidt : REAL; // rate of change of the real angle. We also want this to be zero.
|
||||
END_VAR
|
||||
|
||||
|
||||
FUZZIFY phi // define the membership functions (see graph tab in the demo)
|
||||
TERM Z := TRIAN -5 0 5; // zero (ish)
|
||||
TERM PS := TRIAN 0 5 10; // positive small
|
||||
TERM NS := TRIAN -10 -5 0; // neg small
|
||||
TERM PB := (5,0) (10,1) (60,1) (70,0); // pos big
|
||||
TERM NB := (-70,0) (-60,1) (-10, 1) (-5,0); // neg big
|
||||
|
||||
END_FUZZIFY
|
||||
|
||||
FUZZIFY dphidt
|
||||
TERM Z := TRIAN -8 0 8;
|
||||
TERM PS := TRIAN 0 8 200 ;
|
||||
TERM NS := TRIAN -200 -8 0 ;
|
||||
TERM PB := (8,0) (200,1) (500,1) ;
|
||||
TERM NB := (-500,1) (-200,1) (-8,0);
|
||||
END_FUZZIFY
|
||||
|
||||
|
||||
DEFUZZIFY force
|
||||
TERM Z := 0 ; // TRIAN -20 0 20;
|
||||
TERM PS := 50 ;// TRIAN 30 50 70;
|
||||
TERM NS := -50 ;//TRIAN -70 -50 -30;
|
||||
TERM PB := 200 ;// TRIAN 190 200 210;
|
||||
TERM NB := -200 ;// TRIAN -210 -200 -190;
|
||||
|
||||
METHOD : COGS; // Use 'Center Of Gravity' defuzzification method
|
||||
DEFAULT := 0; // Default value is 0 (if no rule activates defuzzifier)
|
||||
END_DEFUZZIFY
|
||||
|
||||
RULEBLOCK No1 // Rules
|
||||
AND : MIN; // defines how we combine sets
|
||||
ACT : MIN; // how we activate outputs which have more than 1 rule
|
||||
ACCU : MAX; // how we combine the membership functions of the output variables.
|
||||
|
||||
// now the rules . . .
|
||||
|
||||
RULE 1 : IF phi IS PS AND (dphidt IS PS OR dphidt IS Z) THEN force IS PS;
|
||||
RULE 2 : IF phi IS PS AND dphidt IS PB THEN force IS PB ;
|
||||
RULE 3 : IF phi IS NS AND (dphidt IS NS OR dphidt IS Z) THEN force IS NS;
|
||||
RULE 4 : IF phi IS NS AND dphidt IS NB THEN force IS NB ;
|
||||
RULE 5 : IF phi IS PB AND (dphidt IS NOT NB) AND (dphidt IS NOT NS) THEN force IS PB ;
|
||||
RULE 6 : IF phi IS NB AND (dphidt IS NOT PB) AND (dphidt IS NOT PS) THEN force IS NB ;
|
||||
RULE 7 : IF phi IS Z AND dphidt IS Z THEN force IS Z;
|
||||
|
||||
END_RULEBLOCK
|
||||
|
||||
END_FUNCTION_BLOCK
|
Binary file not shown.
Before Width: | Height: | Size: 158 B |
Binary file not shown.
Before Width: | Height: | Size: 158 B |
Binary file not shown.
Before Width: | Height: | Size: 514 B |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,49 +0,0 @@
|
||||
<H1> Fuzzy Control Demo </H1>
|
||||
|
||||
|
||||
|
||||
<p>
|
||||
|
||||
This demo simulates a 2 link robot arm.
|
||||
|
||||
<p>
|
||||
<br>
|
||||
|
||||
<img align="CENTRE" alt="arm.png" src="arm.png"></p>
|
||||
|
||||
<br>
|
||||
<p>
|
||||
|
||||
<h2> Control</h2>
|
||||
|
||||
The user (that is you) can click on the screen to specify the desired location of the "hand".
|
||||
The controller works out the angles needed to achieve this "target" position and uses the
|
||||
difference between the actual values and the target as inputs to the fuzzy control system.
|
||||
The angular velocities are also used in the fuzzy control system to provide damping.
|
||||
|
||||
|
||||
The inputs are:
|
||||
<ul>
|
||||
<li> phi1 and phi2 --
|
||||
the difference between the actual angle
|
||||
and the requested angle
|
||||
</li>
|
||||
<li>
|
||||
dphi1dt and dphi2dt-- rate of change of the angles.
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
The ouput of the system is the torques for the joints torque1 and torque2
|
||||
|
||||
|
||||
<p> The rule set for this demo was created in a hurry
|
||||
by the author in order to get the demo working.
|
||||
The rules can be edited
|
||||
(and possibly saved but this feature is untested on windows)
|
||||
using the Fuzzy Control Logic tab.
|
||||
If you manage to create a better system please let me have
|
||||
a copy :-)
|
||||
</p>
|
||||
|
||||
<p> PJ.Leonard</p>
|
@ -1,99 +0,0 @@
|
||||
FUNCTION_BLOCK arm // Block definition (there may be more than one block per file)
|
||||
|
||||
VAR_OUTPUT // Define input variables
|
||||
torque1 : REAL;
|
||||
torque2 : REAL;
|
||||
END_VAR
|
||||
|
||||
VAR_INPUT // Define output variables
|
||||
dphi1dt : REAL;
|
||||
dphi2dt : REAL;
|
||||
phi1: REAL;
|
||||
phi2: REAL;
|
||||
END_VAR
|
||||
|
||||
FUZZIFY phi1
|
||||
TERM nb := (-2, 1) (-0.5 ,1) (-0.001,0);
|
||||
TERM ns := TRIAN -0.5 -0.001 0;
|
||||
TERM ok := TRIAN -0.001 0 0.001;
|
||||
TERM ps := TRIAN 0 0.001 0.5;
|
||||
TERM pb := (0.001,0) (0.5,1) (2, 1);
|
||||
END_FUZZIFY
|
||||
|
||||
FUZZIFY phi2
|
||||
TERM nb := (-2, 1) (-0.5 ,1) (-0.001,0);
|
||||
TERM ns := TRIAN -0.5 -0.001 0;
|
||||
TERM ok := TRIAN -0.001 0 0.01;
|
||||
TERM ps := TRIAN 0 0.001 0.5;
|
||||
TERM pb := (0.001,0) (0.5,1) (2, 1);
|
||||
END_FUZZIFY
|
||||
|
||||
|
||||
FUZZIFY dphi1dt
|
||||
TERM nb := (-10, 1) (-1 ,1) (-0.3,0);
|
||||
TERM ns := TRIAN -1 -0.3 0;
|
||||
TERM ok := TRIAN -0.3 0 0.3;
|
||||
TERM ps := TRIAN 0 0.3 1;
|
||||
TERM pb := (0.3,0) (1,1) (10, 1);
|
||||
END_FUZZIFY
|
||||
|
||||
FUZZIFY dphi2dt
|
||||
TERM nb := (-10, 1) (-1 ,1) (-0.3,0);
|
||||
TERM ns := TRIAN -1 -0.3 0;
|
||||
TERM ok := TRIAN -0.3 0 0.3;
|
||||
TERM ps := TRIAN 0 0.3 1;
|
||||
TERM pb := (0.3,0) (1,1) (10, 1);
|
||||
END_FUZZIFY
|
||||
|
||||
DEFUZZIFY torque1
|
||||
TERM nb := -800 ;
|
||||
TERM ns := -400 ;
|
||||
TERM zero := 0 ;
|
||||
TERM ps := 400 ;
|
||||
TERM pb := 800 ;
|
||||
|
||||
METHOD : COGS;
|
||||
DEFAULT := 0;
|
||||
END_DEFUZZIFY
|
||||
|
||||
DEFUZZIFY torque2
|
||||
TERM nb := -500 ;
|
||||
TERM ns := -200 ;
|
||||
TERM zero := 0 ;
|
||||
TERM ps := 200 ;
|
||||
TERM pb := 500 ;
|
||||
|
||||
METHOD : COGS;
|
||||
DEFAULT := 0;
|
||||
END_DEFUZZIFY
|
||||
|
||||
|
||||
RULEBLOCK No1
|
||||
AND : MIN;
|
||||
ACCU : MAX;
|
||||
ACT : MIN;
|
||||
|
||||
RULE 1 : IF phi1 IS nb THEN torque1 IS pb;
|
||||
/*
|
||||
RULE 2 : IF phi1 IS ns THEN torque1 IS ps;
|
||||
RULE 3 : IF phi1 IS ok THEN torque1 IS zero;
|
||||
RULE 4 : IF phi1 IS ps THEN torque1 IS ns;
|
||||
RULE 5 : IF phi1 IS pb THEN torque1 IS nb;
|
||||
RULE 6 : IF dphi1dt IS nb THEN torque1 IS pb;
|
||||
RULE 7 : IF dphi1dt IS pb THEN torque1 IS nb;
|
||||
RULE 8 : IF dphi1dt IS ns AND phi1 is ok THEN torque1 IS pb;
|
||||
RULE 9 : IF dphi1dt IS ps AND phi1 is ok THEN torque1 IS nb;
|
||||
RULE 11 : IF phi2 IS nb THEN torque2 IS pb;
|
||||
RULE 12 : IF phi2 IS ns THEN torque2 IS ps;
|
||||
RULE 13 : IF phi2 IS ok THEN torque2 IS zero;
|
||||
RULE 14 : IF phi2 IS ps THEN torque2 IS ns;
|
||||
RULE 15 : IF phi2 IS pb THEN torque2 IS nb;
|
||||
RULE 16 : IF dphi2dt IS nb THEN torque2 IS pb;
|
||||
RULE 17 : IF dphi2dt IS pb THEN torque2 IS nb;
|
||||
RULE 18 : IF dphi2dt IS ns AND phi2 is ok THEN torque2 IS pb;
|
||||
RULE 19 : IF dphi2dt IS ps AND phi2 is ok THEN torque2 IS nb;
|
||||
*/
|
||||
END_RULEBLOCK
|
||||
|
||||
|
||||
END_FUNCTION_BLOCK
|
Binary file not shown.
Before Width: | Height: | Size: 1.0 KiB |
@ -1,14 +0,0 @@
|
||||
<h2> Credits </h2>
|
||||
|
||||
<p>
|
||||
This demo was created by
|
||||
PJ.Leonard (Department of Electrical Engineering. Unversity of Bath).</p>
|
||||
<p>
|
||||
The fuzzy logic engine is jFuzzyLogic an open source software maintained by
|
||||
Pablo Cingolani.</p>
|
||||
|
||||
<p>
|
||||
Thanks to Necip and Pejman for helping with the dynamic simulation.
|
||||
</p>.
|
||||
|
||||
<br><p>This program is written in JAVA</p>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,100 +0,0 @@
|
||||
<H1> Fuzzy Control Demo </H1>
|
||||
|
||||
|
||||
|
||||
<p>
|
||||
|
||||
This demo simulates a 2 link robot arm.
|
||||
|
||||
<br>
|
||||
|
||||
<img align="CENTRE" alt="i2.jpg" src="i2.jpg"></p>
|
||||
|
||||
<br>
|
||||
|
||||
|
||||
<h2> User control</h2>
|
||||
|
||||
<p>
|
||||
The user (that means you) can apply a force by clicking the mouse on the display.
|
||||
The force applied is proportional to the distance from the cart
|
||||
(like an elastic band). See if you can get home without falling over! </p>
|
||||
|
||||
<h2> Fuzzy Logic</h2>
|
||||
|
||||
<p> Fuzzy logic can be used for
|
||||
a wide range of practical applications ranging from what wash to use in your
|
||||
washing machine to the control of robotic limbs.
|
||||
In this demo when the fuzzy logic is enabled the program attempts to
|
||||
control the angle using a set of "fuzzy rules".
|
||||
|
||||
The inputs are:
|
||||
<ul>
|
||||
<li> phi --
|
||||
the difference between the actual angle
|
||||
and the requested angle
|
||||
</li>
|
||||
<li>
|
||||
dphidt -- rate of change of the angle.
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
The ouput of the system is the requested force value.
|
||||
|
||||
|
||||
The fuzzy inference system classifies the
|
||||
input values into degree of membership of fuzzy sets.
|
||||
In this case the sets have names like
|
||||
PB (positive big) PS (positive small) Z (zero) etc.
|
||||
Unlike classical "crisp" logic
|
||||
which only uses 2 values; true and false, the
|
||||
degree of membership of a fuzzy set can be any value between
|
||||
0 (not in the set e.g. false) and 1 (definately in the set e.g. true).</p>
|
||||
|
||||
<p> In this demo the fuzzy controller is define by an FCL (fuzzy control logic) file.
|
||||
You can examine this in the Fuzzy Control Logic tab.
|
||||
In practice this file could be compiled into
|
||||
a program for an embedded micro controller.
|
||||
</p>
|
||||
|
||||
<h2> Why fuzzy logic</h2>
|
||||
|
||||
<p> The big deal with fuzzy logic is that you can define
|
||||
your control system using rules that mean something to a human and avoid
|
||||
the complex maths required for some types of classical control. It is common
|
||||
to create fuzzy controllers by asking experts what rules they use.
|
||||
</p>
|
||||
|
||||
<p>In this demo the rule. </p>
|
||||
|
||||
<code>
|
||||
IF phi IS PS AND dphidt IS PB THEN force IS PB ;
|
||||
</code>
|
||||
|
||||
<p> says we should apply a positive big force if the
|
||||
angle is positive small and the rate of change is positive big. </p>
|
||||
|
||||
<p> All the rules for the force are combined in a process called defuzzification which
|
||||
which creates a final real value for the force from the degree of membership functions.</p
|
||||
|
||||
|
||||
<H2> Graphs tab</H2>
|
||||
|
||||
<p> The Graphs tab shows an animation of how the fuzzy system is working. The
|
||||
coloured sections are the fuzzy sets which map the crisp value
|
||||
into a degree of membership. The defuzzication of the force is done by taking the
|
||||
centre of gravity of the force graph.
|
||||
</p>
|
||||
|
||||
<p> The rule set for this demo was created in a hurry
|
||||
by the author in order to get
|
||||
the demo working.
|
||||
The rules can be edited
|
||||
(and possibly saved but this feature is untested on windows)
|
||||
using the Fuzzy Control Logic tab.
|
||||
If you manage to create a better system please let me have
|
||||
a copy :-)
|
||||
</p>
|
||||
|
||||
<p> PJ.Leonard</p>
|
@ -1,50 +0,0 @@
|
||||
FUNCTION_BLOCK ip // Block definition (there may be more than one block per file)
|
||||
|
||||
VAR_OUTPUT // Define input variables
|
||||
force : REAL;
|
||||
END_VAR
|
||||
|
||||
VAR_INPUT // Define output variable
|
||||
x : REAL;
|
||||
dxdt : REAL;
|
||||
END_VAR
|
||||
|
||||
FUZZIFY x
|
||||
TERM ok := (-0.1,0) (0,1) (0.1,0) ;
|
||||
TERM left := (-2,1) (0,0);
|
||||
TERM right := ( 0, 0) (2,1) ;
|
||||
END_FUZZIFY
|
||||
|
||||
FUZZIFY dxdt
|
||||
TERM ok := TRIAN -1 0 1 ;
|
||||
TERM left := (-1,1) (0,0);
|
||||
TERM right := (0,0) (1,1) ;
|
||||
TERM tooRight := (3,0) (4,1);
|
||||
TERM tooLeft := (-4,1) (-3,0);
|
||||
|
||||
END_FUZZIFY
|
||||
|
||||
|
||||
DEFUZZIFY force
|
||||
TERM zero := TRIAN -1 0 1 ;
|
||||
TERM left := (-101,0) (-100,1) (-99,0);
|
||||
TERM right := (99,0) (100,1) (101,0);
|
||||
|
||||
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 x IS right AND dxdt IS NOT tooLeft THEN force IS left ;
|
||||
RULE 2 : IF x IS left AND dxdt IS NOT tooRight THEN force IS right ;
|
||||
RULE 3 : IF x IS ok AND dxdt IS right THEN force IS left ;
|
||||
RULE 4 : IF x IS ok AND dxdt IS left THEN force IS right ;
|
||||
RULE 5 : IF x IS ok AND dxdt IS ok THEN force IS zero ;
|
||||
|
||||
END_RULEBLOCK
|
||||
|
||||
END_FUNCTION_BLOCK
|
@ -1,11 +0,0 @@
|
||||
<h2> Credits </h2>
|
||||
|
||||
<p>
|
||||
This demo was created by
|
||||
PJ.Leonard (Department of Electrical Engineering. Unversity of Bath).</p><p>
|
||||
The fuzzy logic engine is jFuzzyLogic an open source software maintained by
|
||||
Pablo Cingolani.</p><p> The inverted pendulum dynamic simulation is
|
||||
by Andrew Kaluzniacki.
|
||||
</p>.
|
||||
|
||||
<br><p>This program is written in JAVA</p>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,54 +0,0 @@
|
||||
/*
|
||||
Example: A tip calculation FIS (fuzzy inference system)
|
||||
Calculates tip based on 'servie' and 'food'
|
||||
|
||||
If you want to about thIS example (and fuzzy logic), please
|
||||
read Matlab's tutorial on fuzzy logic toolbox
|
||||
http://www.mathworks.com/access/helpdesk/help/pdf_doc/fuzzy/fuzzy.pdf
|
||||
|
||||
Pablo Cingolani
|
||||
pcingola@users.sourceforge.net
|
||||
*/
|
||||
|
||||
FUNCTION_BLOCK tipper // Block definition (there may be more than one block per file)
|
||||
|
||||
VAR_INPUT // Define input variables
|
||||
service : REAL;
|
||||
food : REAL;
|
||||
END_VAR
|
||||
|
||||
VAR_OUTPUT // Define output variable
|
||||
tip : REAL;
|
||||
END_VAR
|
||||
|
||||
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
|
||||
|
||||
FUZZIFY food // Fuzzify input variable 'food': { 'rancid', 'delicious' }
|
||||
TERM rancid := (0, 1) (1, 1) (3,0) ;
|
||||
TERM delicious := (7,0) (9,1);
|
||||
END_FUZZIFY
|
||||
|
||||
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
|
||||
|
||||
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 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
|
||||
|
Binary file not shown.
Binary file not shown.
@ -1,99 +0,0 @@
|
||||
FUNCTION=34
|
||||
SIGM=61
|
||||
STAR=91
|
||||
LN=43
|
||||
LETTER=96
|
||||
LM=42
|
||||
LOG=44
|
||||
EINSTEIN=26
|
||||
COG=17
|
||||
NOT=52
|
||||
COA=15
|
||||
HAT=81
|
||||
SIN=62
|
||||
EXP=32
|
||||
MM=50
|
||||
COS=20
|
||||
TAN=65
|
||||
LEFT_PARENTHESIS=83
|
||||
COMMENT=99
|
||||
GAUSS2=36
|
||||
NC=51
|
||||
END_RULEBLOCK=30
|
||||
VAR_OUTPUT=72
|
||||
ACT=10
|
||||
END_DEFUZZIFY=27
|
||||
RULE=59
|
||||
NUMBER=93
|
||||
GBELL=37
|
||||
SEMICOLON=89
|
||||
DMIN=24
|
||||
VALUE_REAL=6
|
||||
ALPHANUM=97
|
||||
TYPE_REAL=70
|
||||
ABS=8
|
||||
REAL=98
|
||||
WS=74
|
||||
NSUM=53
|
||||
LEFT_CURLY=82
|
||||
OR=54
|
||||
LOWER=94
|
||||
END_FUZZIFY=29
|
||||
UPPER=95
|
||||
TERM=66
|
||||
COGF=19
|
||||
PROBOR=55
|
||||
RIGHT_CURLY=87
|
||||
NIPMIN=48
|
||||
POINT=4
|
||||
RM=58
|
||||
MAX=45
|
||||
DOTS=80
|
||||
COGS=18
|
||||
ID=102
|
||||
AND=11
|
||||
SUM=64
|
||||
VALUE_ID=7
|
||||
DSIGM=25
|
||||
IF=40
|
||||
SLASH=90
|
||||
THEN=67
|
||||
RIGHT_PARENTHESIS=88
|
||||
COMMA=78
|
||||
IS=41
|
||||
DMAX=23
|
||||
TRAPE=68
|
||||
BDIF=13
|
||||
PROD=56
|
||||
COSINE=16
|
||||
PLUS=86
|
||||
DIGIT=92
|
||||
DOT=79
|
||||
FUNCTION_BLOCK=38
|
||||
WITH=73
|
||||
END_VAR=31
|
||||
ACCU=9
|
||||
ASUM=12
|
||||
PERCENT=85
|
||||
SINGLETONS=63
|
||||
NIPMAX=49
|
||||
ASSIGN_OPERATOR=76
|
||||
TRIAN=69
|
||||
DEFAULT=21
|
||||
HAMACHER=33
|
||||
COMMENT_C=100
|
||||
FCL=5
|
||||
RANGE=57
|
||||
MIN=47
|
||||
MINUS=84
|
||||
DEFUZZIFY=22
|
||||
COLON=77
|
||||
NEWLINE=75
|
||||
COMMENT_SL=101
|
||||
VAR_INPUT=71
|
||||
BSUM=14
|
||||
RULEBLOCK=60
|
||||
FUZZIFY=39
|
||||
END_FUNCTION_BLOCK=28
|
||||
METHOD=46
|
||||
GAUSS=35
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user