From: <lm...@us...> - 2011-07-19 17:59:41
|
Revision: 8391 http://octave.svn.sourceforge.net/octave/?rev=8391&view=rev Author: lmarkov Date: 2011-07-19 17:59:30 +0000 (Tue, 19 Jul 2011) Log Message: ----------- M fuzzy-logic-toolkit/DESCRIPTION M fuzzy-logic-toolkit/ChangeLog M fuzzy-logic-toolkit/INDEX A fuzzy-logic-toolkit/inst/mamdani_tip_demo.m M fuzzy-logic-toolkit/inst/rmvar.m M fuzzy-logic-toolkit/inst/writefis.m A fuzzy-logic-toolkit/inst/cubic-approximator.fis M fuzzy-logic-toolkit/inst/addvar.m M fuzzy-logic-toolkit/inst/showrule.m M fuzzy-logic-toolkit/inst/gensurf.m D fuzzy-logic-toolkit/inst/mamdani_demo.m M fuzzy-logic-toolkit/inst/showrule_demo.m M fuzzy-logic-toolkit/inst/addmf_demo.m A fuzzy-logic-toolkit/inst/sugeno_tip_demo.m A fuzzy-logic-toolkit/inst/linear-tip-calculator.fis M fuzzy-logic-toolkit/inst/getfis.m M fuzzy-logic-toolkit/inst/showfis.m A fuzzy-logic-toolkit/inst/cubic_approx_demo.m A fuzzy-logic-toolkit/inst/heart_demo_1.m A fuzzy-logic-toolkit/inst/heart_demo_2.m M fuzzy-logic-toolkit/inst/evalfis.m A fuzzy-logic-toolkit/inst/linear_tip_demo.m D fuzzy-logic-toolkit/inst/commandline_demo.m M fuzzy-logic-toolkit/inst/setfis.m M fuzzy-logic-toolkit/inst/rmmf.m M fuzzy-logic-toolkit/inst/plotmf.m M fuzzy-logic-toolkit/inst/addvar_demo.m D fuzzy-logic-toolkit/inst/heart_demo.m M fuzzy-logic-toolkit/inst/defuzz.m M fuzzy-logic-toolkit/inst/evalmf.m M fuzzy-logic-toolkit/inst/addmf.m M fuzzy-logic-toolkit/inst/readfis.m D fuzzy-logic-toolkit/inst/tipping_demo.m M fuzzy-logic-toolkit/inst/private/defuzzify_output_mamdani.m M fuzzy-logic-toolkit/inst/private/aggregate_output_sugeno.m M fuzzy-logic-toolkit/inst/private/eval_firing_strength.m M fuzzy-logic-toolkit/inst/private/eval_rules_sugeno.m M fuzzy-logic-toolkit/inst/private/fuzzify_input.m M fuzzy-logic-toolkit/inst/private/eval_rules_mamdani.m M fuzzy-logic-toolkit/inst/private/aggregate_output_mamdani.m M fuzzy-logic-toolkit/inst/private/defuzzify_output_sugeno.m M fuzzy-logic-toolkit/inst/addrule.m Modified Paths: -------------- trunk/octave-forge/main/fuzzy-logic-toolkit/ChangeLog trunk/octave-forge/main/fuzzy-logic-toolkit/DESCRIPTION trunk/octave-forge/main/fuzzy-logic-toolkit/INDEX trunk/octave-forge/main/fuzzy-logic-toolkit/inst/addmf.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/addmf_demo.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/addrule.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/addvar.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/addvar_demo.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/defuzz.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/evalfis.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/evalmf.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/gensurf.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/getfis.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/plotmf.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/private/aggregate_output_mamdani.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/private/aggregate_output_sugeno.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/private/defuzzify_output_mamdani.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/private/defuzzify_output_sugeno.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/private/eval_firing_strength.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/private/eval_rules_mamdani.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/private/eval_rules_sugeno.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/private/fuzzify_input.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/readfis.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/rmmf.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/rmvar.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/setfis.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/showfis.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/showrule.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/showrule_demo.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/writefis.m Added Paths: ----------- trunk/octave-forge/main/fuzzy-logic-toolkit/inst/cubic-approximator.fis trunk/octave-forge/main/fuzzy-logic-toolkit/inst/cubic_approx_demo.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/heart_demo_1.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/heart_demo_2.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/linear-tip-calculator.fis trunk/octave-forge/main/fuzzy-logic-toolkit/inst/linear_tip_demo.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/mamdani_tip_demo.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/sugeno_tip_demo.m Removed Paths: ------------- trunk/octave-forge/main/fuzzy-logic-toolkit/inst/commandline_demo.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/heart_demo.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/mamdani_demo.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/tipping_demo.m Modified: trunk/octave-forge/main/fuzzy-logic-toolkit/ChangeLog =================================================================== --- trunk/octave-forge/main/fuzzy-logic-toolkit/ChangeLog 2011-07-19 15:08:02 UTC (rev 8390) +++ trunk/octave-forge/main/fuzzy-logic-toolkit/ChangeLog 2011-07-19 17:59:30 UTC (rev 8391) @@ -1,31 +1,51 @@ +2011-07-19 Version 0.2.3 + + * ChangeLog: Updated file. + * DESCRIPTION: Updated file. + * INDEX: Updated file. + * inst/*.m: Edited numerous comments and texinfo comment blocks. + * inst/private/*.m: Edited numerous comments and texinfo comment blocks. + * inst/cubic_approx_demo.m: New file. + * inst/cubic-approximator.fis: New file. + * inst/linear-tip-calculator.fis: New file. + * inst/linear_tip_demo.m: New file. + * inst/heart_demo_1.m: Renamed commandline_demo.m. + * inst/heart_demo_2.m: Renamed heart_demo.m. + * inst/mamdani_tip_demo.m: Renamed mamdani_demo.m. + * inst/sugeno_tip_demo.m: Renamed tipping_demo.m. + * inst/gensurf.m: Edited to handle 2-dimensional plots. + * inst/private/eval_rules_sugeno.m: Edited to handle linear output membership functions. + * Demos tested under: Fedora 15/Octave 3.4.0 + * Demos tested under: Fedora 15/Octave 3.2.4 + 2011-06-21 Version 0.2.2 * ChangeLog: New file. - * DESCRIPTION: Update file. - * inst/addmf.m: Modify to workaround a bug in Octave 3.4.0. - * inst/addrule.m: Modify to workaround a bug in Octave 3.4.0. - * inst/addvar.m: Modify to workaround a bug in Octave 3.4.0. - * inst/gaussmf.m: Modify demo and texinfo comment string. - * inst/getfis.m: Modify to workaround a bug in Octave 3.4.0. - * inst/readfis.m: Modify to workaround a bug in Octave 3.4.0. - * inst/private/aggregate_output_mamdani.m: Modify to workaround a bug in Octave 3.4.0. - * inst/private/evalmf_private.m: Modify to workaround a bug in Octave 3.4.0. + * DESCRIPTION: Updated file. + * inst/addmf.m: Modified to workaround a bug in Octave 3.4.0. + * inst/addrule.m: Modified to workaround a bug in Octave 3.4.0. + * inst/addvar.m: Modified to workaround a bug in Octave 3.4.0. + * inst/gaussmf.m: Modified demo and texinfo comment string. + * inst/getfis.m: Modified to workaround a bug in Octave 3.4.0. + * inst/readfis.m: Modified to workaround a bug in Octave 3.4.0. + * inst/private/aggregate_output_mamdani.m: Modified to workaround a bug in Octave 3.4.0. + * inst/private/evalmf_private.m: Modified to workaround a bug in Octave 3.4.0. * Demos tested under: Fedora 15/Octave 3.4.0 * Demos tested under: Fedora 15/Octave 3.2.4 2011-06-08 Version 0.2.1 * Initial release on Octave-Forge. - * Merge membership function demos into related function files. - * Create documentation for Octave-Forge website. - * DESCRIPTION: Update file. + * Merged membership function demos into related function files. + * Created documentation for Octave-Forge website. + * DESCRIPTION: Updated file. * Demos tested under: Fedora 13/Octave 3.2.4 2011-05-25 Version 0.2 - * Move tests/demos/* and tests/fis/* to inst/*. - * Change indentation and spacing to conform to Octave style. - * Convert comments to texinfo. + * Moved tests/demos/* and tests/fis/* to inst/*. + * Changed indentation and spacing to conform to Octave style. + * Converted comments to texinfo. * DESCRIPTION: Update file. * Demos tested under: Fedora 13/Octave 3.2.4 Modified: trunk/octave-forge/main/fuzzy-logic-toolkit/DESCRIPTION =================================================================== --- trunk/octave-forge/main/fuzzy-logic-toolkit/DESCRIPTION 2011-07-19 15:08:02 UTC (rev 8390) +++ trunk/octave-forge/main/fuzzy-logic-toolkit/DESCRIPTION 2011-07-19 17:59:30 UTC (rev 8391) @@ -1,11 +1,12 @@ Name: fuzzy-logic-toolkit -Version: 0.2.2 -Date: 2011-6-21 +Version: 0.2.3 +Date: 2011-7-19 Author: L. Markowsky <lm...@us...> Maintainer: L. Markowsky <lm...@us...> Title: Octave Fuzzy Logic Toolkit Description: A mostly MATLAB-compatible fuzzy logic toolkit for Octave. Depends: octave (>= 3.2.4) + zenity (>= 3.0.0) Autoload: yes License: GPL version 2 or later Url: http://octave.sf.net Modified: trunk/octave-forge/main/fuzzy-logic-toolkit/INDEX =================================================================== --- trunk/octave-forge/main/fuzzy-logic-toolkit/INDEX 2011-07-19 15:08:02 UTC (rev 8390) +++ trunk/octave-forge/main/fuzzy-logic-toolkit/INDEX 2011-07-19 17:59:30 UTC (rev 8391) @@ -43,9 +43,11 @@ Fuzzy Inference System Demos addmf_demo addvar_demo - commandline_demo - heart_demo - mamdani_demo + cubic_approx_demo + heart_demo_1 + heart_demo_2 + linear_tip_demo + mamdani_tip_demo showrule_demo - tipping_demo + sugeno_tip_demo Modified: trunk/octave-forge/main/fuzzy-logic-toolkit/inst/addmf.m =================================================================== --- trunk/octave-forge/main/fuzzy-logic-toolkit/inst/addmf.m 2011-07-19 15:08:02 UTC (rev 8390) +++ trunk/octave-forge/main/fuzzy-logic-toolkit/inst/addmf.m 2011-07-19 17:59:30 UTC (rev 8391) @@ -19,7 +19,7 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {@var{fis} =} addmf (@var{fis}, @var{in_or_out}, @var{var_index}, @var{mf_name}, @var{mf_type}, @var{mf_params}) ## -## Add a membership function to an existing FIS (Fuzzy Inference System) +## Add a membership function to an existing FIS ## structure and return the updated FIS. ## ## The types of the arguments are expected to be: @@ -96,7 +96,7 @@ ## Keywords: fuzzy-logic-toolkit fuzzy membership-function membership ## Directory: fuzzy-logic-toolkit/inst/ ## Filename: addmf.m -## Last-Modified: 20 Jun 2011 +## Last-Modified: 16 Jul 2011 function fis = addmf (fis, in_or_out, var_index, mf_name, mf_type, mf_params) Modified: trunk/octave-forge/main/fuzzy-logic-toolkit/inst/addmf_demo.m =================================================================== --- trunk/octave-forge/main/fuzzy-logic-toolkit/inst/addmf_demo.m 2011-07-19 15:08:02 UTC (rev 8390) +++ trunk/octave-forge/main/fuzzy-logic-toolkit/inst/addmf_demo.m 2011-07-19 17:59:30 UTC (rev 8391) @@ -22,7 +22,7 @@ ## Demonstrate the function @t{addmf} by executing the code ## given in the comment at the top of addmf.m. ## -## @seealso{addmf} +## @seealso{addmf, heart_demo_1} ## @end deftypefn ## Author: L. Markowsky @@ -31,7 +31,7 @@ ## Keywords: fuzzy-logic-toolkit fuzzy tests demos ## Directory: fuzzy-logic-toolkit/inst ## Filename: addmf_demo.m -## Last-Modified: 8 Jun 2011 +## Last-Modified: 16 Jul 2011 ## Create new FIS. a = newfis ('Heart-Disease-Risk', 'sugeno', ... Modified: trunk/octave-forge/main/fuzzy-logic-toolkit/inst/addrule.m =================================================================== --- trunk/octave-forge/main/fuzzy-logic-toolkit/inst/addrule.m 2011-07-19 15:08:02 UTC (rev 8390) +++ trunk/octave-forge/main/fuzzy-logic-toolkit/inst/addrule.m 2011-07-19 17:59:30 UTC (rev 8391) @@ -19,7 +19,7 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {@var{fis} =} addrule (@var{fis}, @var{rule_matrix}) ## -## Add a list of rules to an existing FIS (Fuzzy Inference System) and return +## Add a list of rules to an existing FIS structure and return ## the updated FIS. ## ## Each row of the @var{rule_matrix} represents one rule and has the form: @@ -60,16 +60,16 @@ ## @end example ## ## @noindent -## For a complete example that uses addrule, see commandline_demo.m. +## For a complete example that uses addrule, see heart_demo_1.m. ## -## @seealso{commandline_demo, showrule} +## @seealso{heart_demo_1, showrule} ## @end deftypefn ## Author: L. Markowsky ## Keywords: fuzzy-logic-toolkit fuzzy rule ## Directory: fuzzy-logic-toolkit/inst/ ## Filename: addrule.m -## Last-Modified: 21 Jun 2011 +## Last-Modified: 16 Jul 2011 function fis = addrule (fis, rule_matrix) Modified: trunk/octave-forge/main/fuzzy-logic-toolkit/inst/addvar.m =================================================================== --- trunk/octave-forge/main/fuzzy-logic-toolkit/inst/addvar.m 2011-07-19 15:08:02 UTC (rev 8390) +++ trunk/octave-forge/main/fuzzy-logic-toolkit/inst/addvar.m 2011-07-19 17:59:30 UTC (rev 8391) @@ -19,7 +19,7 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {@var{fis} =} addvar (@var{fis}, @var{in_or_out}, @var{var_name}, @var{var_range}) ## -## Add an input or output variable to an existing FIS (Fuzzy Inference System) +## Add an input or output variable to an existing FIS ## structure and return the updated FIS. ## ## The types of the arguments are expected to be: @@ -61,7 +61,7 @@ ## Keywords: fuzzy-logic-toolkit fuzzy variable ## Directory: fuzzy-logic-toolkit/inst/ ## Filename: addvar.m -## Last-Modified: 20 Jun 2011 +## Last-Modified: 16 Jul 2011 function fis = addvar (fis, in_or_out, var_name, var_range) Modified: trunk/octave-forge/main/fuzzy-logic-toolkit/inst/addvar_demo.m =================================================================== --- trunk/octave-forge/main/fuzzy-logic-toolkit/inst/addvar_demo.m 2011-07-19 15:08:02 UTC (rev 8390) +++ trunk/octave-forge/main/fuzzy-logic-toolkit/inst/addvar_demo.m 2011-07-19 17:59:30 UTC (rev 8391) @@ -22,14 +22,14 @@ ## Demonstrate the function @t{addvar} by executing the code given in the ## comment at the top of addvar.m. ## -## @seealso{addvar} +## @seealso{addvar, heart_demo_1} ## @end deftypefn ## Author: L. Markowsky ## Keywords: fuzzy-logic-toolkit fuzzy tests demos ## Directory: fuzzy-logic-toolkit/inst ## Filename: addvar_demo.m -## Last-Modified: 8 Jun 2011 +## Last-Modified: 16 Jul 2011 a = newfis ('Heart-Disease-Risk', 'sugeno', ... 'min', 'max', 'min', 'max', 'wtaver'); Deleted: trunk/octave-forge/main/fuzzy-logic-toolkit/inst/commandline_demo.m =================================================================== --- trunk/octave-forge/main/fuzzy-logic-toolkit/inst/commandline_demo.m 2011-07-19 15:08:02 UTC (rev 8390) +++ trunk/octave-forge/main/fuzzy-logic-toolkit/inst/commandline_demo.m 2011-07-19 17:59:30 UTC (rev 8391) @@ -1,104 +0,0 @@ -## Copyright (C) 2011 L. Markowsky <lm...@us...> -## -## This file is part of the fuzzy-logic-toolkit. -## -## The fuzzy-logic-toolkit is free software; you can redistribute it -## and/or modify it under the terms of the GNU General Public License -## as published by the Free Software Foundation; either version 3 of -## the License, or (at your option) any later version. -## -## The fuzzy-logic-toolkit is distributed in the hope that it will be -## useful, but WITHOUT ANY WARRANTY; without even the implied warranty -## of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with the fuzzy-logic-toolkit; see the file COPYING. If not, -## see <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## @deftypefn {Script File} {} commandline_demo -## -## Demonstrate the use of command-line functions to build and evaluate an FIS. -## -## The demo: -## @itemize @minus -## @item -## builds an FIS -## @item -## plots the input and output membership functions -## @item -## plots an output as a function of two inputs -## @item -## displays information about the FIS in the Octave window -## @end itemize -## -## @seealso{addmf_demo, addvar_demo, heart_demo, mamdani_demo, tipping_demo} -## @end deftypefn - -## Author: L. Markowsky -## Note: This example is based on an assignment written by -## Dr. Bruce Segee (University of Maine Dept. of ECE). -## Keywords: fuzzy-logic-toolkit fuzzy tests demos -## Directory: fuzzy-logic-toolkit/inst -## Filename: commandline_demo.m -## Last-Modified: 7 Jun 2011 - -## Create new FIS. -a = newfis ('Heart-Disease-Risk', 'sugeno', ... - 'min', 'max', 'min', 'max', 'wtaver'); - -## Add two inputs and their membership functions. -a = addvar (a, 'input', 'LDL-Level', [0 300]); -a = addmf (a, 'input', 1, 'Low', 'trapmf', [-1 0 90 110]); -a = addmf (a, 'input', 1, 'Low-Borderline', 'trapmf', [90 110 120 140]); -a = addmf (a, 'input', 1, 'Borderline', 'trapmf', [120 140 150 170]); -a = addmf (a, 'input', 1, 'High-Borderline', 'trapmf', [150 170 180 200]); -a = addmf (a, 'input', 1, 'High', 'trapmf', [180 200 300 301]); - -a = addvar (a, 'input', 'HDL-Level', [0 100]); -a = addmf (a, 'input', 2, 'Low-HDL', 'trapmf', [-1 0 35 45]); -a = addmf (a, 'input', 2, 'Moderate-HDL', 'trapmf', [35 45 55 65]); -a = addmf (a, 'input', 2, 'High-HDL', 'trapmf', [55 65 100 101]); - -## Plot the input membership functions. -plotmf (a, 'input', 1); -plotmf (a, 'input', 2); - -## Add one output and its membership functions. -a = addvar (a, 'output', 'Heart-Disease-Risk', [0 10]); -a = addmf (a, 'output', 1, 'No-Risk', 'constant', 0); -a = addmf (a, 'output', 1, 'Low-Risk', 'constant', 2.5); -a = addmf (a, 'output', 1, 'Medium-Risk', 'constant', 5); -a = addmf (a, 'output', 1, 'High-Risk', 'constant', 7.5); -a = addmf (a, 'output', 1, 'Extreme-Risk', 'constant', 10); - -## Plot the output membership functions. -plotmf (a, 'output', 1); - -## Add 15 rules and display them in verbose format. -a = addrule (a, [1 1 3 1 1; ... - 1 2 2 1 1; ... - 1 3 1 1 1; ... - 2 1 3 1 1; ... - 2 2 2 1 1; ... - 2 3 2 1 1; ... - 3 1 4 1 1; ... - 3 2 3 1 1; ... - 3 3 2 1 1; ... - 4 1 4 1 1; ... - 4 2 4 1 1; ... - 4 3 3 1 1; ... - 5 1 5 1 1; ... - 5 2 4 1 1; ... - 5 3 3 1 1]); -puts ("\nOutput of showrule(a):\n\n"); -showrule (a); - -## Plot the output as a function of the two inputs. -gensurf (a); - -## Show the FIS in the Octave window. -puts ("\nOutput of showfis(a):\n\n"); -showfis (a); - Added: trunk/octave-forge/main/fuzzy-logic-toolkit/inst/cubic-approximator.fis =================================================================== --- trunk/octave-forge/main/fuzzy-logic-toolkit/inst/cubic-approximator.fis (rev 0) +++ trunk/octave-forge/main/fuzzy-logic-toolkit/inst/cubic-approximator.fis 2011-07-19 17:59:30 UTC (rev 8391) @@ -0,0 +1,57 @@ +[System] +Name='Cubic-Approximator' +Type='sugeno' +Version=2.0 +NumInputs=1 +NumOutputs=1 +NumRules=11 +AndMethod='min' +OrMethod='max' +ImpMethod='min' +AggMethod='max' +DefuzzMethod='wtaver' + +[Input1] +Name='X' +Range=[-5 5] +NumMFs=11 +MF1 = 'About-Neg-Five':'trimf', [-6 -5 -4] +MF2 = 'About-Neg-Four':'trimf', [-5 -4 -3] +MF3 = 'About-Neg-Three':'trimf', [-4 -3 -2] +MF4 = 'About-Neg-Two':'trimf', [-3 -2 -1] +MF5 = 'About-Neg-One':'trimf', [-2 -1 0] +MF6 = 'About-Zero':'trimf', [-1 0 1] +MF7 = 'About-One':'trimf', [0 1 2] +MF8 = 'About-Two':'trimf', [1 2 3] +MF9 = 'About-Three':'trimf', [2 3 4] +MF10 = 'About-Four':'trimf', [3 4 5] +MF11 = 'About-Five':'trimf', [4 5 6] + +[Output1] +Name='Approx-X-Cubed' +Range=[-130 130] +NumMFs=11 +MF1 = 'Tangent-at-Neg-Five':'linear', [75 250] +MF2 = 'Tangent-at-Neg-Four':'linear', [48 128] +MF3 = 'Tangent-at-Neg-Three':'linear', [27 54] +MF4 = 'Tangent-at-Neg-Two':'linear', [12 16] +MF5 = 'Tangent-at-Neg-One':'linear', [3 2] +MF6 = 'Tangent-at-Zero':'linear', [0 0] +MF7 = 'Tangent-at-One':'linear', [3 -2] +MF8 = 'Tangent-at-Two':'linear', [12 -16] +MF9 = 'Tangent-at-Three':'linear', [27 -54] +MF10 = 'Tangent-at-Four':'linear', [48 -128] +MF11 = 'Tangent-at-Five':'linear', [75 -250] + +[Rules] +1, 1 (1) : 1 +2, 2 (1) : 1 +3, 3 (1) : 1 +4, 4 (1) : 1 +5, 5 (1) : 1 +6, 6 (1) : 1 +7, 7 (1) : 1 +8, 8 (1) : 1 +9, 9 (1) : 1 +10, 10 (1) : 1 +11, 11 (1) : 1 Added: trunk/octave-forge/main/fuzzy-logic-toolkit/inst/cubic_approx_demo.m =================================================================== --- trunk/octave-forge/main/fuzzy-logic-toolkit/inst/cubic_approx_demo.m (rev 0) +++ trunk/octave-forge/main/fuzzy-logic-toolkit/inst/cubic_approx_demo.m 2011-07-19 17:59:30 UTC (rev 8391) @@ -0,0 +1,52 @@ +## Copyright (C) 2011 L. Markowsky <lm...@us...> +## +## This file is part of the fuzzy-logic-toolkit. +## +## The fuzzy-logic-toolkit is free software; you can redistribute it +## and/or modify it under the terms of the GNU General Public License +## as published by the Free Software Foundation; either version 3 of +## the License, or (at your option) any later version. +## +## The fuzzy-logic-toolkit is distributed in the hope that it will be +## useful, but WITHOUT ANY WARRANTY; without even the implied warranty +## of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with the fuzzy-logic-toolkit; see the file COPYING. If not, +## see <http://www.gnu.org/licenses/>. + +## -*- texinfo -*- +## @deftypefn {Script File} {} cubic_approx_demo +## +## Demonstrate the use of the Octave Fuzzy Logic Toolkit to approximate a +## non-linear function using a Sugeno-type FIS with linear output membership +## functions. +## +## The demo: +## @itemize @minus +## @item +## reads an FIS structure from a file +## @item +## plots the input membership functions +## @item +## plots the output as a function of the input +## @end itemize +## +## @seealso{heart_demo_1, heart_demo_2, linear_tip_demo, mamdani_tip_demo, sugeno_tip_demo} +## @end deftypefn + +## Author: L. Markowsky +## Keywords: fuzzy-logic-toolkit fuzzy tests demos +## Directory: fuzzy-logic-toolkit/inst +## Filename: cubic_approx_demo.m +## Last-Modified: 17 Jul 2011 + +## Read the FIS structure from a file. +fis = readfis ('cubic-approximator.fis'); + +## Plot the input membership functions. +plotmf (fis, 'input', 1); + +## Plot the output y as a function of the input x. +gensurf (fis); Modified: trunk/octave-forge/main/fuzzy-logic-toolkit/inst/defuzz.m =================================================================== --- trunk/octave-forge/main/fuzzy-logic-toolkit/inst/defuzz.m 2011-07-19 15:08:02 UTC (rev 8390) +++ trunk/octave-forge/main/fuzzy-logic-toolkit/inst/defuzz.m 2011-07-19 17:59:30 UTC (rev 8391) @@ -20,8 +20,8 @@ ## @deftypefn {Function File} {@var{crisp_x} =} defuzz (@var{x}, @var{y}, @var{defuzz_method}) ## @deftypefnx {Function File} {@var{crisp_x} =} defuzz (@var{[x1 x2 ... xn]}, @var{[y1 y2 ... yn]}, @var{defuzz_method}) ## -## Return the defuzzified (crisp) value of @var{x} using the defuzzification -## method specified by the third argument for the given domain and y-values. +## For a given domain, set of fuzzy function values, and defuzzification method, +## return the defuzzified (crisp) value of the fuzzy function. ## ## The arguments @var{x} and @var{y} must be either two real numbers or ## two equal-length, non-empty vectors of reals, with the elements of @var{x} @@ -53,7 +53,7 @@ ## Keywords: fuzzy-logic-toolkit fuzzy defuzzification ## Directory: fuzzy-logic-toolkit/inst/ ## Filename: defuzz.m -## Last-Modified: 7 Jun 2011 +## Last-Modified: 16 Jul 2011 ##------------------------------------------------------------------------------ Modified: trunk/octave-forge/main/fuzzy-logic-toolkit/inst/evalfis.m =================================================================== --- trunk/octave-forge/main/fuzzy-logic-toolkit/inst/evalfis.m 2011-07-19 15:08:02 UTC (rev 8390) +++ trunk/octave-forge/main/fuzzy-logic-toolkit/inst/evalfis.m 2011-07-19 17:59:30 UTC (rev 8391) @@ -22,18 +22,18 @@ ## @deftypefnx {Function File} {[@var{output}, @var{rule_input}, @var{rule_output}, @var{fuzzy_output}] =} evalfis (@var{user_input}, @var{fis}) ## @deftypefnx {Function File} {[@var{output}, @var{rule_input}, @var{rule_output}, @var{fuzzy_output}] =} evalfis (@var{user_input}, @var{fis}, @var{num_points}) ## -## Evaluate the FIS for each line in the user_input matrix, and for each row of -## crisp input values, return the crisp output of the FIS. Also, for the last -## row of user_input, return: +## Return the crisp output(s) of an FIS for each row in a matrix of crisp input +## values. +## Also, for the last row of @var{user_input}, return the intermediate results: ## ## @table @var ## @item rule_input -## a matrix (num_rules x num_inputs) of the degree to which -## each input matched the membership function for each rule +## a matrix of the degree to which +## each FIS rule matches each FIS input variable ## @item rule_output -## a matrix of the output of each rule +## a matrix of the fuzzy output for each (rule, FIS output) pair ## @item fuzzy_output -## a matrix of the aggregated output for each FIS output +## a matrix of the aggregated output for each FIS output variable ## @end table ## ## The optional argument @var{num_points} specifies the number of points over @@ -41,41 +41,44 @@ ## 101. ## ## @noindent -## Format of user_input: +## Argument @var{user_input}: ## -## The @var{user_input} is a matrix of crisp input values. Each row of the -## matrix represents one set of input values to the FIS and has the form: +## @var{user_input} is a matrix of crisp input values. Each row +## represents one set of crisp FIS input values. For an FIS that has N inputs, +## an input matrix of z sets of input values will have the form: ## ## @example ## @group -## [input_1a input_2a ... input_Ma] <-- 1st row is 1st set of inputs -## [input_1b input_2b ... input_Mb] <-- 2nd row is 2nd set of inputs +## [input_11 input_12 ... input_1N] <-- 1st row is 1st set of inputs +## [input_21 input_22 ... input_2N] <-- 2nd row is 2nd set of inputs ## [ ... ] ... -## [input_1z input_2z ... input_Mz] <-- zth row is zth set of inputs +## [input_z1 input_z2 ... input_zN] <-- zth row is zth set of inputs ## @end group ## @end example ## ## @noindent -## Format of output: +## Return value @var{output}: ## -## The @var{output} of the FIS is also a matrix of crisp values. Each row -## of the matrix represents the set of outputs for the corresponding row of -## @var{user_input}: +## @var{output} is a matrix of crisp output values. Each row represents +## the set of crisp FIS output values for the corresponding row of +## @var{user_input}. For an FIS that has M outputs, an @var{output} matrix +## corresponding to the preceding input matrix will have the form: ## ## @example ## @group -## [output_1a output_2a ... output_Na] <-- 1st row is 1st set of outputs -## [output_1b output_2b ... output_Nb] <-- 2nd row is 2nd set of outputs +## [output_11 output_12 ... output_1M] <-- 1st row is 1st set of outputs +## [output_21 output_22 ... output_2M] <-- 2nd row is 2nd set of outputs ## [ ... ] ... -## [output_1z output_2z ... output_Nz] <-- zth row is zth set of outputs +## [output_z1 output_z2 ... output_zM] <-- zth row is zth set of outputs ## @end group ## @end example ## ## @noindent -## Format of rule_input: +## The intermediate result @var{rule_input}: ## -## The matching degree for each (rule, input value) pair is specified by an -## Q x N matrix: +## The matching degree for each (rule, input value) pair is specified by the +## @var{rule_input} matrix. For an FIS that has Q rules and N input variables, +## the matrix will have the form: ## @example ## @group ## in_1 in_2 ... in_N @@ -87,30 +90,26 @@ ## @end example ## ## @noindent -## where Q is the number of rules and N is the number of inputs to the FIS. ## ## @noindent -## Format of rule_output: +## The intermediate result @var{rule_output}: ## -## The format of rule_output depends on the FIS type ('mamdani' or 'sugeno'). -## ## For either a Mamdani-type FIS (that is, an FIS that does not have constant or ## linear output membership functions) or a Sugeno-type FIS (that is, an FIS ## that has only constant and linear output membership functions), -## @var{rule_output} specifies the fuzzy output for each rule and for each -## output variable. +## @var{rule_output} specifies the fuzzy output for each (rule, FIS output) pair. +## The format of rule_output depends on the FIS type. ## -## For a Mamdani-type FIS, @var{rule_output} is a num_points x (Q*L) matrix, -## where num_points is the number of points at which the fuzzy output is -## evaluated, Q is the number of rules, and L is the number of outputs of the -## FIS. Each column of this matrix gives the y-values of the corresponding fuzzy -## output (of a single rule for a single FIS output). +## For a Mamdani-type FIS, @var{rule_output} is a @var{num_points} x (Q * M) +## matrix, where Q is the number of rules and M is the number of FIS output +## variables. Each column of this matrix gives the y-values of the fuzzy +## output for a single (rule, FIS output) pair. ## ## @example ## @group -## num_rules cols num_rules cols num_rules cols +## Q cols Q cols Q cols ## --------------- --------------- --------------- -## out_1 ... out_1 out_2 ... out_2 ... out_L ... out_L +## out_1 ... out_1 out_2 ... out_2 ... out_M ... out_M ## 1 [ ] ## 2 [ ] ## ... [ ] @@ -118,23 +117,22 @@ ## @end group ## @end example ## -## For a Sugeno-type FIS, @var{rule_output} is a 2 x (Q*L) matrix, where -## Q is the number of rules and L is the number of outputs of the FIS. +## For a Sugeno-type FIS, @var{rule_output} is a 2 x (Q * M) matrix. ## Each column of this matrix gives the (location, height) pair of the -## corresponding singleton output (of a single rule for a single FIS output). +## singleton output for a single (rule, FIS output) pair. ## ## @example ## @group -## num_rules cols num_rules cols num_rules cols +## Q cols Q cols Q cols ## --------------- --------------- --------------- -## out_1 ... out_1 out_2 ... out_2 ... out_L ... out_L +## out_1 ... out_1 out_2 ... out_2 ... out_M ... out_M ## location [ ] ## height [ ] ## @end group ## @end example ## ## @noindent -## Format of fuzzy_output: +## The intermediate result @var{fuzzy_output}: ## ## The format of @var{fuzzy_output} depends on the FIS type ('mamdani' or ## 'sugeno'). @@ -142,56 +140,62 @@ ## For either a Mamdani-type FIS or a Sugeno-type FIS, @var{fuzzy_output} ## specifies the aggregated fuzzy output for each FIS output. ## -## For a Mamdani-type FIS, the aggregated @var{fuzzy_output} is an num_pts x L -## matrix. Each column of this matrix gives the y-values of the corresponding -## fuzzy output (for a single FIS output, aggregated over all rules). +## For a Mamdani-type FIS, the aggregated @var{fuzzy_output} is a +## @var{num_points} x M matrix. Each column of this matrix gives the y-values +## of the fuzzy output for a single FIS output, aggregated over all rules. ## ## @example ## @group -## out_1 out_2 ... out_L -## 1 [ ] -## 2 [ ] -## ... [ ] -## num_pts [ ] +## out_1 out_2 ... out_M +## 1 [ ] +## 2 [ ] +## ... [ ] +## num_points [ ] ## @end group ## @end example ## -## For a Sugeno-type FIS, the aggregated output for each FIS output is a 2 x M -## matrix, where M is the number of distinct singleton locations in the -## @var{rule_output} (above) for that FIS output: +## For a Sugeno-type FIS, the aggregated output for each FIS output is a 2 x L +## matrix, where L is the number of distinct singleton locations in the +## @var{rule_output} for that FIS output: ## ## @example ## @group -## singleton_1 singleton_2 ... singleton_M +## singleton_1 singleton_2 ... singleton_L ## location [ ] ## height [ ] ## @end group ## @end example ## -## Then @var{fuzzy_output} is a vector of L structures, each of which has an index and +## Then @var{fuzzy_output} is a vector of M structures, each of which has an index and ## one of these matrices. ## ## @noindent ## Examples: ## -## Three examples of using evalfis are shown in: +## Six examples of using evalfis are shown in: ## @itemize @bullet ## @item -## heart_demo.m +## cubic_approx_demo.m ## @item -## mamdani_demo.m +## heart_demo_1.m ## @item -## tipping_demo.m +## heart_demo_2.m +## @item +## linear_tip_demo.m +## @item +## mamdani_tip_demo.m +## @item +## sugeno_tip_demo.m ## @end itemize ## -## @seealso{heart_demo, mamdani_demo, tipping_demo} +## @seealso{cubic_approx_demo, heart_demo_1, heart_demo_2, linear_tip_demo, mamdani_tip_demo, sugeno_tip_demo} ## @end deftypefn ## Author: L. Markowsky ## Keywords: fuzzy-logic-toolkit fuzzy fuzzy-inference-system fis ## Directory: fuzzy-logic-toolkit/inst/ ## Filename: evalfis.m -## Last-Modified: 19 May 2011 +## Last-Modified: 16 Jul 2011 function [output, rule_input, rule_output, fuzzy_output] = ... evalfis (user_input, fis, num_points=101) Modified: trunk/octave-forge/main/fuzzy-logic-toolkit/inst/evalmf.m =================================================================== --- trunk/octave-forge/main/fuzzy-logic-toolkit/inst/evalmf.m 2011-07-19 15:08:02 UTC (rev 8390) +++ trunk/octave-forge/main/fuzzy-logic-toolkit/inst/evalmf.m 2011-07-19 17:59:30 UTC (rev 8391) @@ -20,14 +20,13 @@ ## @deftypefn {Function File} {@var{y} =} evalmf (@var{x}, @var{param}, @var{mf_type}) ## @deftypefnx {Function File} {@var{y} =} evalmf (@var{[x1 x2 ... xn]}, @var{[param1 ... ]}, @var{mf_type}) ## -## For a given domain @var{x} and parameters @var{param}, return the -## corresponding @var{y} values for the membership function corresponding to -## the @var{mf_type}. +## For a given domain, set of parameters, and membership function type, +## return the corresponding y-values for the membership function. ## ## The argument @var{x} must be a real number or a non-empty list of strictly ## increasing real numbers, @var{param} must be a valid parameter or a vector ## of valid parameters for @var{mf_type}, and @var{mf_type} must be a string -## corresponding to a membership function. Evalmf handles both built-in and +## corresponding to a membership function type. Evalmf handles both built-in and ## custom membership functions. ## ## @noindent @@ -40,7 +39,7 @@ ## Keywords: fuzzy-logic-toolkit fuzzy membership-function evaluate ## Directory: fuzzy-logic-toolkit/inst/ ## Filename: evalmf.m -## Last-Modified: 7 Jun 2011 +## Last-Modified: 16 Jul 2011 function y = evalmf (x, params, mf_type) Modified: trunk/octave-forge/main/fuzzy-logic-toolkit/inst/gensurf.m =================================================================== --- trunk/octave-forge/main/fuzzy-logic-toolkit/inst/gensurf.m 2011-07-19 15:08:02 UTC (rev 8390) +++ trunk/octave-forge/main/fuzzy-logic-toolkit/inst/gensurf.m 2011-07-19 17:59:30 UTC (rev 8391) @@ -25,9 +25,9 @@ ## @deftypefnx {Function File} {} gensurf (@var{fis}, @var{input_axes}, @var{output_axes}, @var{grids}, @var{ref_input}, @var{num_points}) ## @deftypefnx {Function File} {@var{[x, y, z]} =} gensurf (...) ## -## Generate and plot a surface showing the output_axis as a function of the -## two input_axes. The reference input is used for all FIS inputs that are not -## in the input_axes vector. +## Generate and plot a surface (or 2-dimensional curve) showing one FIS output +## as a function of two (or one) of the FIS inputs. The reference input is used +## for all FIS inputs that are not in the input_axes vector. ## ## Grids, which specifies the number of grids to show on the input axes, may be ## a scalar or a vector of length 2. If a scalar, then both axes will use the @@ -52,47 +52,45 @@ ## num_points == 101 ## @end itemize ## -## Four examples of using gensurf are shown in: +## Six demo scripts that use gensurf are: ## @itemize @bullet ## @item -## commandline_demo.m +## cubic_approx_demo.m ## @item -## heart_demo.m +## heart_demo_1.m ## @item -## mamdani_demo.m +## heart_demo_2.m ## @item -## tipping_demo.m +## linear_tip_demo.m +## @item +## mamdani_tip_demo.m +## @item +## sugeno_tip_demo.m ## @end itemize ## ## CURRENT LIMITATIONS: ## @itemize @bullet ## @item -## input_axes must have length 2, so that gensurf plots a surface. -## @item -## Output for only 1 input axis (a 2-D plot) is not yet implemented. -## @item ## The FIS for which the surface is generated must have only one output. ## @item ## grids must have length 2. ## @item -## The final form of gensurf (that suppresses plotting) is not yet +## The form of gensurf that suppresses plotting (the final form above) is not yet ## implemented. ## @end itemize ## -## @seealso{commandline_demo, heart_demo, mamdani_demo, tipping_demo, plotmf} +## @seealso{cubic_approx_demo, heart_demo_1, heart_demo_2, linear_tip_demo, mamdani_tip_demo, sugeno_tip_demo, plotmf} ## @end deftypefn ## Author: L. Markowsky ## Keywords: fuzzy-logic-toolkit fuzzy fuzzy-inference-system fis plot ## Directory: fuzzy-logic-toolkit/inst/ ## Filename: gensurf.m -## Last-Modified: 7 Jun 2011 +## Last-Modified: 18 Jul 2011 function [x, y, z] = gensurf (fis, input_axes=[1 2], output_axis=1, ... grids=[15 15], ref_input=[], num_points=101) - ## TO DO: RESET INPUT_AXES=1 IF NARGIN==1 AND THE FIS HAS ONLY 1 INPUT - ## TO DO: GENERATE 2-D PLOT IF LENGTH(INPUTS_AXES)==1 ## TO DO: HANDLE FIS STRUCTURES THAT HAVE MORE THAN 1 OUTPUT ## TO DO: HANDLE SCALAR GRIDS ARGUMENT ## TO DO: RENAME X, Y, AND Z. MAKE SURE THEY ARE ASSIGNED VALUES. @@ -123,9 +121,69 @@ error ("gensurf's sixth argument to gensurf must be an integer >= 2\n"); endif + if (length (input_axes) == 1 || columns (fis.input) == 1) + generate_plot (fis, input_axes, output_axis, grids, ref_input, num_points); + else + generate_surface (fis, input_axes, output_axis, grids, ref_input, ... + num_points); + endif + +endfunction + +##------------------------------------------------------------------------------ +## Function: generate_plot +## Purpose: Generate a plot representing one of the FIS outputs as a +## function of one of the FIS inputs. +##------------------------------------------------------------------------------ + +function [x, y, z] = generate_plot (fis, input_axis, output_axis, grids, ... + ref_input, num_points) + ## Create input to FIS using grid points and reference values. num_inputs = columns (fis.input); + num_grid_pts = grids(1); + fis_input = zeros (num_grid_pts, num_inputs); + + if (num_inputs == 1) + input_axis = 1; + endif + + for i = 1 : num_inputs + if (i == input_axis) + x_axis = (linspace (fis.input(i).range(1), ... + fis.input(i).range(2), ... + num_grid_pts))'; + fis_input(:, i) = x_axis; + else + fis_input(:, i) = ref_input(i) * ones (num_grid_pts, 1); + endif + endfor + + ## Compute and plot the output. + + output = evalfis_private (fis_input, fis, num_points); + figure ('NumberTitle', 'off', 'Name', fis.name); + plot (x_axis, output, 'LineWidth', 2); + xlabel (fis.input(input_axis).name, 'FontWeight', 'bold'); + ylabel (fis.output(output_axis).name, 'FontWeight', 'bold'); + grid; + hold; + +endfunction + +##------------------------------------------------------------------------------ +## Function: generate_surface +## Purpose: Generate a surface representing one of the FIS outputs as a +## function of two of the FIS inputs. +##------------------------------------------------------------------------------ + +function [x, y, z] = generate_surface (fis, input_axes, output_axis, grids, ... + ref_input, num_points) + + ## Create input to FIS using grid points and reference values. + + num_inputs = columns (fis.input); num_grid_pts = prod (grids); fis_input = zeros (num_grid_pts, num_inputs); @@ -139,7 +197,7 @@ fis.input(i).range(2), ... grids(2)))'; else - fis_input(:, i) = (ref_input(i) * ones (num_grid_pts))'; + fis_input(:, i) = ref_input(i) * ones (num_grid_pts, 1); endif endfor Modified: trunk/octave-forge/main/fuzzy-logic-toolkit/inst/getfis.m =================================================================== --- trunk/octave-forge/main/fuzzy-logic-toolkit/inst/getfis.m 2011-07-19 15:08:02 UTC (rev 8390) +++ trunk/octave-forge/main/fuzzy-logic-toolkit/inst/getfis.m 2011-07-19 17:59:30 UTC (rev 8391) @@ -24,8 +24,8 @@ ## @deftypefnx {Function File} {@var{retval} =} getfis (@var{fis}, @var{in_or_out}, @var{var_index}, @var{mf}, @var{mf_index}) ## @deftypefnx {Function File} {@var{retval} =} getfis (@var{fis}, @var{in_or_out}, @var{var_index}, @var{mf}, @var{mf_index}, @var{mf_property}) ## -## Return (or print) property (field) values of an FIS structure. -## There are six forms of getfis: +## Return or print the property (field) values of an FIS structure +## specified by the arguments. There are six forms of getfis: ## ## @table @asis ## @item # Arguments @@ -93,7 +93,7 @@ ## Keywords: fuzzy-logic-toolkit fuzzy fuzzy-inference-system fis ## Directory: fuzzy-logic-toolkit/inst/ ## Filename: getfis.m -## Last-Modified: 21 Jun 2011 +## Last-Modified: 16 Jul 2011 ##------------------------------------------------------------------------------ Deleted: trunk/octave-forge/main/fuzzy-logic-toolkit/inst/heart_demo.m =================================================================== --- trunk/octave-forge/main/fuzzy-logic-toolkit/inst/heart_demo.m 2011-07-19 15:08:02 UTC (rev 8390) +++ trunk/octave-forge/main/fuzzy-logic-toolkit/inst/heart_demo.m 2011-07-19 17:59:30 UTC (rev 8391) @@ -1,66 +0,0 @@ -## Copyright (C) 2011 L. Markowsky <lm...@us...> -## -## This file is part of the fuzzy-logic-toolkit. -## -## The fuzzy-logic-toolkit is free software; you can redistribute it -## and/or modify it under the terms of the GNU General Public License -## as published by the Free Software Foundation; either version 3 of -## the License, or (at your option) any later version. -## -## The fuzzy-logic-toolkit is distributed in the hope that it will be -## useful, but WITHOUT ANY WARRANTY; without even the implied warranty -## of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with the fuzzy-logic-toolkit; see the file COPYING. If not, -## see <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## @deftypefn {Script File} {} heart_demo -## -## Demonstrate the use of the fuzzy_logic_toolkit to read and evaluate a -## Sugeno-type FIS stored in a file. -## -## The demo: -## @itemize @minus -## @item -## reads an FIS structure from a file -## @item -## plots the input and output membership functions -## @item -## plots the output as a function of the inputs -## @item -## evaluates the Sugeno-type FIS for four inputs -## @end itemize -## -## @seealso{commandline_demo, tipping_demo} -## @end deftypefn - -## Author: L. Markowsky -## Keywords: fuzzy-logic-toolkit fuzzy tests demos -## Note: This example is based on an assignment written by -## Dr. Bruce Segee (University of Maine Dept. of ECE). -## Directory: fuzzy-logic-toolkit/inst -## Filename: heart_demo.m -## Last-Modified: 7 Jun 2011 - -## Read the FIS structure from a file. -## (Alternatively, to select heart-disease-risk.fis using the dialog, -## replace the following line with -## fis = readfis (); -fis = readfis('heart-disease-risk.fis'); - -## Plot the input and output membership functions. -plotmf (fis, 'input', 1); -plotmf (fis, 'input', 2); -plotmf (fis, 'output', 1); - -## Plot the Heart Disease Risk as a function of LDL-Level and HDL-Level. -gensurf (fis); - -## Calculate the Heart Disease Risk for 4 sets of LDL-HDL values: -puts ("\nFor the following four sets of LDL-HDL values:\n\n"); -ldl_hdl = [129 59; 130 60; 90 65; 205 40] -puts ("\nThe Heart Disease Risk is:\n\n"); -heart_disease_risk = evalfis (ldl_hdl, fis, 1001) Added: trunk/octave-forge/main/fuzzy-logic-toolkit/inst/heart_demo_1.m =================================================================== --- trunk/octave-forge/main/fuzzy-logic-toolkit/inst/heart_demo_1.m (rev 0) +++ trunk/octave-forge/main/fuzzy-logic-toolkit/inst/heart_demo_1.m 2011-07-19 17:59:30 UTC (rev 8391) @@ -0,0 +1,105 @@ +## Copyright (C) 2011 L. Markowsky <lm...@us...> +## +## This file is part of the fuzzy-logic-toolkit. +## +## The fuzzy-logic-toolkit is free software; you can redistribute it +## and/or modify it under the terms of the GNU General Public License +## as published by the Free Software Foundation; either version 3 of +## the License, or (at your option) any later version. +## +## The fuzzy-logic-toolkit is distributed in the hope that it will be +## useful, but WITHOUT ANY WARRANTY; without even the implied warranty +## of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with the fuzzy-logic-toolkit; see the file COPYING. If not, +## see <http://www.gnu.org/licenses/>. + +## -*- texinfo -*- +## @deftypefn {Script File} {} heart_demo_1 +## +## Demonstrate the use of newfis, addvar, addmf, addrule, and evalfis +## to build and evaluate an FIS. +## +## The demo: +## @itemize @minus +## @item +## builds an FIS +## @item +## plots the input and output membership functions +## @item +## plots an output as a function of two inputs +## @item +## displays information about the FIS in the Octave window +## @end itemize +## +## @seealso{addmf_demo, addvar_demo, heart_demo_2, showrule_demo} +## @end deftypefn + +## Author: L. Markowsky +## Note: This example is based on an assignment written by +## Dr. Bruce Segee (University of Maine Dept. of ECE). +## Keywords: fuzzy-logic-toolkit fuzzy tests demos +## Directory: fuzzy-logic-toolkit/inst +## Filename: heart_demo_1.m +## Last-Modified: 16 Jul 2011 + +## Create new FIS. +a = newfis ('Heart-Disease-Risk', 'sugeno', ... + 'min', 'max', 'min', 'max', 'wtaver'); + +## Add two inputs and their membership functions. +a = addvar (a, 'input', 'LDL-Level', [0 300]); +a = addmf (a, 'input', 1, 'Low', 'trapmf', [-1 0 90 110]); +a = addmf (a, 'input', 1, 'Low-Borderline', 'trapmf', [90 110 120 140]); +a = addmf (a, 'input', 1, 'Borderline', 'trapmf', [120 140 150 170]); +a = addmf (a, 'input', 1, 'High-Borderline', 'trapmf', [150 170 180 200]); +a = addmf (a, 'input', 1, 'High', 'trapmf', [180 200 300 301]); + +a = addvar (a, 'input', 'HDL-Level', [0 100]); +a = addmf (a, 'input', 2, 'Low-HDL', 'trapmf', [-1 0 35 45]); +a = addmf (a, 'input', 2, 'Moderate-HDL', 'trapmf', [35 45 55 65]); +a = addmf (a, 'input', 2, 'High-HDL', 'trapmf', [55 65 100 101]); + +## Plot the input membership functions. +plotmf (a, 'input', 1); +plotmf (a, 'input', 2); + +## Add one output and its membership functions. +a = addvar (a, 'output', 'Heart-Disease-Risk', [0 10]); +a = addmf (a, 'output', 1, 'No-Risk', 'constant', 0); +a = addmf (a, 'output', 1, 'Low-Risk', 'constant', 2.5); +a = addmf (a, 'output', 1, 'Medium-Risk', 'constant', 5); +a = addmf (a, 'output', 1, 'High-Risk', 'constant', 7.5); +a = addmf (a, 'output', 1, 'Extreme-Risk', 'constant', 10); + +## Plot the output membership functions. +plotmf (a, 'output', 1); + +## Add 15 rules and display them in verbose format. +a = addrule (a, [1 1 3 1 1; ... + 1 2 2 1 1; ... + 1 3 1 1 1; ... + 2 1 3 1 1; ... + 2 2 2 1 1; ... + 2 3 2 1 1; ... + 3 1 4 1 1; ... + 3 2 3 1 1; ... + 3 3 2 1 1; ... + 4 1 4 1 1; ... + 4 2 4 1 1; ... + 4 3 3 1 1; ... + 5 1 5 1 1; ... + 5 2 4 1 1; ... + 5 3 3 1 1]); +puts ("\nOutput of showrule(a):\n\n"); +showrule (a); + +## Plot the output as a function of the two inputs. +gensurf (a); + +## Show the FIS in the Octave window. +puts ("\nOutput of showfis(a):\n\n"); +showfis (a); + Added: trunk/octave-forge/main/fuzzy-logic-toolkit/inst/heart_demo_2.m =================================================================== --- trunk/octave-forge/main/fuzzy-logic-toolkit/inst/heart_demo_2.m (rev 0) +++ trunk/octave-forge/main/fuzzy-logic-toolkit/inst/heart_demo_2.m 2011-07-19 17:59:30 UTC (rev 8391) @@ -0,0 +1,66 @@ +## Copyright (C) 2011 L. Markowsky <lm...@us...> +## +## This file is part of the fuzzy-logic-toolkit. +## +## The fuzzy-logic-toolkit is free software; you can redistribute it +## and/or modify it under the terms of the GNU General Public License +## as published by the Free Software Foundation; either version 3 of +## the License, or (at your option) any later version. +## +## The fuzzy-logic-toolkit is distributed in the hope that it will be +## useful, but WITHOUT ANY WARRANTY; without even the implied warranty +## of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with the fuzzy-logic-toolkit; see the file COPYING. If not, +## see <http://www.gnu.org/licenses/>. + +## -*- texinfo -*- +## @deftypefn {Script File} {} heart_demo_2 +## +## Demonstrate the use of the Octave Fuzzy Logic Toolkit to read and evaluate a +## Sugeno-type FIS stored in a file. +## +## The demo: +## @itemize @minus +## @item +## reads an FIS structure from a file +## @item +## plots the input and output membership functions +## @item +## plots the output as a function of the inputs +## @item +## evaluates the Sugeno-type FIS for four inputs +## @end itemize +## +## @seealso{cubic_approx_demo, heart_demo_1, linear_tip_demo, mamdani_tip_demo, sugeno_tip_demo} +## @end deftypefn + +## Author: L. Markowsky +## Keywords: fuzzy-logic-toolkit fuzzy tests demos +## Note: This example is based on an assignment written by +## Dr. Bruce Segee (University of Maine Dept. of ECE). +## Directory: fuzzy-logic-toolkit/inst +## Filename: heart_demo_2.m +## Last-Modified: 17 Jul 2011 + +## Read the FIS structure from a file. +## (Alternatively, to select heart-disease-risk.fis using the dialog, +## replace the following line with +## fis = readfis (); +fis = readfis('heart-disease-risk.fis'); + +## Plot the input and output membership functions. +plotmf (fis, 'input', 1); +plotmf (fis, 'input', 2); +plotmf (fis, 'output', 1); + +## Plot the Heart Disease Risk as a function of LDL-Level and HDL-Level. +gensurf (fis); + +## Calculate the Heart Disease Risk for 4 sets of LDL-HDL values: +puts ("\nFor the following four sets of LDL-HDL values:\n\n"); +ldl_hdl = [129 59; 130 60; 90 65; 205 40] +puts ("\nThe Heart Disease Risk is:\n\n"); +heart_disease_risk = evalfis (ldl_hdl, fis, 1001) Added: trunk/octave-forge/main/fuzzy-logic-toolkit/inst/linear-tip-calculator.fis =================================================================== --- trunk/octave-forge/main/fuzzy-logic-toolkit/inst/linear-tip-calculator.fis (rev 0) +++ trunk/octave-forge/main/fuzzy-logic-toolkit/inst/linear-tip-calculator.fis 2011-07-19 17:59:30 UTC (rev 8391) @@ -0,0 +1,40 @@ +[System] +Name='Linear-Tip-Calculator' +Type='sugeno' +Version=2.0 +NumInputs=2 +NumOutputs=1 +NumRules=4 +AndMethod='min' +OrMethod='max' +ImpMethod='min' +AggMethod='max' +DefuzzMethod='wtaver' + +[Input1] +Name='Food-Quality' +Range=[1 10] +NumMFs=2 +MF1='Bad':'trapmf',[0 1 3 7] +MF2='Good':'trapmf',[3 7 10 11] + +[Input2] +Name='Service' +Range=[1 10] +NumMFs=2 +MF1='Bad':'trapmf',[0 1 3 7] +MF2='Good':'trapmf',[3 7 10 11] + +[Output1] +Name='Tip' +Range=[10 20] +NumMFs=3 +MF1='Ten-Percent':'linear',[0 0 10] +MF2='Fifteen-Percent':'linear',[0 0 15] +MF3='Twenty-Percent':'linear',[0 0 20] + +[Rules] +1 1, 1 (1) : 1 +1 2, 2 (1) : 1 +2 1, 2 (1) : 1 +2 2, 3 (1) : 1 Added: trunk/octave-forge/main/fuzzy-logic-toolkit/inst/linear_tip_demo.m =================================================================== --- trunk/octave-forge/main/fuzzy-logic-toolkit/inst/linear_tip_demo.m (rev 0) +++ trunk/octave-forge/main/fuzzy-logic-toolkit/inst/linear_tip_demo.m 2011-07-19 17:59:30 UTC (rev 8391) @@ -0,0 +1,62 @@ +## Copyright (C) 2011 L. Markowsky <lm...@us...> +## +## This file is part of the fuzzy-logic-toolkit. +## +## The fuzzy-logic-toolkit is free software; you can redistribute it +## and/or modify it under the terms of the GNU General Public License +## as published by the Free Software Foundation; either version 3 of +## the License, or (at your option) any later version. +## +## The fuzzy-logic-toolkit is distributed in the hope that it will be +## useful, but WITHOUT ANY WARRANTY; without even the implied warranty +## of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with the fuzzy-logic-toolkit; see the file COPYING. If not, +## see <http://www.gnu.org/licenses/>. + +## -*- texinfo -*- +## @deftypefn {Script File} {} linear_tip_demo +## +## Demonstrate the use of linear output membership functions to simulate +## constant membership functions. +## +## The demo: +## @itemize @minus +## @item +## reads an FIS structure from a file +## @item +## plots the input membership functions +## @item +## plots the output as a function of the inputs +## @item +## evaluates the Sugeno-type FIS for six inputs +## @end itemize +## +## @seealso{cubic_approx_demo, heart_demo_1, heart_demo_2, mamdani_tip_demo, sugeno_tip_demo} +## @end deftypefn + +## Author: L. Markowsky +## Keywords: fuzzy-logic-toolkit fuzzy tests demos +## Note: This example is based on an assignment written by +## Dr. Bruce Segee (University of Maine Dept. of ECE). +## Directory: fuzzy-logic-toolkit/inst +## Filename: linear_tip_demo.m +## Last-Modified: 17 Jul 2011 + +## Read the FIS structure from a file. +fis = readfis ('linear-tip-calculator.fis'); + +## Plot the input membership functions. +plotmf (fis, 'input', 1); +plotmf (fis, 'input', 2); + +## Plot the Tip as a function of Food-Quality and Service. +gensurf (fis); + +## Calculate the Tip for 6 sets of input values: +puts ("\nFor the following values of (Food Quality, Service):\n\n"); +food_service = [1 1; 5 5; 10 10; 4 6; 6 4; 7 4] +puts ("\nThe Tip is:\n\n"); +tip = evalfis (food_service, fis, 1001) Deleted: trunk/octave-forge/main/fuzzy-logic-toolkit/inst/mamdani_demo.m =================================================================== --- trunk/octave-forge/main/fuzzy-logic-toolkit/inst/mamdani_demo.m 2011-07-19 15:08:02 UTC (rev 8390) +++ trunk/octave-forge/main/fuzzy-logic-toolkit/inst/mamdani_demo.m 2011-07-19 17:59:30 UTC (rev 8391) @@ -1,94 +0,0 @@ -## Copyright (C) 2011 L. Markowsky <lm...@us...> -## -## This file is part of the fuzzy-logic-toolkit. -## -## The fuzzy-logic-toolkit is free software; you can redistribute it -## and/or modify it under the terms of the GNU General Public License -## as published by the Free Software Foundation; either version 3 of -## the License, or (at your option) any later version. -## -## The fuzzy-logic-toolkit is distributed in the hope that it will be -## useful, but WITHOUT ANY WARRANTY; without even the implied warranty -## of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with the fuzzy-logic-toolkit; see the file COPYING. If not, -## see <http://www.gnu.org/licenses/>. - -## -*- texinfo -*- -## @deftypefn {Script File} {} mamdani_demo -## Demonstrate the use of the fuzzy_logic_toolkit to read and evaluate a -## Mamdani-type FIS stored in a file. -## -## The demo: -## @itemize @minus -## @item -## evaluates a Mamdani-type FIS for a given input -## @item -## plots the output membership functions -## @item -## plots the output as a function of two inputs -## @item -## plots the output of individual rules -## @item -## plots the aggregated fuzzy output and the crisp output -## @end itemize -## -## @seealso{commandline_demo, heart_demo, tipping_demo} -## @end deftypefn - -## Author: L. Markowsky -## Keywords: fuzzy-logic-toolkit fuzzy tests demos -## Note: This example is based on an assignment written by -## Dr. Bruce Segee (University of Maine Dept. of ECE). -## Directory: fuzzy-logic-toolkit/inst -## Filename: mamdani_demo.m -## Last-Modified: 7 Jun 2011 - -## Read the FIS structure from a file. -fis=readfis ('mamdani-tip-calculator'); - -## Plot the input and output membership functions. -plotmf (fis, 'input', 1); -plotmf (fis, 'input', 2); -plotmf (fis, 'output', 1); - -## Plot the Tip as a function of Food-Quality and Service. -gensurf (fis); - -## Calculate the Tip using (Food-Quality, Service) = (4, 6). -[output, rule_input, rule_output, fuzzy_output] = evalfis ([4 6], fis, 1001); - -## Plot the output of the individual fuzzy rules (on one set of axes). -x_axis = linspace (fis.output(1).range(1), fis.output(1).range(2), 1001); -colors = ['r' 'b' 'm' 'g']; -figure ('NumberTitle', 'off', 'Name', ... - 'Output of Fuzzy Rules 1-4 for Input = (4, 6)'); - -for i = 1 : 4 - y_label = [colors(i) ";Rule " num2str(i) ";"]; - plot (x_axis, rule_output(:,i), y_label, 'LineWidth', 2); - hold on; -endfor - -ylim ([-0.1, 1.1]); -xlabel ('Tip', 'FontWeight', 'bold'); -grid; -hold; - -## Plot the aggregated fuzzy output and the crisp output (on one set of axes). -figure('NumberTitle', 'off', 'Name', 'Aggregation and Defuzzification for Input = (4, 6)'); -plot (x_axis, fuzzy_output, "b;Aggregated Fuzzy Output;", 'LineWidth', 2); -hold on; -crisp_output = evalmf(x_axis, output, 'constant'); -y_label = ["r;Crisp Output = " num2str(output) "%;"]; -plot (x_axis, crisp_output, y_label, 'LineWidth', 2); -ylim ([-0.1, 1.1]); -xlabel ('Tip', 'FontWeight', 'bold'); -grid; -hold; - -## Show the rules in symbolic format. -puts ("\nMamdani Tip Calculator Rules:\n\n"); -showrule (fis, 1:columns(fis.rule), 'symbolic'); Added: trunk/oct... [truncated message content] |