From: <lm...@us...> - 2011-11-13 18:37:14
|
Revision: 9082 http://octave.svn.sourceforge.net/octave/?rev=9082&view=rev Author: lmarkov Date: 2011-11-13 18:37:05 +0000 (Sun, 13 Nov 2011) Log Message: ----------- A inst/heart_disease_demo_1.m M inst/smf.m A inst/heart_disease_demo_2.m M inst/mamdani_tip_demo.m M inst/gauss2mf.m M inst/writefis.m M inst/zmf.m M inst/addvar.m M inst/showrule.m M inst/gbellmf.m A inst/hamacher_product.m A inst/algebraic_product.m M inst/dsigmf.m M inst/gensurf.m A inst/einstein_product.m M inst/sugeno_tip_demo.m M inst/getfis.m M inst/trimf.m M inst/showfis.m M inst/cubic_approx_demo.m M inst/psigmf.m D inst/heart_demo_1.m D inst/heart_demo_2.m A inst/drastic_product.m M inst/evalfis.m M inst/trapmf.m A inst/bounded_difference.m M inst/linear_tip_demo.m M inst/newfis.m M inst/pimf.m A inst/hamacher_sum.m A inst/algebraic_sum.m A inst/investment_portfolio_demo.m M inst/plotmf.m A inst/einstein_sum.m A inst/bounded_sum.m M inst/sigmf.m M inst/gaussmf.m M inst/evalmf.m M inst/sugeno_tip_calculator.fis M inst/addmf.m M inst/readfis.m A inst/drastic_sum.m A inst/investment_portfolio.fis M inst/cubic_approximator.fis M inst/addrule.m Modified Paths: -------------- trunk/octave-forge/main/fuzzy-logic-toolkit/inst/addmf.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/cubic_approx_demo.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/cubic_approximator.fis trunk/octave-forge/main/fuzzy-logic-toolkit/inst/dsigmf.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/gauss2mf.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/gaussmf.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/gbellmf.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/linear_tip_demo.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/mamdani_tip_demo.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/newfis.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/pimf.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/plotmf.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/psigmf.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/readfis.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/sigmf.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/smf.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/sugeno_tip_calculator.fis trunk/octave-forge/main/fuzzy-logic-toolkit/inst/sugeno_tip_demo.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/trapmf.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/trimf.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/writefis.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/zmf.m Added Paths: ----------- trunk/octave-forge/main/fuzzy-logic-toolkit/inst/algebraic_product.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/algebraic_sum.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/bounded_difference.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/bounded_sum.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/drastic_product.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/drastic_sum.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/einstein_product.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/einstein_sum.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/hamacher_product.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/hamacher_sum.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/heart_disease_demo_1.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/heart_disease_demo_2.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/investment_portfolio.fis trunk/octave-forge/main/fuzzy-logic-toolkit/inst/investment_portfolio_demo.m Removed Paths: ------------- trunk/octave-forge/main/fuzzy-logic-toolkit/inst/heart_demo_1.m trunk/octave-forge/main/fuzzy-logic-toolkit/inst/heart_demo_2.m Modified: trunk/octave-forge/main/fuzzy-logic-toolkit/inst/addmf.m =================================================================== --- trunk/octave-forge/main/fuzzy-logic-toolkit/inst/addmf.m 2011-11-13 18:30:38 UTC (rev 9081) +++ trunk/octave-forge/main/fuzzy-logic-toolkit/inst/addmf.m 2011-11-13 18:37:05 UTC (rev 9082) @@ -51,10 +51,9 @@ ## them for FIS inputs or Mamdani-type FIS outputs has not yet been tested. ## ## @noindent -## To run the demonstration code below, type @t{demo('addmf')} at the -## Octave prompt. This demo creates two FIS input variables and associated -## membership functions and then produces two figures showing the term -## sets for the two FIS inputs. +## To run the demonstration code, type @t{demo('addmf')} at the Octave prompt. +## This demo creates two FIS input variables and associated membership functions +## and then produces two figures showing the term sets for the two FIS inputs. ## ## @seealso{rmmf, setfis} ## @end deftypefn @@ -65,7 +64,7 @@ ## Filename: addmf.m ## Note: The demo code is based on an assignment written by ## Dr. Bruce Segee (University of Maine Dept. of ECE). -## Last-Modified: 30 Aug 2011 +## Last-Modified: 28 Oct 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/addrule.m =================================================================== --- trunk/octave-forge/main/fuzzy-logic-toolkit/inst/addrule.m 2011-11-13 18:30:38 UTC (rev 9081) +++ trunk/octave-forge/main/fuzzy-logic-toolkit/inst/addrule.m 2011-11-13 18:37:05 UTC (rev 9082) @@ -41,35 +41,50 @@ ## connect == antecedent connective (1 == and; 2 == or) ## @end itemize ## -## To express the hedge "not", prepend a minus sign to the membership function -## index. ("Not" is the only hedge supported.) To omit an input or output, use -## 0 for the membership function index. The consequent connective is always -## "and". +## To express: +## @itemize @w +## @item +## "not" -- prepend a minus sign to the membership function index +## @item +## "somewhat" -- append ".05" to the membership function index +## @item +## "very" -- append ".20" to the membership function index +## @item +## "extremely" -- append ".30" to the membership function index +## @item +## "very very" -- append ".40" to the membership function index +## @item +## custom hedge -- append .xy, where x.y is the degree to which the membership +## value should be raised, to the membership function index +## @end itemize ## +## To omit an input or output, use 0 for the membership function index. +## The consequent connective is always "and". +## ## @noindent ## For example, to express: ## @example -## "If input_1 is mf_2 or input_3 is not mf_1, -## then output_2 is mf_1." +## "If (input_1 is mf_2) or (input_3 is not mf_1) or (input_4 is very mf_1), +## then (output_1 is mf_2) and (output_2 is mf_1^0.3)." ## @end example ## ## @noindent ## with weight 1, the corresponding row of @var{rule_matrix} would be: ## @example -## [2 0 -1 0 1 1 2] +## [2 0 -1 4.2 2 1.03 1 2] ## @end example ## ## @noindent -## For a complete example that uses addrule, see heart_demo_1.m. +## For a complete example that uses addrule, see heart_disease_demo_1.m. ## -## @seealso{heart_demo_1, showrule} +## @seealso{heart_disease_demo_1, showrule} ## @end deftypefn ## Author: L. Markowsky ## Keywords: fuzzy-logic-toolkit fuzzy rule ## Directory: fuzzy-logic-toolkit/inst/ ## Filename: addrule.m -## Last-Modified: 16 Jul 2011 +## Last-Modified: 11 Nov 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-11-13 18:30:38 UTC (rev 9081) +++ trunk/octave-forge/main/fuzzy-logic-toolkit/inst/addvar.m 2011-11-13 18:37:05 UTC (rev 9082) @@ -38,8 +38,7 @@ ## specify the lower and upper bounds of the variable's domain. ## ## @noindent -## To run the demonstration code below, type @t{demo('addvar')} at the -## Octave prompt. +## To run the demonstration code, type @t{demo('addvar')} at the Octave prompt. ## ## @end deftypefn @@ -47,7 +46,7 @@ ## Keywords: fuzzy-logic-toolkit fuzzy variable ## Directory: fuzzy-logic-toolkit/inst/ ## Filename: addvar.m -## Last-Modified: 30 Aug 2011 +## Last-Modified: 28 Oct 2011 function fis = addvar (fis, in_or_out, var_name, var_range) Added: trunk/octave-forge/main/fuzzy-logic-toolkit/inst/algebraic_product.m =================================================================== --- trunk/octave-forge/main/fuzzy-logic-toolkit/inst/algebraic_product.m (rev 0) +++ trunk/octave-forge/main/fuzzy-logic-toolkit/inst/algebraic_product.m 2011-11-13 18:37:05 UTC (rev 9082) @@ -0,0 +1,56 @@ +## 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 {Function File} {@var{retval} =} algebraic_product (@var{x}) +## @deftypefnx {Function File} {@var{retval} =} algebraic_product (@var{x}, @var{y}) +## +## Return the algebraic product of the input. +## The algebraic product of two real scalars x and y is: x * y +## +## For one vector argument, apply the algebraic product to all of elements of +## the vector. (The algebraic product is associative.) For one two-dimensional +## matrix argument, return a vector of the algebraic product of each column. +## +## For two vectors or matrices of identical dimensions, or for one scalar and +## one vector or matrix argument, return the pair-wise product. +## +## @seealso{algebraic_sum, bounded_difference, bounded_sum, drastic_product, drastic_sum, einstein_product, einstein_sum, hamacher_product, hamacher_sum} +## @end deftypefn + +## Author: L. Markowsky +## Keywords: fuzzy-logic-toolkit fuzzy algebraic_product +## Directory: fuzzy-logic-toolkit/inst/ +## Filename: algebraic_product.m +## Last-Modified: 12 Nov 2011 + +function retval = algebraic_product (x, y = 0) + if (!(isreal (x) && isreal (y))) + puts ("Type 'help algebraic_product' for more information.\n"); + error ("algebraic_product requires real scalar or matrix arguments\n"); + elseif (nargin == 2 && ... + (isscalar (x) || isscalar (y) || isequal (size (x), size (y)))) + retval = x .* y; + elseif (nargin == 1 && ndims (x) <= 2) + retval = prod (x); + else + puts ("Type 'help algebraic_product' for more information.\n"); + error ("invalid arguments to function algebraic_product\n"); + endif +endfunction + Added: trunk/octave-forge/main/fuzzy-logic-toolkit/inst/algebraic_sum.m =================================================================== --- trunk/octave-forge/main/fuzzy-logic-toolkit/inst/algebraic_sum.m (rev 0) +++ trunk/octave-forge/main/fuzzy-logic-toolkit/inst/algebraic_sum.m 2011-11-13 18:37:05 UTC (rev 9082) @@ -0,0 +1,71 @@ +## 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 {Function File} {@var{retval} =} algebraic_sum (@var{x, y}) +## @deftypefnx {Function File} {@var{retval} =} algebraic_sum (@var{x, y}) +## +## Return the algebraic sum of the input. +## The algebraic sum of two real scalars x and y is: x + y - x * y +## +## For one vector argument, apply the algebraic sum to all of elements of +## the vector. (The algebraic sum is associative.) For one two-dimensional +## matrix argument, return a vector of the algebraic sum of each column. +## +## For two vectors or matrices of identical dimensions, or for one scalar and +## one vector or matrix argument, return the pair-wise algebraic sum. +## +## @seealso{algebraic_product, bounded_difference, bounded_sum, drastic_product, drastic_sum, einstein_product, einstein_sum, hamacher_product, hamacher_sum} +## @end deftypefn + +## Author: L. Markowsky +## Keywords: fuzzy-logic-toolkit fuzzy algebraic_sum +## Directory: fuzzy-logic-toolkit/inst/ +## Filename: algebraic_sum.m +## Last-Modified: 12 Nov 2011 + +function retval = algebraic_sum (x, y = 0) + if (!(isreal (x) && isreal (y))) + puts ("Type 'help algebraic_sum' for more information.\n"); + error ("algebraic_sum requires real scalar or matrix arguments\n"); + elseif (nargin == 2 && ... + (isscalar (x) || isscalar (y) || isequal (size (x), size (y)))) + retval = x .+ y .- x .* y; + elseif (nargin == 1 && isvector (x)) + retval = algebraic_sum_of_vector (x); + elseif (nargin == 1 && ndims (x) == 2) + num_cols = columns (x); + retval = zeros (1, num_cols); + for i = 1 : num_cols + retval(i) = algebraic_sum_of_vector (x(:, i)); + endfor + else + puts ("Type 'help algebraic_sum' for more information.\n"); + error ("invalid arguments to function algebraic_sum\n"); + endif +endfunction + +function retval = algebraic_sum_of_vector (real_vector) + x = 0; + for i = 1 : length (real_vector) + y = real_vector(i); + x = x + y - x * y; + endfor + retval = x; +endfunction + Added: trunk/octave-forge/main/fuzzy-logic-toolkit/inst/bounded_difference.m =================================================================== --- trunk/octave-forge/main/fuzzy-logic-toolkit/inst/bounded_difference.m (rev 0) +++ trunk/octave-forge/main/fuzzy-logic-toolkit/inst/bounded_difference.m 2011-11-13 18:37:05 UTC (rev 9082) @@ -0,0 +1,72 @@ +## 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 {Function File} {@var{retval} =} bounded_difference (@var{x}) +## @deftypefnx {Function File} {@var{retval} =} bounded_difference (@var{x}, @var{y}) +## +## Return the bounded difference of the input. +## The bounded difference of two real scalars x and y is: max (0, x + y - 1) +## +## For one vector argument, apply the bounded difference to all of the elements +## of the vector. (The bounded difference is associative.) For one +## two-dimensional matrix argument, return a vector of the bounded difference +## of each column. +## +## For two vectors or matrices of identical dimensions, or for one scalar and +## one vector or matrix argument, return the pair-wise bounded difference. +## +## @seealso{algebraic_product, algebraic_sum, bounded_sum, drastic_product, drastic_sum, einstein_product, einstein_sum, hamacher_product, hamacher_sum} +## @end deftypefn + +## Author: L. Markowsky +## Keywords: fuzzy-logic-toolkit fuzzy bounded_difference +## Directory: fuzzy-logic-toolkit/inst/ +## Filename: bounded_difference.m +## Last-Modified: 12 Nov 2011 + +function retval = bounded_difference (x, y = 0) + if (!(isreal (x) && isreal (y))) + puts ("Type 'help bounded_difference' for more information.\n"); + error ("bounded_difference requires real scalar or matrix arguments\n"); + elseif (nargin == 2 && ... + (isscalar (x) || isscalar (y) || isequal (size (x), size (y)))) + retval = max (0, (x .+ y - 1)); + elseif (nargin == 1 && isvector (x)) + retval = bounded_difference_of_vector (x); + elseif (nargin == 1 && ndims (x) == 2) + num_cols = columns (x); + retval = zeros (1, num_cols); + for i = 1 : num_cols + retval(i) = bounded_difference_of_vector (x(:, i)); + endfor + else + puts ("Type 'help bounded_difference' for more information.\n"); + error ("invalid arguments to function bounded_difference\n"); + endif +endfunction + +function retval = bounded_difference_of_vector (real_vector) + x = 1; + for i = 1 : length (real_vector) + y = real_vector(i); + x = max (0, (x + y - 1)); + endfor + retval = x; +endfunction + Added: trunk/octave-forge/main/fuzzy-logic-toolkit/inst/bounded_sum.m =================================================================== --- trunk/octave-forge/main/fuzzy-logic-toolkit/inst/bounded_sum.m (rev 0) +++ trunk/octave-forge/main/fuzzy-logic-toolkit/inst/bounded_sum.m 2011-11-13 18:37:05 UTC (rev 9082) @@ -0,0 +1,71 @@ +## 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 {Function File} {@var{retval} =} bounded_sum (@var{x}) +## @deftypefnx {Function File} {@var{retval} =} bounded_sum (@var{x}, @var{y}) +## +## Return the bounded sum of the input. +## The bounded sum of two real scalars x and y is: min (1, x + y) +## +## For one vector argument, apply the bounded sum to all of elements of +## the vector. (The bounded sum is associative.) For one two-dimensional +## matrix argument, return a vector of the bounded sum of each column. +## +## For two vectors or matrices of identical dimensions, or for one scalar and +## one vector or matrix argument, return the pair-wise bounded sum. +## +## @seealso{algebraic_product, algebraic_sum, bounded_difference, drastic_product, drastic_sum, einstein_product, einstein_sum, hamacher_product, hamacher_sum} +## @end deftypefn + +## Author: L. Markowsky +## Keywords: fuzzy-logic-toolkit fuzzy bounded_sum +## Directory: fuzzy-logic-toolkit/inst/ +## Filename: bounded_sum.m +## Last-Modified: 12 Nov 2011 + +function retval = bounded_sum (x, y = 0) + if (!(isreal (x) && isreal (y))) + puts ("Type 'help bounded_sum' for more information.\n"); + error ("bounded_sum requires real scalar or matrix arguments\n"); + elseif (nargin == 2 && ... + (isscalar (x) || isscalar (y) || isequal (size (x), size (y)))) + retval = min (1, (x .+ y)); + elseif (nargin == 1 && isvector (x)) + retval = bounded_sum_of_vector (x); + elseif (nargin == 1 && ndims (x) == 2) + num_cols = columns (x); + retval = zeros (1, num_cols); + for i = 1 : num_cols + retval(i) = bounded_sum_of_vector (x(:, i)); + endfor + else + puts ("Type 'help bounded_sum' for more information.\n"); + error ("invalid arguments to function bounded_sum\n"); + endif +endfunction + +function retval = bounded_sum_of_vector (real_vector) + x = 0; + for i = 1 : length (real_vector) + y = real_vector(i); + x = min (1, (x + y)); + endfor + retval = x; +endfunction + Modified: trunk/octave-forge/main/fuzzy-logic-toolkit/inst/cubic_approx_demo.m =================================================================== --- trunk/octave-forge/main/fuzzy-logic-toolkit/inst/cubic_approx_demo.m 2011-11-13 18:30:38 UTC (rev 9081) +++ trunk/octave-forge/main/fuzzy-logic-toolkit/inst/cubic_approx_demo.m 2011-11-13 18:37:05 UTC (rev 9082) @@ -20,8 +20,7 @@ ## @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. +## non-linear function using a Sugeno-type FIS with linear output functions. ## ## The demo: ## @itemize @minus @@ -30,23 +29,26 @@ ## @item ## plots the input membership functions ## @item -## plots the output as a function of the input +## plots the (linear) output functions +## @item +## plots the FIS 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} +## @seealso{heart_disease_demo_1, heart_disease_demo_2, investment_portfolio_demo, 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: 27 Aug 2011 +## Last-Modified: 12 Nov 2011 ## Read the FIS structure from a file. fis = readfis ('cubic_approximator.fis'); -## Plot the input membership functions. +## Plot the input membership functions and linear output functions. plotmf (fis, 'input', 1); +plotmf (fis, 'output', 1, -150, 150); -## Plot the output y as a function of the input x. +## Plot the FIS output y as a function of the input x. gensurf (fis); Modified: trunk/octave-forge/main/fuzzy-logic-toolkit/inst/cubic_approximator.fis =================================================================== --- trunk/octave-forge/main/fuzzy-logic-toolkit/inst/cubic_approximator.fis 2011-11-13 18:30:38 UTC (rev 9081) +++ trunk/octave-forge/main/fuzzy-logic-toolkit/inst/cubic_approximator.fis 2011-11-13 18:37:05 UTC (rev 9082) @@ -29,7 +29,7 @@ [Output1] Name='Approx-X-Cubed' -Range=[-130 130] +Range=[-5 5] NumMFs=11 MF1 = 'Tangent-at-Neg-Five':'linear', [75 250] MF2 = 'Tangent-at-Neg-Four':'linear', [48 128] Added: trunk/octave-forge/main/fuzzy-logic-toolkit/inst/drastic_product.m =================================================================== --- trunk/octave-forge/main/fuzzy-logic-toolkit/inst/drastic_product.m (rev 0) +++ trunk/octave-forge/main/fuzzy-logic-toolkit/inst/drastic_product.m 2011-11-13 18:37:05 UTC (rev 9082) @@ -0,0 +1,107 @@ +## 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 {Function File} {@var{retval} =} drastic_product (@var{x}) +## @deftypefnx {Function File} {@var{retval} =} drastic_product (@var{x}, @var{y}) +## +## Return the drastic product of the input. +## The drastic product of two real scalars x and y is: +## @example +## @group +## min (x, y) if max (x, y) == 1 +## 0 otherwise +## @end group +## @end example +## +## For one vector argument, apply the drastic product to all of the elements +## of the vector. (The drastic product is associative.) For one +## two-dimensional matrix argument, return a vector of the drastic product +## of each column. +## +## For two vectors or matrices of identical dimensions, or for one scalar and +## one vector or matrix argument, return the pair-wise drastic product. +## +## @seealso{algebraic_product, algebraic_sum, bounded_difference, bounded_sum, drastic_sum, einstein_product, einstein_sum, hamacher_product, hamacher_sum} +## @end deftypefn + +## Author: L. Markowsky +## Keywords: fuzzy-logic-toolkit fuzzy drastic_product +## Directory: fuzzy-logic-toolkit/inst/ +## Filename: drastic_product.m +## Last-Modified: 12 Nov 2011 + +function retval = drastic_product (x, y = 0) + if (nargin == 0 || nargin > 2 || + !is_real_matrix (x) || !is_real_matrix (y)) + argument_error + + elseif (nargin == 1) + if (isvector (x)) + retval = vector_arg (x); + elseif (ndims (x) == 2) + retval = matrix_arg (x); + else + argument_error; + endif + + elseif (nargin == 2) + if (isequal (size (x), size (y))) + retval = arrayfun (@scalar_args, x, y); + elseif (isscalar (x) && ismatrix (y)) + x = x * ones (size (y)); + retval = arrayfun (@scalar_args, x, y); + elseif (ismatrix (x) && isscalar (y)) + y = y * ones (size (x)); + retval = arrayfun (@scalar_args, x, y); + else + argument_error; + endif + endif +endfunction + +function retval = scalar_args (x, y) + if (max (x, y) == 1) + retval = min (x, y); + else + retval = 0; + endif +endfunction + +function retval = vector_arg (x) + if (isempty (x)) + retval = 1; + elseif (max (x) == 1) + retval = min (x); + else + retval = 0; + endif +endfunction + +function retval = matrix_arg (x) + num_cols = columns (x); + retval = zeros (1, num_cols); + for i = 1 : num_cols + retval(i) = vector_arg (x(:, i)); + endfor +endfunction + +function argument_error + puts ("Type 'help drastic_product' for more information.\n"); + error ("invalid arguments to function drastic_product\n"); +endfunction Added: trunk/octave-forge/main/fuzzy-logic-toolkit/inst/drastic_sum.m =================================================================== --- trunk/octave-forge/main/fuzzy-logic-toolkit/inst/drastic_sum.m (rev 0) +++ trunk/octave-forge/main/fuzzy-logic-toolkit/inst/drastic_sum.m 2011-11-13 18:37:05 UTC (rev 9082) @@ -0,0 +1,107 @@ +## 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 {Function File} {@var{retval} =} drastic_sum (@var{x}) +## @deftypefnx {Function File} {@var{retval} =} drastic_sum (@var{x}, @var{y}) +## +## Return the drastic sum of the input. +## The drastic sum of two real scalars x and y is: +## @example +## @group +## max (x, y) if min (x, y) == 0 +## 1 otherwise +## @end group +## @end example +## +## For one vector argument, apply the drastic sum to all of the elements +## of the vector. (The drastic sum is associative.) For one +## two-dimensional matrix argument, return a vector of the drastic sum +## of each column. +## +## For two vectors or matrices of identical dimensions, or for one scalar and +## one vector or matrix argument, return the pair-wise drastic sum. +## +## @seealso{algebraic_product, algebraic_sum, bounded_difference, bounded_sum, drastic_product, einstein_product, einstein_sum, hamacher_product, hamacher_sum} +## @end deftypefn + +## Author: L. Markowsky +## Keywords: fuzzy-logic-toolkit fuzzy drastic_sum +## Directory: fuzzy-logic-toolkit/inst/ +## Filename: drastic_sum.m +## Last-Modified: 12 Nov 2011 + +function retval = drastic_sum (x, y = 0) + if (nargin == 0 || nargin > 2 || + !is_real_matrix (x) || !is_real_matrix (y)) + argument_error + + elseif (nargin == 1) + if (isvector (x)) + retval = vector_arg (x); + elseif (ndims (x) == 2) + retval = matrix_arg (x); + else + argument_error; + endif + + elseif (nargin == 2) + if (isequal (size (x), size (y))) + retval = arrayfun (@scalar_args, x, y); + elseif (isscalar (x) && ismatrix (y)) + x = x * ones (size (y)); + retval = arrayfun (@scalar_args, x, y); + elseif (ismatrix (x) && isscalar (y)) + y = y * ones (size (x)); + retval = arrayfun (@scalar_args, x, y); + else + argument_error; + endif + endif +endfunction + +function retval = scalar_args (x, y) + if (min (x, y) == 0) + retval = max (x, y); + else + retval = 1; + endif +endfunction + +function retval = vector_arg (x) + if (isempty (x)) + retval = 0; + elseif (min (x) == 0) + retval = max (x); + else + retval = 1; + endif +endfunction + +function retval = matrix_arg (x) + num_cols = columns (x); + retval = zeros (1, num_cols); + for i = 1 : num_cols + retval(i) = vector_arg (x(:, i)); + endfor +endfunction + +function argument_error + puts ("Type 'help drastic_sum' for more information.\n"); + error ("invalid arguments to function drastic_sum\n"); +endfunction Modified: trunk/octave-forge/main/fuzzy-logic-toolkit/inst/dsigmf.m =================================================================== --- trunk/octave-forge/main/fuzzy-logic-toolkit/inst/dsigmf.m 2011-11-13 18:30:38 UTC (rev 9081) +++ trunk/octave-forge/main/fuzzy-logic-toolkit/inst/dsigmf.m 2011-11-13 18:37:05 UTC (rev 9082) @@ -59,8 +59,7 @@ ## Here, the symbol ~ means "approximately equal". ## ## @noindent -## To run the demonstration code below, type @t{demo('dsigmf')} at the -## Octave prompt. +## To run the demonstration code, type @t{demo('dsigmf')} at the Octave prompt. ## ## @seealso{gauss2mf, gaussmf, gbellmf, pimf, psigmf, sigmf, smf, trapmf, trimf, zmf} ## @end deftypefn @@ -69,7 +68,7 @@ ## Keywords: fuzzy-logic-toolkit fuzzy membership-function sigmoidal ## Directory: fuzzy-logic-toolkit/inst/ ## Filename: dsigmf.m -## Last-Modified: 7 Jun 2011 +## Last-Modified: 28 Oct 2011 function y = dsigmf (x, params) Added: trunk/octave-forge/main/fuzzy-logic-toolkit/inst/einstein_product.m =================================================================== --- trunk/octave-forge/main/fuzzy-logic-toolkit/inst/einstein_product.m (rev 0) +++ trunk/octave-forge/main/fuzzy-logic-toolkit/inst/einstein_product.m 2011-11-13 18:37:05 UTC (rev 9082) @@ -0,0 +1,97 @@ +## 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 {Function File} {@var{retval} =} einstein_product (@var{x}) +## @deftypefnx {Function File} {@var{retval} =} einstein_product (@var{x}, @var{y}) +## +## Return the Einstein product of the input. +## The Einstein product of two real scalars x and y is: +## (x * y) / (2 - (x + y - x * y)) +## +## For one vector argument, apply the Einstein product to all of the elements +## of the vector. (The Einstein product is associative.) For one +## two-dimensional matrix argument, return a vector of the Einstein product +## of each column. +## +## For two vectors or matrices of identical dimensions, or for one scalar and +## one vector or matrix argument, return the pair-wise Einstein product. +## +## @seealso{algebraic_product, algebraic_sum, bounded_difference, bounded_sum, drastic_product, drastic_sum, einstein_sum, hamacher_product, hamacher_sum} +## @end deftypefn + +## Author: L. Markowsky +## Keywords: fuzzy-logic-toolkit fuzzy einstein_product +## Directory: fuzzy-logic-toolkit/inst/ +## Filename: einstein_product.m +## Last-Modified: 12 Nov 2011 + +function retval = einstein_product (x, y = 0) + if (nargin == 0 || nargin > 2 || + !is_real_matrix (x) || !is_real_matrix (y)) + argument_error + + elseif (nargin == 1) + if (isvector (x)) + retval = vector_arg (x); + elseif (ndims (x) == 2) + retval = matrix_arg (x); + else + argument_error; + endif + + elseif (nargin == 2) + if (isequal (size (x), size (y))) + retval = arrayfun (@scalar_args, x, y); + elseif (isscalar (x) && ismatrix (y)) + x = x * ones (size (y)); + retval = arrayfun (@scalar_args, x, y); + elseif (ismatrix (x) && isscalar (y)) + y = y * ones (size (x)); + retval = arrayfun (@scalar_args, x, y); + else + argument_error; + endif + endif +endfunction + +function retval = scalar_args (x, y) + retval = (x * y) / (2 - (x + y - x * y)); +endfunction + +function retval = vector_arg (real_vector) + x = 1; + for i = 1 : length (real_vector) + y = real_vector(i); + x = (x * y) / (2 - (x + y - x * y)); + endfor + retval = x; +endfunction + +function retval = matrix_arg (x) + num_cols = columns (x); + retval = zeros (1, num_cols); + for i = 1 : num_cols + retval(i) = vector_arg (x(:, i)); + endfor +endfunction + +function argument_error + puts ("Type 'help einstein_product' for more information.\n"); + error ("invalid arguments to function einstein_product\n"); +endfunction Added: trunk/octave-forge/main/fuzzy-logic-toolkit/inst/einstein_sum.m =================================================================== --- trunk/octave-forge/main/fuzzy-logic-toolkit/inst/einstein_sum.m (rev 0) +++ trunk/octave-forge/main/fuzzy-logic-toolkit/inst/einstein_sum.m 2011-11-13 18:37:05 UTC (rev 9082) @@ -0,0 +1,96 @@ +## 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 {Function File} {@var{retval} =} einstein_sum (@var{x}) +## @deftypefnx {Function File} {@var{retval} =} einstein_sum (@var{x}, @var{y}) +## +## Return the Einstein sum of the input. +## The Einstein sum of two real scalars x and y is: (x + y) / (1 + x * y) +## +## For one vector argument, apply the Einstein sum to all of the elements +## of the vector. (The Einstein sum is associative.) For one +## two-dimensional matrix argument, return a vector of the Einstein sum +## of each column. +## +## For two vectors or matrices of identical dimensions, or for one scalar and +## one vector or matrix argument, return the pair-wise Einstein sum. +## +## @seealso{algebraic_product, algebraic_sum, bounded_difference, bounded_sum, drastic_product, drastic_sum, einstein_product, hamacher_product, hamacher_sum} +## @end deftypefn + +## Author: L. Markowsky +## Keywords: fuzzy-logic-toolkit fuzzy einstein_sum +## Directory: fuzzy-logic-toolkit/inst/ +## Filename: einstein_sum.m +## Last-Modified: 12 Nov 2011 + +function retval = einstein_sum (x, y = 0) + if (nargin == 0 || nargin > 2 || + !is_real_matrix (x) || !is_real_matrix (y)) + argument_error + + elseif (nargin == 1) + if (isvector (x)) + retval = vector_arg (x); + elseif (ndims (x) == 2) + retval = matrix_arg (x); + else + argument_error; + endif + + elseif (nargin == 2) + if (isequal (size (x), size (y))) + retval = arrayfun (@scalar_args, x, y); + elseif (isscalar (x) && ismatrix (y)) + x = x * ones (size (y)); + retval = arrayfun (@scalar_args, x, y); + elseif (ismatrix (x) && isscalar (y)) + y = y * ones (size (x)); + retval = arrayfun (@scalar_args, x, y); + else + argument_error; + endif + endif +endfunction + +function retval = scalar_args (x, y) + retval = (x + y) / (1 + x * y); +endfunction + +function retval = vector_arg (real_vector) + x = 0; + for i = 1 : length (real_vector) + y = real_vector(i); + x = (x + y) / (1 + x * y); + endfor + retval = x; +endfunction + +function retval = matrix_arg (x) + num_cols = columns (x); + retval = zeros (1, num_cols); + for i = 1 : num_cols + retval(i) = vector_arg (x(:, i)); + endfor +endfunction + +function argument_error + puts ("Type 'help einstein_sum' for more information.\n"); + error ("invalid arguments to function einstein_sum\n"); +endfunction Modified: trunk/octave-forge/main/fuzzy-logic-toolkit/inst/evalfis.m =================================================================== --- trunk/octave-forge/main/fuzzy-logic-toolkit/inst/evalfis.m 2011-11-13 18:30:38 UTC (rev 9081) +++ trunk/octave-forge/main/fuzzy-logic-toolkit/inst/evalfis.m 2011-11-13 18:37:05 UTC (rev 9082) @@ -90,7 +90,45 @@ ## @end example ## ## @noindent +## Evaluation of hedges and "not": ## +## Each element of each FIS rule antecedent and consequent indicates the +## corresponding membership function, hedge, and whether or not "not" should +## be applied to the result. The index of the membership function to be used is +## given by the positive whole number portion of the antecedent/consequent +## vector entry, the hedge is given by the fractional portion (if any), and +## "not" is indicated by a minus sign. A "0" as the integer portion in any +## position in the rule indicates that the corresponding FIS input or output +## variable is omitted from the rule. +## +## For custom hedges and the four built-in hedges "somewhat," "very," +## "extremely," and "very very," the membership function value (without the +## hedge or "not") is raised to the power corresponding to the hedge. All +## hedges are rounded to 2 digits. +## +## For example, if "mu(x)" denotes the matching degree of the input to the +## corresponding membership function without a hedge or "not," then the final +## matching degree recorded in @var{rule_input} will be computed by applying +## the hedge and "not" in two steps. First, the hedge is applied: +## +## @example +## @group +## (fraction == .05) <=> somewhat x <=> mu(x)^0.5 <=> sqrt(mu(x)) +## (fraction == .20) <=> very x <=> mu(x)^2 <=> sqr(mu(x)) +## (fraction == .30) <=> extremely x <=> mu(x)^3 <=> cube(mu(x)) +## (fraction == .40) <=> very very x <=> mu(x)^4 +## (fraction == .dd) <=> <custom hedge> x <=> mu(x)^(dd/10) +## @end group +## @end example +## +## After applying the appropriate hedge, "not" is calculated by: +## @example +## minus sign present <=> not x <=> 1 - mu(x) +## minus sign and hedge present <=> not <hedge> x <=> 1 - mu(x)^(dd/10) +## @end example +## +## Hedges and "not" in the consequent are handled similarly. +## ## @noindent ## The intermediate result @var{rule_output}: ## @@ -172,15 +210,17 @@ ## @noindent ## Examples: ## -## Six examples of using evalfis are shown in: +## Seven examples of using evalfis are shown in: ## @itemize @bullet ## @item ## cubic_approx_demo.m ## @item -## heart_demo_1.m +## heart_disease_demo_1.m ## @item -## heart_demo_2.m +## heart_disease_demo_2.m ## @item +## investment_portfolio_demo.m +## @item ## linear_tip_demo.m ## @item ## mamdani_tip_demo.m @@ -188,17 +228,17 @@ ## sugeno_tip_demo.m ## @end itemize ## -## @seealso{cubic_approx_demo, heart_demo_1, heart_demo_2, linear_tip_demo, mamdani_tip_demo, sugeno_tip_demo} +## @seealso{cubic_approx_demo, heart_disease_demo_1, heart_disease_demo_2, investment_portfolio_demo, 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: 16 Jul 2011 +## Last-Modified: 12 Nov 2011 function [output, rule_input, rule_output, fuzzy_output] = ... - evalfis (user_input, fis, num_points=101) + evalfis (user_input, fis, num_points = 101) ## If evalfis was called with an incorrect number of arguments, or the ## arguments do not have the correct type, print an error message and halt. Modified: trunk/octave-forge/main/fuzzy-logic-toolkit/inst/evalmf.m =================================================================== --- trunk/octave-forge/main/fuzzy-logic-toolkit/inst/evalmf.m 2011-11-13 18:30:38 UTC (rev 9081) +++ trunk/octave-forge/main/fuzzy-logic-toolkit/inst/evalmf.m 2011-11-13 18:37:05 UTC (rev 9082) @@ -18,10 +18,15 @@ ## -*- texinfo -*- ## @deftypefn {Function File} {@var{y} =} evalmf (@var{x}, @var{param}, @var{mf_type}) +## @deftypefnx {Function File} {@var{y} =} evalmf (@var{x}, @var{param}, @var{mf_type}, @var{hedge}) +## @deftypefnx {Function File} {@var{y} =} evalmf (@var{x}, @var{param}, @var{mf_type}, @var{hedge}, @var{not_flag}) ## @deftypefnx {Function File} {@var{y} =} evalmf (@var{[x1 x2 ... xn]}, @var{[param1 ... ]}, @var{mf_type}) +## @deftypefnx {Function File} {@var{y} =} evalmf (@var{[x1 x2 ... xn]}, @var{[param1 ... ]}, @var{mf_type}, @var{hedge}) +## @deftypefnx {Function File} {@var{y} =} evalmf (@var{[x1 x2 ... xn]}, @var{[param1 ... ]}, @var{mf_type}, @var{hedge}, @var{not_flag}) ## -## For a given domain, set of parameters, and membership function type, -## return the corresponding y-values for the membership function. +## For a given domain, set of parameters, membership function type, and +## optional hedge and not_flag, 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 @@ -29,38 +34,61 @@ ## corresponding to a membership function type. Evalmf handles both built-in and ## custom membership functions. ## +## For custom hedges and the four built-in hedges "somewhat", "very", +## "extremely", and "very very", raise the membership function values to +## the power corresponding to the hedge. +## +## @example +## @group +## (fraction == .05) <=> somewhat x <=> mu(x)^0.5 <=> sqrt(mu(x)) +## (fraction == .20) <=> very x <=> mu(x)^2 <=> sqr(mu(x)) +## (fraction == .30) <=> extremely x <=> mu(x)^3 <=> cube(mu(x)) +## (fraction == .40) <=> very very x <=> mu(x)^4 +## (fraction == .dd) <=> <custom hedge> x <=> mu(x)^(dd/10) +## @end group +## @end example +## +## The @var{not_flag} negates the membership function using: +## @example +## mu(not(x)) = 1 - mu(x) +## @end example +## ## @noindent -## To run the demonstration below, type @t{demo('evalmf')} at the Octave -## prompt. -## +## To run the demonstration code, type @t{demo('evalmf')} at the Octave prompt. ## @end deftypefn ## Author: L. Markowsky ## Keywords: fuzzy-logic-toolkit fuzzy membership-function evaluate ## Directory: fuzzy-logic-toolkit/inst/ ## Filename: evalmf.m -## Last-Modified: 16 Jul 2011 +## Last-Modified: 13 Nov 2011 -function y = evalmf (x, params, mf_type) +function y = evalmf (x, params, mf_type, hedge = 0, not_flag = false) - ## If the caller did not supply 3 argument values with the correct types, + ## If the caller did not supply 3 - 5 argument values with the correct types, ## print an error message and halt. - if (nargin != 3) + if ((nargin < 3) || (nargin > 5)) puts ("Type 'help evalmf' for more information.\n"); - error ("evalmf requires 3 arguments\n"); + error ("evalmf requires between 3 and 5 arguments\n"); elseif (!is_domain (x)) puts ("Type 'help evalmf' for more information.\n"); error ("evalmf's first argument must be a valid domain\n"); elseif (!is_string (mf_type)) puts ("Type 'help evalmf' for more information.\n"); - error ("evalmf's third argument to evalmf must be a string\n"); + error ("evalmf's third argument must be a string\n"); + elseif (!is_real (hedge)) + puts ("Type 'help evalmf' for more information.\n"); + error ("evalmf's fourth argument must be a real number\n"); + elseif (!isbool (not_flag)) + puts ("Type 'help evalmf' for more information.\n"); + error ("evalmf's fifth argument must be a Boolean\n"); endif ## Calculate and return the y values of the membership function on the ## domain x. - y = evalmf_private (x, params, mf_type); + y = evalmf_private (x, params, mf_type, hedge, not_flag); endfunction Modified: trunk/octave-forge/main/fuzzy-logic-toolkit/inst/gauss2mf.m =================================================================== --- trunk/octave-forge/main/fuzzy-logic-toolkit/inst/gauss2mf.m 2011-11-13 18:30:38 UTC (rev 9081) +++ trunk/octave-forge/main/fuzzy-logic-toolkit/inst/gauss2mf.m 2011-11-13 18:37:05 UTC (rev 9082) @@ -58,8 +58,7 @@ ## than 1). ## ## @noindent -## To run the demonstration code below, type @t{demo('gauss2mf')} at the -## Octave prompt. +## To run the demonstration code, type @t{demo('gauss2mf')} at the Octave prompt. ## ## @seealso{dsigmf, gaussmf, gbellmf, pimf, psigmf, sigmf, smf, trapmf, trimf, zmf} ## @end deftypefn @@ -68,7 +67,7 @@ ## Keywords: fuzzy-logic-toolkit fuzzy membership-function gaussian ## Directory: fuzzy-logic-toolkit/inst/ ## Filename: gauss2mf.m -## Last-Modified: 7 Jun 2011 +## Last-Modified: 28 Oct 2011 function y = gauss2mf (x, params) Modified: trunk/octave-forge/main/fuzzy-logic-toolkit/inst/gaussmf.m =================================================================== --- trunk/octave-forge/main/fuzzy-logic-toolkit/inst/gaussmf.m 2011-11-13 18:30:38 UTC (rev 9081) +++ trunk/octave-forge/main/fuzzy-logic-toolkit/inst/gaussmf.m 2011-11-13 18:37:05 UTC (rev 9082) @@ -54,8 +54,7 @@ ## @end itemize ## ## @noindent -## To run the demonstration code below, type @t{demo('gaussmf')} at the -## Octave prompt. +## To run the demonstration code, type @t{demo('gaussmf')} at the Octave prompt. ## ## @seealso{dsigmf, gauss2mf, gbellmf, pimf, psigmf, sigmf, smf, trapmf, trimf, zmf} ## @end deftypefn @@ -64,7 +63,7 @@ ## Keywords: fuzzy-logic-toolkit fuzzy membership-function gaussian ## Directory: fuzzy-logic-toolkit/inst/ ## Filename: gaussmf.m -## Last-Modified: 20 Jun 2011 +## Last-Modified: 28 Oct 2011 function y = gaussmf (x, params) Modified: trunk/octave-forge/main/fuzzy-logic-toolkit/inst/gbellmf.m =================================================================== --- trunk/octave-forge/main/fuzzy-logic-toolkit/inst/gbellmf.m 2011-11-13 18:30:38 UTC (rev 9081) +++ trunk/octave-forge/main/fuzzy-logic-toolkit/inst/gbellmf.m 2011-11-13 18:37:05 UTC (rev 9082) @@ -58,8 +58,7 @@ ## differentiable and is symmetric about the line x = c. ## ## @noindent -## To run the demonstration code below, type @t{demo('gbellmf')} at the -## Octave prompt. +## To run the demonstration code, type @t{demo('gbellmf')} at the Octave prompt. ## ## @seealso{dsigmf, gauss2mf, gaussmf, pimf, psigmf, sigmf, smf, trapmf, trimf, zmf} ## @end deftypefn @@ -68,7 +67,7 @@ ## Keywords: fuzzy-logic-toolkit fuzzy membership-function bell-shaped bell ## Directory: fuzzy-logic-toolkit/inst/ ## Filename: gbellmf.m -## Last-Modified: 7 Jun 2011 +## Last-Modified: 28 Oct 2011 function y = gbellmf (x, params) Modified: trunk/octave-forge/main/fuzzy-logic-toolkit/inst/gensurf.m =================================================================== --- trunk/octave-forge/main/fuzzy-logic-toolkit/inst/gensurf.m 2011-11-13 18:30:38 UTC (rev 9081) +++ trunk/octave-forge/main/fuzzy-logic-toolkit/inst/gensurf.m 2011-11-13 18:37:05 UTC (rev 9082) @@ -57,10 +57,12 @@ ## @item ## cubic_approx_demo.m ## @item -## heart_demo_1.m +## heart_disease_demo_1.m ## @item -## heart_demo_2.m +## heart_disease_demo_2.m ## @item +## investment_portfolio_demo.m +## @item ## linear_tip_demo.m ## @item ## mamdani_tip_demo.m @@ -72,17 +74,17 @@ ## The form of gensurf that suppresses plotting (the final form above) is not yet ## implemented. ## -## @seealso{cubic_approx_demo, heart_demo_1, heart_demo_2, linear_tip_demo, mamdani_tip_demo, sugeno_tip_demo, plotmf} +## @seealso{cubic_approx_demo, heart_disease_demo_1, heart_disease_demo_2, investment_portfolio_demo, 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: 30 Aug 2011 +## Last-Modified: 11 Nov 2011 -function [x, y, z] = gensurf (fis, input_axes=[1 2], output_axis=1, ... - grids=[15 15], ref_input=[], num_points=101) +function [x, y, z] = gensurf (fis, input_axes = [1 2], output_axis = 1, ... + grids = [15 15], ref_input = [], num_points = 101) ## If gensurf was called with an incorrect number of arguments, or the ## arguments do not have the correct type, print an error message and halt. Modified: trunk/octave-forge/main/fuzzy-logic-toolkit/inst/getfis.m =================================================================== --- trunk/octave-forge/main/fuzzy-logic-toolkit/inst/getfis.m 2011-11-13 18:30:38 UTC (rev 9081) +++ trunk/octave-forge/main/fuzzy-logic-toolkit/inst/getfis.m 2011-11-13 18:37:05 UTC (rev 9082) @@ -93,12 +93,12 @@ ## Keywords: fuzzy-logic-toolkit fuzzy fuzzy-inference-system fis ## Directory: fuzzy-logic-toolkit/inst/ ## Filename: getfis.m -## Last-Modified: 31 Aug 2011 +## Last-Modified: 31 Oct 2011 ##------------------------------------------------------------------------------ -function retval = getfis (fis, arg2='dummy', arg3='dummy', arg4='dummy', ... - arg5='dummy', arg6='dummy') +function retval = getfis (fis, arg2 = 'dummy', arg3 = 'dummy', ... + arg4 = 'dummy', arg5 = 'dummy', arg6 = 'dummy') switch (nargin) case 1 retval = getfis_one_arg (fis); Added: trunk/octave-forge/main/fuzzy-logic-toolkit/inst/hamacher_product.m =================================================================== --- trunk/octave-forge/main/fuzzy-logic-toolkit/inst/hamacher_product.m (rev 0) +++ trunk/octave-forge/main/fuzzy-logic-toolkit/inst/hamacher_product.m 2011-11-13 18:37:05 UTC (rev 9082) @@ -0,0 +1,101 @@ +## 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 {Function File} {@var{retval} =} hamacher_product (@var{x}) +## @deftypefnx {Function File} {@var{retval} =} hamacher_product (@var{x}, @var{y}) +## +## Return the Hamacher product of the input. +## The Hamacher product of two real scalars x and y is: +## (x * y) / (x + y - x * y) +## +## For one vector argument, apply the Hamacher product to all of the elements +## of the vector. (The Hamacher product is associative.) For one +## two-dimensional matrix argument, return a vector of the Hamacher product +## of each column. +## +## For two vectors or matrices of identical dimensions, or for one scalar and +## one vector or matrix argument, return the pair-wise Hamacher product. +## +## @seealso{algebraic_product, algebraic_sum, bounded_difference, bounded_sum, drastic_product, drastic_sum, einstein_product, einstein_sum, hamacher_sum} +## @end deftypefn + +## Author: L. Markowsky +## Keywords: fuzzy-logic-toolkit fuzzy hamacher_product +## Directory: fuzzy-logic-toolkit/inst/ +## Filename: hamacher_product.m +## Last-Modified: 12 Nov 2011 + +function retval = hamacher_product (x, y = 0) + if (nargin == 0 || nargin > 2 || + !is_real_matrix (x) || !is_real_matrix (y)) + argument_error + + elseif (nargin == 1) + if (isvector (x)) + retval = vector_arg (x); + elseif (ndims (x) == 2) + retval = matrix_arg (x); + else + argument_error; + endif + + elseif (nargin == 2) + if (isequal (size (x), size (y))) + retval = arrayfun (@scalar_args, x, y); + elseif (isscalar (x) && ismatrix (y)) + x = x * ones (size (y)); + retval = arrayfun (@scalar_args, x, y); + elseif (ismatrix (x) && isscalar (y)) + y = y * ones (size (x)); + retval = arrayfun (@scalar_args, x, y); + else + argument_error; + endif + endif +endfunction + +function retval = scalar_args (x, y) + retval = (x * y) / (x + y - x * y); +endfunction + +function retval = vector_arg (real_vector) + x = 1; + for i = 1 : length (real_vector) + y = real_vector(i); + if (x == 0 && y == 0) + x = 0; + else + x = (x * y) / (x + y - x * y); + endif + endfor + retval = x; +endfunction + +function retval = matrix_arg (x) + num_cols = columns (x); + retval = zeros (1, num_cols); + for i = 1 : num_cols + retval(i) = vector_arg (x(:, i)); + endfor +endfunction + +function argument_error + puts ("Type 'help hamacher_product' for more information.\n"); + error ("invalid arguments to function hamacher_product\n"); +endfunction Added: trunk/octave-forge/main/fuzzy-logic-toolkit/inst/hamacher_sum.m =================================================================== --- trunk/octave-forge/main/fuzzy-logic-toolkit/inst/hamacher_sum.m (rev 0) +++ trunk/octave-forge/main/fuzzy-logic-toolkit/inst/hamacher_sum.m 2011-11-13 18:37:05 UTC (rev 9082) @@ -0,0 +1,101 @@ +## 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 {Function File} {@var{retval} =} hamacher_sum (@var{x}) +## @deftypefnx {Function File} {@var{retval} =} hamacher_sum (@var{x}, @var{y}) +## +## Return the Hamacher sum of the input. +## The Hamacher sum of two real scalars x and y is: +## (x + y - 2 * x * y) / (1 - x * y) +## +## For one vector argument, apply the Hamacher sum to all of the elements +## of the vector. (The Hamacher sum is associative.) For one +## two-dimensional matrix argument, return a vector of the Hamacher sum +## of each column. +## +## For two vectors or matrices of identical dimensions, or for one scalar and +## one vector or matrix argument, return the pair-wise Hamacher sum. +## +## @seealso{algebraic_product, algebraic_sum, bounded_difference, bounded_sum, drastic_product, drastic_sum, einstein_product, einstein_sum, hamacher_product} +## @end deftypefn + +## Author: L. Markowsky +## Keywords: fuzzy-logic-toolkit fuzzy hamacher_sum +## Directory: fuzzy-logic-toolkit/inst/ +## Filename: hamacher_sum.m +## Last-Modified: 12 Nov 2011 + +function retval = hamacher_sum (x, y = 0) + if (nargin == 0 || nargin > 2 || + !is_real_matrix (x) || !is_real_matrix (y)) + argument_error + + elseif (nargin == 1) + if (isvector (x)) + retval = vector_arg (x); + elseif (ndims (x) == 2) + retval = matrix_arg (x); + else + argument_error; + endif + + elseif (nargin == 2) + if (isequal (size (x), size (y))) + retval = arrayfun (@scalar_args, x, y); + elseif (isscalar (x) && ismatrix (y)) + x = x * ones (size (y)); + retval = arrayfun (@scalar_args, x, y); + elseif (ismatrix (x) && isscalar (y)) + y = y * ones (size (x)); + retval = arrayfun (@scalar_args, x, y); + else + argument_error; + endif + endif +endfunction + +function retval = scalar_args (x, y) + retval = (x + y - 2 * x * y) / (1 - x * y); +endfunction + +function retval = vector_arg (real_vector) + x = 0; + fo... [truncated message content] |