changeset 8896:a44da9fb6660 octave-forge

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
author lmarkov
date Sun, 13 Nov 2011 18:37:05 +0000
parents e71a955612cb
children 05f2b03460c5
files main/fuzzy-logic-toolkit/inst/addmf.m main/fuzzy-logic-toolkit/inst/addrule.m main/fuzzy-logic-toolkit/inst/addvar.m main/fuzzy-logic-toolkit/inst/algebraic_product.m main/fuzzy-logic-toolkit/inst/algebraic_sum.m main/fuzzy-logic-toolkit/inst/bounded_difference.m main/fuzzy-logic-toolkit/inst/bounded_sum.m main/fuzzy-logic-toolkit/inst/cubic_approx_demo.m main/fuzzy-logic-toolkit/inst/cubic_approximator.fis main/fuzzy-logic-toolkit/inst/drastic_product.m main/fuzzy-logic-toolkit/inst/drastic_sum.m main/fuzzy-logic-toolkit/inst/dsigmf.m main/fuzzy-logic-toolkit/inst/einstein_product.m main/fuzzy-logic-toolkit/inst/einstein_sum.m main/fuzzy-logic-toolkit/inst/evalfis.m main/fuzzy-logic-toolkit/inst/evalmf.m main/fuzzy-logic-toolkit/inst/gauss2mf.m main/fuzzy-logic-toolkit/inst/gaussmf.m main/fuzzy-logic-toolkit/inst/gbellmf.m main/fuzzy-logic-toolkit/inst/gensurf.m main/fuzzy-logic-toolkit/inst/getfis.m main/fuzzy-logic-toolkit/inst/hamacher_product.m main/fuzzy-logic-toolkit/inst/hamacher_sum.m main/fuzzy-logic-toolkit/inst/heart_demo_1.m main/fuzzy-logic-toolkit/inst/heart_demo_2.m main/fuzzy-logic-toolkit/inst/heart_disease_demo_1.m main/fuzzy-logic-toolkit/inst/heart_disease_demo_2.m main/fuzzy-logic-toolkit/inst/investment_portfolio.fis main/fuzzy-logic-toolkit/inst/investment_portfolio_demo.m main/fuzzy-logic-toolkit/inst/linear_tip_demo.m main/fuzzy-logic-toolkit/inst/mamdani_tip_demo.m main/fuzzy-logic-toolkit/inst/newfis.m main/fuzzy-logic-toolkit/inst/pimf.m main/fuzzy-logic-toolkit/inst/plotmf.m main/fuzzy-logic-toolkit/inst/psigmf.m main/fuzzy-logic-toolkit/inst/readfis.m main/fuzzy-logic-toolkit/inst/showfis.m main/fuzzy-logic-toolkit/inst/showrule.m main/fuzzy-logic-toolkit/inst/sigmf.m main/fuzzy-logic-toolkit/inst/smf.m main/fuzzy-logic-toolkit/inst/sugeno_tip_calculator.fis main/fuzzy-logic-toolkit/inst/sugeno_tip_demo.m main/fuzzy-logic-toolkit/inst/trapmf.m main/fuzzy-logic-toolkit/inst/trimf.m main/fuzzy-logic-toolkit/inst/writefis.m main/fuzzy-logic-toolkit/inst/zmf.m
diffstat 46 files changed, 1868 insertions(+), 497 deletions(-) [+]
line wrap: on
line diff
--- a/main/fuzzy-logic-toolkit/inst/addmf.m	Sun Nov 13 18:30:38 2011 +0000
+++ b/main/fuzzy-logic-toolkit/inst/addmf.m	Sun Nov 13 18:37:05 2011 +0000
@@ -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)
 
--- a/main/fuzzy-logic-toolkit/inst/addrule.m	Sun Nov 13 18:30:38 2011 +0000
+++ b/main/fuzzy-logic-toolkit/inst/addrule.m	Sun Nov 13 18:37:05 2011 +0000
@@ -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) 
 
--- a/main/fuzzy-logic-toolkit/inst/addvar.m	Sun Nov 13 18:30:38 2011 +0000
+++ b/main/fuzzy-logic-toolkit/inst/addvar.m	Sun Nov 13 18:37:05 2011 +0000
@@ -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)
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main/fuzzy-logic-toolkit/inst/algebraic_product.m	Sun Nov 13 18:37:05 2011 +0000
@@ -0,0 +1,56 @@
+## Copyright (C) 2011 L. Markowsky <lmarkov@users.sourceforge.net>
+##
+## 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
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main/fuzzy-logic-toolkit/inst/algebraic_sum.m	Sun Nov 13 18:37:05 2011 +0000
@@ -0,0 +1,71 @@
+## Copyright (C) 2011 L. Markowsky <lmarkov@users.sourceforge.net>
+##
+## 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
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main/fuzzy-logic-toolkit/inst/bounded_difference.m	Sun Nov 13 18:37:05 2011 +0000
@@ -0,0 +1,72 @@
+## Copyright (C) 2011 L. Markowsky <lmarkov@users.sourceforge.net>
+##
+## 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
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main/fuzzy-logic-toolkit/inst/bounded_sum.m	Sun Nov 13 18:37:05 2011 +0000
@@ -0,0 +1,71 @@
+## Copyright (C) 2011 L. Markowsky <lmarkov@users.sourceforge.net>
+##
+## 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
+
--- a/main/fuzzy-logic-toolkit/inst/cubic_approx_demo.m	Sun Nov 13 18:30:38 2011 +0000
+++ b/main/fuzzy-logic-toolkit/inst/cubic_approx_demo.m	Sun Nov 13 18:37:05 2011 +0000
@@ -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);
--- a/main/fuzzy-logic-toolkit/inst/cubic_approximator.fis	Sun Nov 13 18:30:38 2011 +0000
+++ b/main/fuzzy-logic-toolkit/inst/cubic_approximator.fis	Sun Nov 13 18:37:05 2011 +0000
@@ -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]
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main/fuzzy-logic-toolkit/inst/drastic_product.m	Sun Nov 13 18:37:05 2011 +0000
@@ -0,0 +1,107 @@
+## Copyright (C) 2011 L. Markowsky <lmarkov@users.sourceforge.net>
+##
+## 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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main/fuzzy-logic-toolkit/inst/drastic_sum.m	Sun Nov 13 18:37:05 2011 +0000
@@ -0,0 +1,107 @@
+## Copyright (C) 2011 L. Markowsky <lmarkov@users.sourceforge.net>
+##
+## 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
--- a/main/fuzzy-logic-toolkit/inst/dsigmf.m	Sun Nov 13 18:30:38 2011 +0000
+++ b/main/fuzzy-logic-toolkit/inst/dsigmf.m	Sun Nov 13 18:37:05 2011 +0000
@@ -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)
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main/fuzzy-logic-toolkit/inst/einstein_product.m	Sun Nov 13 18:37:05 2011 +0000
@@ -0,0 +1,97 @@
+## Copyright (C) 2011 L. Markowsky <lmarkov@users.sourceforge.net>
+##
+## 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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main/fuzzy-logic-toolkit/inst/einstein_sum.m	Sun Nov 13 18:37:05 2011 +0000
@@ -0,0 +1,96 @@
+## Copyright (C) 2011 L. Markowsky <lmarkov@users.sourceforge.net>
+##
+## 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
--- a/main/fuzzy-logic-toolkit/inst/evalfis.m	Sun Nov 13 18:30:38 2011 +0000
+++ b/main/fuzzy-logic-toolkit/inst/evalfis.m	Sun Nov 13 18:37:05 2011 +0000
@@ -90,6 +90,44 @@
 ## @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,14 +210,16 @@
 ## @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
@@ -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.
--- a/main/fuzzy-logic-toolkit/inst/evalmf.m	Sun Nov 13 18:30:38 2011 +0000
+++ b/main/fuzzy-logic-toolkit/inst/evalmf.m	Sun Nov 13 18:37:05 2011 +0000
@@ -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
 
--- a/main/fuzzy-logic-toolkit/inst/gauss2mf.m	Sun Nov 13 18:30:38 2011 +0000
+++ b/main/fuzzy-logic-toolkit/inst/gauss2mf.m	Sun Nov 13 18:37:05 2011 +0000
@@ -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)
 
--- a/main/fuzzy-logic-toolkit/inst/gaussmf.m	Sun Nov 13 18:30:38 2011 +0000
+++ b/main/fuzzy-logic-toolkit/inst/gaussmf.m	Sun Nov 13 18:37:05 2011 +0000
@@ -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)
 
--- a/main/fuzzy-logic-toolkit/inst/gbellmf.m	Sun Nov 13 18:30:38 2011 +0000
+++ b/main/fuzzy-logic-toolkit/inst/gbellmf.m	Sun Nov 13 18:37:05 2011 +0000
@@ -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)
 
--- a/main/fuzzy-logic-toolkit/inst/gensurf.m	Sun Nov 13 18:30:38 2011 +0000
+++ b/main/fuzzy-logic-toolkit/inst/gensurf.m	Sun Nov 13 18:37:05 2011 +0000
@@ -57,9 +57,11 @@
 ## @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
@@ -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.
--- a/main/fuzzy-logic-toolkit/inst/getfis.m	Sun Nov 13 18:30:38 2011 +0000
+++ b/main/fuzzy-logic-toolkit/inst/getfis.m	Sun Nov 13 18:37:05 2011 +0000
@@ -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);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main/fuzzy-logic-toolkit/inst/hamacher_product.m	Sun Nov 13 18:37:05 2011 +0000
@@ -0,0 +1,101 @@
+## Copyright (C) 2011 L. Markowsky <lmarkov@users.sourceforge.net>
+##
+## 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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main/fuzzy-logic-toolkit/inst/hamacher_sum.m	Sun Nov 13 18:37:05 2011 +0000
@@ -0,0 +1,101 @@
+## Copyright (C) 2011 L. Markowsky <lmarkov@users.sourceforge.net>
+##
+## 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;
+  for i = 1 : length (real_vector)
+    y = real_vector(i);
+    if (x == 1 && y == 1)
+      x = 1;
+    else
+      x = (x + y - 2 * x * y) / (1 - 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_sum' for more information.\n");
+  error ("invalid arguments to function hamacher_sum\n");
+endfunction
--- a/main/fuzzy-logic-toolkit/inst/heart_demo_1.m	Sun Nov 13 18:30:38 2011 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,105 +0,0 @@
-## Copyright (C) 2011 L. Markowsky <lmarkov@users.sourceforge.net>
-##
-## 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{cubic_approx_demo, heart_demo_2, linear_tip_demo, mamdani_tip_demo, sugeno_tip_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: 30 Aug 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);
-
--- a/main/fuzzy-logic-toolkit/inst/heart_demo_2.m	Sun Nov 13 18:30:38 2011 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,66 +0,0 @@
-## Copyright (C) 2011 L. Markowsky <lmarkov@users.sourceforge.net>
-##
-## 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: 28 Aug 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)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main/fuzzy-logic-toolkit/inst/heart_disease_demo_1.m	Sun Nov 13 18:37:05 2011 +0000
@@ -0,0 +1,92 @@
+## Copyright (C) 2011 L. Markowsky <lmarkov@users.sourceforge.net>
+##
+## 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_disease_demo_1
+##
+## Demonstrate the use of newfis, addvar, addmf, addrule, and evalfis
+## to build and evaluate an FIS. Also demonstrate the use of the algebraic
+## product and sum as the T-norm/S-norm pair, and demonstrate the use of
+## hedges in the FIS rules.
+##
+## The demo:
+## @itemize @minus
+## @item
+## builds an FIS
+## @item
+## plots the input membership functions
+## @item
+## plots the constant output functions
+## @item
+## displays the FIS rules in verbose format in the Octave window
+## @item
+## plots the FIS output as a function of the inputs
+## @end itemize
+##
+## @seealso{cubic_approx_demo, heart_disease_demo_2, investment_portfolio_demo, linear_tip_demo, mamdani_tip_demo, sugeno_tip_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_disease_demo_1.m
+## Last-Modified: 12 Nov 2011
+
+## Create new FIS.
+a = newfis ('Heart-Disease-Risk', 'sugeno', ...
+            'algebraic_product', 'algebraic_sum', ...
+            '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 130]);
+a = addmf (a, 'input', 1, 'Moderate', 'trapmf', [90 130 160 200]);
+a = addmf (a, 'input', 1, 'High', 'trapmf', [160 200 300 301]);
+
+a = addvar (a, 'input', 'HDL-Level', [0 100]);
+a = addmf (a, 'input', 2, 'Low', 'trapmf', [-1 0 35 45]);
+a = addmf (a, 'input', 2, 'Moderate', 'trapmf', [35 45 55 65]);
+a = addmf (a, 'input', 2, 'High', 'trapmf', [55 65 100 101]);
+
+## Add one output and its membership functions.
+a = addvar (a, 'output', 'Heart-Disease-Risk', [-2 12]);
+a = addmf (a, 'output', 1, 'Negligible', 'constant', 0);
+a = addmf (a, 'output', 1, 'Low', 'constant', 2.5);
+a = addmf (a, 'output', 1, 'Medium', 'constant', 5);
+a = addmf (a, 'output', 1, 'High', 'constant', 7.5);
+a = addmf (a, 'output', 1, 'Extreme', 'constant', 10);
+
+## Plot the input and output membership functions.
+plotmf (a, 'input', 1);
+plotmf (a, 'input', 2);
+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 4 1 1; 2 2 3 1 1; 2 3 2 1 1; ...
+                 3 1 5 1 1; 3 2 4 1 1; 3 3 3 1 1; ...
+                 1.3 3.3 2 1 2; ...
+                 3.05 1.05 4 1 2; ...
+                 -3.2 -1.2 3 1 1]);
+puts ("\nOutput of showrule(a):\n\n");
+showrule (a);
+
+## Plot the output as a function of the two inputs.
+gensurf (a);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main/fuzzy-logic-toolkit/inst/heart_disease_demo_2.m	Sun Nov 13 18:37:05 2011 +0000
@@ -0,0 +1,68 @@
+## Copyright (C) 2011 L. Markowsky <lmarkov@users.sourceforge.net>
+##
+## 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_disease_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 the FIS structure from a file
+## @item
+## plots the input membership functions
+## @item
+## plots the (constant) output functions
+## @item
+## plots the FIS output as a function of the inputs
+## @item
+## evaluates the Sugeno-type FIS for four inputs
+## @end itemize
+##
+## @seealso{cubic_approx_demo, heart_disease_demo_1, investment_portfolio_demo, 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_disease_demo_2.m
+## Last-Modified: 12 Nov 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)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main/fuzzy-logic-toolkit/inst/investment_portfolio.fis	Sun Nov 13 18:37:05 2011 +0000
@@ -0,0 +1,40 @@
+[System]
+Name='Investment-Portfolio'
+Type='mamdani'
+Version=2.0
+NumInputs=2
+NumOutputs=1
+NumRules=4
+AndMethod='einstein_product'
+OrMethod='einstein_sum'
+ImpMethod='einstein_product'
+AggMethod='einstein_sum'
+DefuzzMethod='centroid'
+
+[Input1]
+Name='Age'
+Range=[20 100]
+NumMFs=2
+MF1='Young':'zmf',[30 90]
+MF2='Old':'smf',[30 90]
+
+[Input2]
+Name='Risk-Tolerance'
+Range=[0 10]
+NumMFs=2
+MF1='Low':'zmf',[2 8]
+MF2='High':'smf',[2 8]
+
+[Output1]
+Name='Percentage-In-Stocks'
+Range=[0 100]
+NumMFs=3
+MF1='About-Fifteen':'gaussmf',[10 15]
+MF2='About-Fifty':'gaussmf',[10 50]
+MF3='About-Eighty-Five':'gaussmf',[10 85]
+
+[Rules]
+1 2, 3 (1) : 2
+2 1, 1 (1) : 2
+-2.3 -1.3, 2 (0.5) : 1
+-1.3 -2.3, 2 (0.5) : 1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main/fuzzy-logic-toolkit/inst/investment_portfolio_demo.m	Sun Nov 13 18:37:05 2011 +0000
@@ -0,0 +1,100 @@
+## Copyright (C) 2011 L. Markowsky <lmarkov@users.sourceforge.net>
+##
+## 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} {} investment_portfolio_demo
+## Demonstrate the use of the Octave Fuzzy Logic Toolkit to read and evaluate
+## a Mamdani-type FIS stored in a file. Also demonstrate the use of hedges and
+## weights in the FIS rules, the use of the Einstein product and sum as the
+## T-norm/S-norm pair, and the non-standard use of the Einstein sum as the
+## aggregation method.
+##
+## The demo:
+## @itemize @minus
+## @item
+## reads the FIS structure from a file
+## @item
+## plots the input and output membership functions
+## @item
+## plots the FIS output as a function of the inputs
+## @item
+## plots the output of the 4 individual rules for (Age, Risk-Tolerance) = (40, 7)
+## @item
+## plots the aggregated fuzzy output and the crisp output for
+## (Age, Risk-Tolerance) = (40, 7)
+## @item
+## shows the rules in verbose format in the Octave window
+## @end itemize
+##
+## @seealso{cubic_approx_demo, heart_disease_demo_1, heart_disease_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:      investment_portfolio_demo.m
+## Last-Modified: 12 Nov 2011
+
+## Read the FIS structure from a file.
+fis=readfis ('investment_portfolio');
+
+## Plot the input and output membership functions.
+plotmf (fis, 'input', 1);
+plotmf (fis, 'input', 2);
+plotmf (fis, 'output', 1);
+
+## Plot the Percentage-In-Stocks a function of Age and Risk-Tolerance.
+gensurf (fis, [1 2], 1);
+
+## Calculate the Percentage-In-Stocks using (Age, Risk-Tolerance) = (40, 7).
+[output, rule_input, rule_output, fuzzy_output] = evalfis ([40 7], fis, 1001);
+
+## Plot the output (Percentage-In-Stocks) 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 (Age, Risk Tolerance) = (40, 7)');
+
+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 ('Percentage in Stocks', 'FontWeight', 'bold');
+grid;
+hold;
+
+## Plot the first aggregated fuzzy output and the crisp output (Percentage-In-Stocks)
+## on one set of axes.
+figure('NumberTitle', 'off', 'Name', 'Aggregation and Defuzzification for (Age, Risk Tolerace) = (40, 7)');
+plot (x_axis, fuzzy_output(:, 1), "b;Aggregated Fuzzy Output;", 'LineWidth', 2);
+hold on;
+crisp_output = evalmf(x_axis, output(1), 'constant');
+y_label = ["r;Crisp Output = " num2str(output(1)) "%;"];
+plot (x_axis, crisp_output, y_label, 'LineWidth', 2);
+ylim ([-0.1, 1.1]);
+xlabel ('Percentage in Stocks', 'FontWeight', 'bold');
+grid;
+hold;
+
+## Show the rules in English.
+puts ("\nInvestment Portfolio Calculator Rules:\n\n");
+showrule (fis);
--- a/main/fuzzy-logic-toolkit/inst/linear_tip_demo.m	Sun Nov 13 18:30:38 2011 +0000
+++ b/main/fuzzy-logic-toolkit/inst/linear_tip_demo.m	Sun Nov 13 18:37:05 2011 +0000
@@ -25,16 +25,16 @@
 ## The demo:
 ## @itemize @minus
 ## @item
-## reads an FIS structure from a file
+## reads the FIS structure from a file
 ## @item
 ## plots the input membership functions
 ## @item
-## plots the output as a function of the inputs
+## plots the FIS 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}
+## @seealso{cubic_approx_demo, heart_disease_demo_1, heart_disease_demo_2, investment_portfolio_demo, mamdani_tip_demo, sugeno_tip_demo}
 ## @end deftypefn
 
 ## Author:        L. Markowsky
@@ -43,7 +43,7 @@
 ##                Dr. Bruce Segee (University of Maine Dept. of ECE).
 ## Directory:     fuzzy-logic-toolkit/inst
 ## Filename:      linear_tip_demo.m
-## Last-Modified: 27 Aug 2011
+## Last-Modified: 12 Nov 2011
 
 ## Read the FIS structure from a file.
 fis = readfis ('linear_tip_calculator.fis');
--- a/main/fuzzy-logic-toolkit/inst/mamdani_tip_demo.m	Sun Nov 13 18:30:38 2011 +0000
+++ b/main/fuzzy-logic-toolkit/inst/mamdani_tip_demo.m	Sun Nov 13 18:37:05 2011 +0000
@@ -24,18 +24,21 @@
 ## The demo:
 ## @itemize @minus
 ## @item
-## evaluates a Mamdani-type FIS for a given input
+## reads the FIS structure from a file
 ## @item
-## plots the output membership functions
+## plots the input and output membership functions
+## @item
+## plots each of the two FIS outputs as a function of the inputs
 ## @item
-## plots the output as a function of two inputs
+## plots the output of the 4 individual rules for (Food-Quality, Service) = (4, 6)
 ## @item
-## plots the output of individual rules
+## plots the aggregated fuzzy output and the crisp output for
+## (Food-Quality, Service) = (4, 6)
 ## @item
-## plots the aggregated fuzzy output and the crisp output
+## displays the FIS rules in symbolic format in the Octave window
 ## @end itemize
 ##
-## @seealso{cubic_approx_demo, heart_demo_1, heart_demo_2, linear_tip_demo, sugeno_tip_demo}
+## @seealso{cubic_approx_demo, heart_disease_demo_1, heart_disease_demo_2, investment_portfolio_demo, linear_tip_demo, sugeno_tip_demo}
 ## @end deftypefn
 
 ## Author:        L. Markowsky
@@ -44,7 +47,7 @@
 ##                Dr. Bruce Segee (University of Maine Dept. of ECE).
 ## Directory:     fuzzy-logic-toolkit/inst
 ## Filename:      mamdani_tip_demo.m
-## Last-Modified: 30 Aug 2011
+## Last-Modified: 12 Nov 2011
 
 ## Read the FIS structure from a file.
 fis=readfis ('mamdani_tip_calculator');
--- a/main/fuzzy-logic-toolkit/inst/newfis.m	Sun Nov 13 18:30:38 2011 +0000
+++ b/main/fuzzy-logic-toolkit/inst/newfis.m	Sun Nov 13 18:37:05 2011 +0000
@@ -53,11 +53,12 @@
 ## Keywords:      fuzzy-logic-toolkit fuzzy fuzzy-inference-system fis
 ## Directory:     fuzzy-logic-toolkit/inst/
 ## Filename:      newfis.m
-## Last-Modified: 26 Aug 2011
+## Last-Modified: 31 Oct 2011
 
-function fis = newfis (fis_name, fis_type='mamdani', and_method='min', ...
-                       or_method='max', imp_method='min', agg_method='max', ...
-                       defuzz_method='centroid', fis_version=1.0)
+function fis = newfis (fis_name, fis_type = 'mamdani', and_method = 'min', ...
+                       or_method = 'max', imp_method = 'min', ...
+                       agg_method = 'max', defuzz_method = 'centroid', ...
+                       fis_version = 1.0)
 
   ## If the caller did not supply the between 1 and 8 argument values, or if
   ## any of the argument values were not strings, print an error message and
--- a/main/fuzzy-logic-toolkit/inst/pimf.m	Sun Nov 13 18:30:38 2011 +0000
+++ b/main/fuzzy-logic-toolkit/inst/pimf.m	Sun Nov 13 18:37:05 2011 +0000
@@ -44,8 +44,7 @@
 ## which always returns values in the range [0, 1].
 ##
 ## @noindent
-## To run the demonstration code below, type @t{demo('pimf')} at the Octave
-## prompt.
+## To run the demonstration code, type @t{demo('pimf')} at the Octave prompt.
 ##
 ## @seealso{dsigmf, gauss2mf, gaussmf, gbellmf, psigmf, sigmf, smf, trapmf, trimf, zmf}
 ## @end deftypefn
@@ -54,7 +53,7 @@
 ## Keywords:      fuzzy-logic-toolkit fuzzy membership-function pi-shaped pi
 ## Directory:     fuzzy-logic-toolkit/inst/
 ## Filename:      pimf.m
-## Last-Modified: 7 Jun 2011
+## Last-Modified: 28 Oct 2011
 
 function y = pimf (x, params)
 
--- a/main/fuzzy-logic-toolkit/inst/plotmf.m	Sun Nov 13 18:30:38 2011 +0000
+++ b/main/fuzzy-logic-toolkit/inst/plotmf.m	Sun Nov 13 18:37:05 2011 +0000
@@ -18,10 +18,28 @@
 
 ## -*- texinfo -*-
 ## @deftypefn {Function File} {} plotmf (@var{fis}, @var{in_or_out}, @var{var_index})
+## @deftypefnx {Function File} {} plotmf (@var{fis}, @var{in_or_out}, @var{var_index}, @var{y_lower_limit})
+## @deftypefnx {Function File} {} plotmf (@var{fis}, @var{in_or_out}, @var{var_index}, @var{y_lower_limit}, @var{y_upper_limit})
 ##
-## Plot all of the the membership functions for the specified FIS input or
-## output variable on a single set of axes. The types of the arguments are
-## expected to be:
+## Plot the membership functions defined for the specified FIS input or output
+## variable on a single set of axes. Fuzzy output membership functions are
+## represented by the [0, 1]-valued fuzzy functions, and constant output
+## membership functions are represented by unit-valued singleton spikes.
+## Linear output membership functions, however, are represented by
+## two-dimensional lines y = ax + c, regardless of how many dimensions the
+## linear function is defined to have. In effect, all of the other dimensions
+## of the linear function are set to 0.
+##
+## If both constant and linear membership functions are used for a single FIS
+## output, then two sets of axes are used: one for the constant membership
+## functions, and another for the linear membership functions. To plot both
+## constant and linear membership functions together, or to plot constant
+## membership functions as horizontal lines instead of unit-valued spikes,
+## represent the constant membership functions using 'linear' functions, with
+## 0 for all except the last parameter, and with the desired constant value as
+## the last parameter.
+##
+## The types of the arguments are expected to be:
 ## @itemize @bullet
 ## @item
 ## @var{fis} - an FIS structure
@@ -29,6 +47,10 @@
 ## @var{in_or_out} - either 'input' or 'output' (case-insensitive)
 ## @item
 ## @var{var_index} - an FIS input or output variable index
+## @item
+## @var{y_lower_limit} - a real scalar (default value = -0.1)
+## @item
+## @var{y_upper_limit} - a real scalar (default value = 1.1)
 ## @end itemize
 ##
 ## Six examples that use plotmf are:
@@ -36,9 +58,11 @@
 ## @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
@@ -54,16 +78,17 @@
 ## Keywords:      fuzzy-logic-toolkit fuzzy membership-function plot
 ## Directory:     fuzzy-logic-toolkit/inst/
 ## Filename:      plotmf.m
-## Last-Modified: 16 Jul 2011
+## Last-Modified: 11 Nov 2011
 
-function plotmf (fis, in_or_out, var_index)
+function plotmf (fis, in_or_out, var_index, ...
+                 y_lower_limit = -0.1, y_upper_limit = 1.1)
 
   ## If the caller did not supply 3 argument values with the correct types,
   ## print an error message and halt.
 
-  if (nargin != 3)
+  if ((nargin < 3) || (nargin > 5))
     puts ("Type 'help plotmf' for more information.\n");
-    error ("plotmf requires 3 arguments\n");
+    error ("plotmf requires 3 - 5 arguments\n");
   elseif (!is_fis (fis))
     puts ("Type 'help plotmf' for more information.\n");
     error ("plotmf's first argument must be an FIS structure\n");
@@ -74,6 +99,9 @@
   elseif (!is_var_index (fis, in_or_out, var_index))
     puts ("Type 'help plotmf' for more information.\n");
     error ("plotmf's third argument must be a variable index\n");
+  elseif (!(is_real (y_lower_limit) && is_real (y_upper_limit)))
+    puts ("Type 'help plotmf' for more information.\n");
+    error ("plotmf's fourth and fifth arguments must be real scalars\n");
   endif
 
   ## Select specified variable and construct the window title.
@@ -90,27 +118,65 @@
   ## Cycle through the five colors: red, blue, green, magenta, cyan.
   ## Display the membership function names in a legend.
 
+  colors = ["r" "b" "g" "m" "c"];
   x = linspace (var.range(1), var.range(2), 1001); 
   num_mfs = columns (var.mf);
-  colors = ["r" "b" "g" "m" "c"];
-  figure ('NumberTitle', 'off', 'Name', window_title);
 
+  ## Define vectors to keep track of linear and non-linear mfs.
+
+  linear_mfs = zeros (1, num_mfs);
   for i = 1 : num_mfs
     if (strcmp ('linear', var.mf(i).type))
-      error ("plotmf does not handle linear membership functions\n");
+      linear_mfs(i) = 1;
     endif
-    y = evalmf_private (x, var.mf(i).params, var.mf(i).type);
-    y_label = [colors(mod(i-1,5)+1) ";" var.mf(i).name ";"];
-    plot (x, y, y_label, 'LineWidth', 2);
-    hold on;
   endfor
+  fuzzy_and_constant_mfs = 1 - linear_mfs;
+
+  ## Plot the fuzzy or constant membership functions together on a set of axes.
+
+  if (sum (fuzzy_and_constant_mfs))
+    figure ('NumberTitle', 'off', 'Name', window_title);
+
+    ## Plot the mfs.
+    for i = 1 : num_mfs
+      if (fuzzy_and_constant_mfs(i))
+        y = evalmf_private (x, var.mf(i).params, var.mf(i).type);
+        y_label = [colors(mod(i-1,5)+1) ";" var.mf(i).name ";"];
+        plot (x, y, y_label, 'LineWidth', 2);
+        hold on;
+      endif
+    endfor
 
-  ## Adjust the y-axis, label both axes, and display a dotted grid.
+    ## Adjust the y-axis, label both axes, and display a dotted grid.
+    ylim ([y_lower_limit y_upper_limit]);
+    xlabel (var.name, 'FontWeight', 'bold');
+    ylabel ('Degree of Membership', 'FontWeight', 'bold');
+    grid;
+    hold;
+  endif
+
+  ## Plot the linear membership functions together on a separate set of axes.
+
+  if (sum (linear_mfs))
+    figure ('NumberTitle', 'off', 'Name', window_title);
 
-  ylim ([-0.1, 1.1]);
-  xlabel (var.name, 'FontWeight', 'bold');
-  ylabel ('Degree of Membership', 'FontWeight', 'bold');
-  grid;
-  hold;
+    ## Plot the mfs.
+    for i = 1 : num_mfs
+      if (linear_mfs(i))
+        y = evalmf_private (x, var.mf(i).params, var.mf(i).type);
+        y_label = [colors(mod(i-1,5)+1) ";" var.mf(i).name ";"];
+        plot (x, y, y_label, 'LineWidth', 2);
+        hold on;
+      endif
+    endfor
+
+    ## Adjust the y-axis, label both axes, and display a dotted grid.
+    ylim ([y_lower_limit y_upper_limit]);
+    xlabel ('X', 'FontWeight', 'bold');
+    ylabel (var.name, 'FontWeight', 'bold');
+    grid;
+    hold;
+  endif
+
 
 endfunction
--- a/main/fuzzy-logic-toolkit/inst/psigmf.m	Sun Nov 13 18:30:38 2011 +0000
+++ b/main/fuzzy-logic-toolkit/inst/psigmf.m	Sun Nov 13 18:37:05 2011 +0000
@@ -58,8 +58,7 @@
 ## (Here, the symbol ~ means "approximately equal".)
 ##
 ## @noindent
-## To run the demonstration code below, type @t{demo('psigmf')} at the Octave
-## prompt.
+## To run the demonstration code, type @t{demo('psigmf')} at the Octave prompt.
 ##
 ## @seealso{dsigmf, gauss2mf, gaussmf, gbellmf, pimf, sigmf, smf, trapmf, trimf, zmf}
 ## @end deftypefn
@@ -68,7 +67,7 @@
 ## Keywords:      fuzzy-logic-toolkit fuzzy membership-function sigmoidal
 ## Directory:     fuzzy-logic-toolkit/inst/
 ## Filename:      psigmf.m
-## Last-Modified: 7 Jun 2011
+## Last-Modified: 28 Oct 2011
 
 function y = psigmf (x, params)
 
--- a/main/fuzzy-logic-toolkit/inst/readfis.m	Sun Nov 13 18:30:38 2011 +0000
+++ b/main/fuzzy-logic-toolkit/inst/readfis.m	Sun Nov 13 18:37:05 2011 +0000
@@ -36,19 +36,19 @@
 ## sugeno_tip_calculator.fis
 ## @end itemize
 ##
-## Six examples that use readfis:
+## Six example scripts that use readfis:
 ## @itemize @bullet
 ## @item
 ## cubic_approx_demo.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
 ## @item
-## showrule_demo.m
-## @item
 ## sugeno_tip_demo.m
 ## @end itemize
 ##
@@ -59,9 +59,9 @@
 ## Keywords:      fuzzy-logic-toolkit fuzzy fuzzy-inference-system fis
 ## Directory:     fuzzy-logic-toolkit/inst/
 ## Filename:      readfis.m
-## Last-Modified: 28 Aug 2011
+## Last-Modified: 11 Nov 2011
 
-function fis = readfis (filename='')
+function fis = readfis (filename = '')
 
   ## If readfis was not called with 0 or 1 arguments, or if the argument is
   ## not a string, print an error message and halt.
@@ -455,9 +455,9 @@
   ##--------------------------------------------------------------------------
   ## Read antecedent.
   ##--------------------------------------------------------------------------
-  format_str = "%d";
-  for j = 2 : num_inputs
-    format_str = [format_str " %d"];
+  format_str = "";
+  for j = 1 : num_inputs
+    format_str = [format_str " %f"];
   endfor
   [antecedent, count] = sscanf (line_vec{1}, format_str, [1, num_inputs]);
   if (length (antecedent) != num_inputs)
@@ -469,7 +469,7 @@
   ##--------------------------------------------------------------------------
   format_str = "";
   for j = 1 : num_outputs
-    format_str = [format_str " %d"];
+    format_str = [format_str " %f"];
   endfor
   [consequent, count] = sscanf (line_vec{2}, format_str, [1, num_outputs]);
   if (length (consequent) != num_outputs)
--- a/main/fuzzy-logic-toolkit/inst/showfis.m	Sun Nov 13 18:30:38 2011 +0000
+++ b/main/fuzzy-logic-toolkit/inst/showfis.m	Sun Nov 13 18:37:05 2011 +0000
@@ -20,16 +20,16 @@
 ## @deftypefn {Function File} {} showfis (@var{fis})
 ##
 ## Print all of the property (field) values of the FIS structure and its
-## substructures. For an example, see heart_demo_1.m.
+## substructures.
 ##
-## @seealso{getfis, heart_demo_1, showrule}
+## @seealso{getfis, showrule}
 ## @end deftypefn
 
 ## Author:        L. Markowsky
 ## Keywords:      fuzzy-logic-toolkit fuzzy fuzzy-inference-system fis
 ## Directory:     fuzzy-logic-toolkit/inst/
 ## Filename:      showfis.m
-## Last-Modified: 16 Jul 2011
+## Last-Modified: 11 Nov 2011
 
 function showfis (fis)
 
--- a/main/fuzzy-logic-toolkit/inst/showrule.m	Sun Nov 13 18:30:38 2011 +0000
+++ b/main/fuzzy-logic-toolkit/inst/showrule.m	Sun Nov 13 18:37:05 2011 +0000
@@ -20,12 +20,24 @@
 ## @deftypefn {Function File} {} showrule (@var{fis})
 ## @deftypefnx {Function File} {} showrule (@var{fis}, @var{index_list})
 ## @deftypefnx {Function File} {} showrule (@var{fis}, @var{index_list}, @var{format})
-## @deftypefnx {Function File} {} showrule (@var{fis}, @var{index_list}, @var{format}, @var{language})
+## @deftypefnx {Function File} {} showrule (@var{fis}, @var{index_list}, @var{'verbose'}, @var{language})
+## @deftypefnx {Function File} {} showrule (@var{fis}, @var{index_list}, @var{'verbose'}, @var{'custom'}, @var{"and" "or" "If" "then" "is" "isn't" "somewhat" "very" "extremely" "very very"})
+##
 ##
 ## Show the rules for an FIS structure in verbose, symbolic, or indexed format.
+## Built in languages for the 'verbose' format are: English,
+## Chinese (or Mandarin, Pinyin), Russian (or Pycckii, Russkij), French (or Francais),
+## Spanish (or Espanol), and German (or Deutsch). The names of the languages are
+## case-insensitive, Chinese is written in Pinyin, and Russian is transliterated.
+##
+## To use a custom language, enter 'verbose' and 'custom' for the third and
+## fourth parameters, respectively, and a cell array of ten strings (to specify
+## the custom language) corresponding to the English @{"and" "or" "If" "then"
+## "is" "isn't" "somewhat" "very" "extremely" "very very"@} for the fifth
+## parameter.
 ##
 ## @noindent
-## To run the demonstration code below, type @t{demo('showrule')} at the
+## To run the demonstration code, type @t{demo('showrule')} at the
 ## Octave prompt.
 ##
 ## @seealso{addrule, getfis, showfis}
@@ -35,18 +47,21 @@
 ## Keywords:      fuzzy-logic-toolkit fuzzy rule
 ## Directory:     fuzzy-logic-toolkit/inst/
 ## Filename:      showrule.m
-## Last-Modified: 31 Aug 2011
+## Last-Modified: 13 Nov 2011
 
-function showrule (fis, index_list=[], format='verbose', language='english')
+function showrule (fis, index_list = [], format = 'verbose', ...
+                   language = 'english', ...
+                   verbose_strings = {"and" "or" "If" "then" "is" "isn't" ...
+                                      "somewhat" "very" "extremely" "very very"})
 
   ##--------------------------------------------------------------------------
-  ## If the caller did not supply between 1 and 4 arguments with the correct
+  ## If the caller did not supply between 1 and 5 arguments with the correct
   ## types, print an error message and halt.
   ##--------------------------------------------------------------------------
 
-  if (!(nargin >= 1 && nargin <= 4))
+  if (!(nargin >= 1 && nargin <= 5))
     puts ("Type 'help showrule' for more information.\n");
-    error ("showrule requires between 1 and 4 arguments\n");
+    error ("showrule requires between 1 and 5 arguments\n");
   elseif (!is_fis (fis))
     puts ("Type 'help showrule' for more information.\n");
     error ("showrule's first argument must be an FIS structure\n");
@@ -56,9 +71,15 @@
   elseif ((nargin >= 3) && !is_format (format))
     puts ("Type 'help showrule' for more information.\n");
     error ("showrule's third argument must specify the format\n");
-  elseif ((nargin == 4) && !is_language (language))
+  elseif ((nargin == 4) && isequal (tolower (language), "custom"))
+    puts ("Type 'help showrule' for more information.\n");
+    error ("please specify custom verbose strings in the fifth argument\n");
+  elseif ((nargin == 4) && !is_builtin_language (language))
     puts ("Type 'help showrule' for more information.\n");
-    error ("showrule's fourth argument must specify the language\n");
+    error ("showrule's fourth argument must specify a built-in language\n");
+  elseif ((nargin == 5) && !isequal (tolower (language), "custom"))
+    puts ("Type 'help showrule' for more information.\n");
+    error ("use 'custom' for the 4th argument to specify custom strings\n");
   endif
 
   ##--------------------------------------------------------------------------
@@ -71,176 +92,343 @@
   endif
 
   ##--------------------------------------------------------------------------
-  ## Save some numbers locally.
+  ## Show the rules in indexed, symbolic, or verbose format.
   ##--------------------------------------------------------------------------
 
+  switch (tolower (format))
+    case 'indexed'
+      showrule_indexed_format (fis, index_list);
+    case 'symbolic'
+      showrule_symbolic_format (fis, index_list);
+    case 'verbose'
+      showrule_verbose_format (fis, index_list, language, verbose_strings);
+  endswitch
+
+endfunction
+
+##------------------------------------------------------------------------------
+## Function: get_verbose_hedge
+## Purpose:  For no hedge, return the empty string.
+##           For the built-in hedges, return the verbose string in the language
+##           used in the cell array verbose_strings (the second parameter).
+##           For custom hedges, return the power (rounded to two digits) to
+##           which the membership function matching value will be raised.
+##------------------------------------------------------------------------------
+
+function hedge = get_verbose_hedge (mf_index_and_hedge, verbose_strings)
+
+  mf_index_and_hedge = abs (mf_index_and_hedge);
+  mf_index = fix (mf_index_and_hedge);
+  hedge_num = round (100 * (mf_index_and_hedge - mf_index));
+
+  switch (hedge_num)
+    case 0                         ## .00 <=> no hedge <=> mu(x)
+      hedge = "";
+    case 5                         ## .05 <=> somewhat x <=> mu(x)^0.5
+      hedge = verbose_strings{7};
+    case 20                        ## .20 <=> very x <=> mu(x)^2
+      hedge = verbose_strings{8};
+    case 30                        ## .30 <=> extremely x <=> mu(x)^3
+      hedge = verbose_strings{9};
+    case 40                        ## .40 <=> very very x <=> mu(x)^4
+      hedge = verbose_strings{10};
+    otherwise                      ## .dd <=> <custom hedge> x <=> mu(x)^(dd/10)
+      hedge = hedge_num / 10;      ## For custom hedge, return the power dd/10.
+  endswitch
+
+endfunction
+
+##------------------------------------------------------------------------------
+## Function: get_is_or_isnt
+## Purpose:  Return the verbose string for "is" or "isn't" for the given 
+##           membership function value. If the membership function value is 0,
+##           return the empty string.
+##------------------------------------------------------------------------------
+
+function is_or_isnt = get_is_or_isnt (mem_fcn_value, verbose_strings)
+
+  if (mem_fcn_value > 0)
+    is_or_isnt = verbose_strings{5};
+  elseif (mem_fcn_value < 0)
+    is_or_isnt = verbose_strings{6};
+  else
+    is_or_isnt = "";
+  endif
+
+endfunction
+
+##------------------------------------------------------------------------------
+## Function: get_mf_name
+## Purpose:  Return the specified membership function name.
+##------------------------------------------------------------------------------
+
+function mf_name = get_mf_name (mem_fcn_value, fis_input_or_output)
+
+  mf_name = fis_input_or_output.mf(abs(fix(mem_fcn_value))).name;
+
+endfunction
+
+##------------------------------------------------------------------------------
+## Function: get_verbose_strings
+## Purpose:  Return a cell array of ten strings corresponding to:
+##              {"and" "or" "If" "then" "is" "isn't" ...
+##               "somewhat" "very" "extremely" "very very"}
+##           for the (built-in) language specified by the argument.
+##           Custom verbose strings are specified by an argument to
+##           showrule -- they are not handled by this function.
+##------------------------------------------------------------------------------
+
+function str = get_verbose_strings (language)
+
+  switch (language)
+    case 'english'
+      str = {"and" "or" "If" "then" "is" "isn't" ...
+             "somewhat" "very" "extremely" "very very"};
+    case {'chinese' 'mandarin' 'pinyin'}
+      str = {"he" "huo" "Ruguo" "name" "shi" "bu shi" ...
+             "youdian" "hen" "feichang" "feichang feichang"};
+    case {'russian' 'russkij' 'pycckii'}
+      str = {"i" "ili" "ecli" "togda" "" "ne" ...
+             "nemnogo" "ochen" "prevoshodnoye" "ochen ochen"};
+    case {'spanish' 'espanol'}
+      str = {"y" "o" "Si" "entonces" "es" "no es" ...
+             "un poco" "muy" "extremadamente" "muy muy"};
+    case {'francais' 'french'}
+      str = {"et" "ou" "Si" "alors" "est" "n'est pas" ...
+             "un peu" "tres" "extremement" "tres tres"};
+    case {'deutsch' 'german'}
+      str = {"und" "oder" "Wenn" "dann" "ist" "ist nicht" ...
+             "ein wenig" "sehr" "auBerst" "sehr sehr"};
+  endswitch
+
+endfunction
+
+##------------------------------------------------------------------------------
+## Function: showrule_indexed_format
+## Purpose:  Show the rules in indexed format.
+##------------------------------------------------------------------------------
+
+function showrule_indexed_format (fis, index_list)
+
   num_inputs = columns (fis.input);
   num_outputs = columns (fis.output);
 
-  ##--------------------------------------------------------------------------
-  ## Show the rules in indexed format.
-  ##--------------------------------------------------------------------------
-
-  if (strcmpi (format, 'indexed'))
-
-    for i = 1 : length (index_list)
-      current_ant = fis.rule(index_list(i)).antecedent;
-      current_con = fis.rule(index_list(i)).consequent;
-      current_wt = fis.rule(index_list(i)).weight;
-      current_connect = fis.rule(index_list(i)).connection;
-
-      ##------------------------------------------------------------------
-      ## Print membership functions for the inputs.
-      ##------------------------------------------------------------------
-      if (num_inputs >= 1)
-        printf ("%d", current_ant(1));
-      endif
-      for j = 2 : num_inputs
-        printf (" %d", current_ant(j));
-      endfor
-      printf (", ");
+  for i = 1 : length (index_list)
+    current_ant = fis.rule(index_list(i)).antecedent;
+    current_con = fis.rule(index_list(i)).consequent;
+    current_wt = fis.rule(index_list(i)).weight;
+    current_connect = fis.rule(index_list(i)).connection;
 
-      ##------------------------------------------------------------------
-      ## Print membership functions for the outputs.
-      ##------------------------------------------------------------------
-      if (num_outputs >= 1)
-        printf ("%d", current_con(1));
+    ##------------------------------------------------------------------
+    ## Print membership functions for the inputs.
+    ##------------------------------------------------------------------
+    for j = 1 : num_inputs
+      if (is_int (current_ant(j)))
+        printf ("%d", current_ant(j));
+      else
+        printf ("%.2f", current_ant(j));
       endif
-      for j = 2 : num_outputs
-        printf (" %d", current_con(j));
-      endfor
-
-      ##------------------------------------------------------------------
-      ## Print the weight in parens.
-      ##------------------------------------------------------------------
-      if (is_int (current_wt))
-        printf (" (%d) : ", current_wt);
-      else
-        printf (" (%.4f) : ", current_wt);
+      if (j == num_inputs)
+        puts (",");
       endif
-
-      ##------------------------------------------------------------------
-      ## Print the connection and a newline.
-      ##------------------------------------------------------------------
-      printf ("%d\n", current_connect);
+      puts (" ");
     endfor
 
-  ##--------------------------------------------------------------------------
-  ## Show the rules in symbolic or verbose format.
-  ##--------------------------------------------------------------------------
-
-  else
-
-    ##----------------------------------------------------------------------
-    ## Create a cell array of the strings for 'and', 'or', 'is', 'is not',
-    ## 'if' and 'then' in the three possible languages.
-    ##----------------------------------------------------------------------
-
-    if (strcmp (format, 'symbolic'))
-      str = {"&"  "|"  ""  "=>"   "=="  "~="  "="  "~="};
-    else
-      switch (tolower (language))
-        case 'english'
-          str = {"and" "or" "If" "then" "is" "is not" "is" "is not"};
-        case 'francais'
-          str = {"et" "ou" "Si" "alors" "est" "n'est pas" "est" ...
-                 "n'est pas"};
-        case 'deutsch'
-          str = {"und" "oder" "Wenn" "dann" "ist" "ist nicht" ...
-                 "ist" "ist nicht"};
-      endswitch
-    endif
-
-    ##----------------------------------------------------------------------
-    ## For each index in the index_list, print the index number, the rule,
-    ## and the weight.
-    ##----------------------------------------------------------------------
-
-    if_str = str{3};
-    then_str = str{4};
-
-    for i = 1 : length (index_list)
-
-      connect_str = str{fis.rule(index_list(i)).connection};
-      current_ant = fis.rule(index_list(i)).antecedent;
-      current_con = fis.rule(index_list(i)).consequent;
-      current_wt = fis.rule(index_list(i)).weight;
-
-      ##------------------------------------------------------------------
-      ## Handle the first input separately by printing:
-      ##     "<rule num>. If (<var name> <is or isn't> <mem func name>) "
-      ## in the specified language.
-      ##------------------------------------------------------------------
-
-      if (current_ant(1) > 0)
-        is_or_isnt = str{5};
+    ##------------------------------------------------------------------
+    ## Print membership functions for the outputs.
+    ##------------------------------------------------------------------
+    for j = 1 : num_outputs
+      if (is_int (current_con(j)))
+        printf ("%d", current_con(j));
       else
-        is_or_isnt = str{6};
+        printf ("%.2f", current_con(j));
       endif
-      mf_str = fis.input(1).mf(abs(current_ant(1))).name;
-
-      printf ("%d. %s (%s %s %s) ", index_list(i), if_str, ...
-              fis.input(1).name, is_or_isnt, mf_str);
-
-      ##------------------------------------------------------------------
-      ## For each of the remaining inputs, print:
-      ##     "<connection> (<var name> <is or isn't> <mem func name>) "
-      ## in the specified language.
-      ##------------------------------------------------------------------
-
-      for j = 2 : num_inputs
-        if (current_ant(j) > 0)
-          is_or_isnt = str{5};
-        else
-          is_or_isnt = str{6};
-        endif
-        mf_str = fis.input(j).mf(abs(current_ant(j))).name;
-
-        printf ("%s (%s %s %s) ", connect_str, fis.input(j).name, ...
-                is_or_isnt, mf_str);
-      endfor
-
-      ##------------------------------------------------------------------
-      ## After all inputs have been printed, print:
-      ##     "then "
-      ## in the specified language.
-      ##------------------------------------------------------------------
-
-      printf ("%s ", then_str);
-
-      ##------------------------------------------------------------------
-      ## For each of the outputs, print:
-      ##     " (<var name> <is or isn't> <mem func name>)"
-      ## in the specified language.
-      ##------------------------------------------------------------------
-
-      for j = 1 : num_outputs
-        if (current_con(j) > 0)
-          is_or_isnt = str{7};
-        else
-          is_or_isnt = str{8};
-        endif
-        mf_str = fis.output(j).mf(abs(current_con(j))).name;
-
-        printf ("(%s %s %s)", fis.output(j).name, is_or_isnt, mf_str);
-      endfor
-
-      ##------------------------------------------------------------------
-      ## Finally, print the weight in parens and a newline:
-      ##     " (<weight>)"
-      ##------------------------------------------------------------------
-
-      if is_int (current_wt)
-        printf (" (%d)\n", current_wt);
-      else
-        printf (" (%.4f)\n", current_wt);
+      if (j < num_outputs)
+        puts (" ");
       endif
     endfor
 
+    ##------------------------------------------------------------------
+    ## Print the weight in parens.
+    ##------------------------------------------------------------------
+    if (is_int (current_wt))
+      printf (" (%d) : ", current_wt);
+    else
+      printf (" (%.4f) : ", current_wt);
+    endif
+
+    ##------------------------------------------------------------------
+    ## Print the connection and a newline.
+    ##------------------------------------------------------------------
+    printf ("%d\n", current_connect);
+  endfor
+
+endfunction
+
+##------------------------------------------------------------------------------
+## Function: showrule_symbolic_format
+## Purpose:  Show the rules in symbolic format.
+##------------------------------------------------------------------------------
+
+function showrule_symbolic_format (fis, index_list)
+
+  verbose_strings = {"&&"  "||"  ""  "=>"  "=="  "!="  0.5  2.0  3.0  4.0};
+  showrule_verbose_format (fis, index_list, "custom", verbose_strings, true);
+
+endfunction
+
+##------------------------------------------------------------------------------
+## Function: showrule_verbose_format
+## Purpose:  Show the rules in verbose format.
+##------------------------------------------------------------------------------
+
+function showrule_verbose_format (fis, index_list, language, ...
+                                  verbose_strings, suppress_comma = false)
+
+  num_inputs = columns (fis.input);
+  num_outputs = columns (fis.output);
+
+  ##----------------------------------------------------------------------
+  ## Get verbose strings in the (built-in) language specified.
+  ## Note that the strings for custom languages are supplied by the user.
+  ##----------------------------------------------------------------------
+
+  language = tolower (language);
+  if (isequal ("custom", language))
+    str = verbose_strings;
+  else
+    str = get_verbose_strings (language);
   endif
 
+  and_str = str{1};
+  if_str = str{3};
+  then_str = str{4};
+
+  ##----------------------------------------------------------------------
+  ## For each index in the index_list, print the index number, the rule,
+  ## and the weight.
+  ##----------------------------------------------------------------------
+
+  for i = 1 : length (index_list)
+
+    connect_str = str{fis.rule(index_list(i)).connection};
+    current_ant = fis.rule(index_list(i)).antecedent;
+    current_con = fis.rule(index_list(i)).consequent;
+    current_wt = fis.rule(index_list(i)).weight;
+
+    ##------------------------------------------------------------------
+    ## For j = 1, print:
+    ##     "<rule num>. If (<var name> <is or isn't> [<hedge>] <mem func name>) "
+    ## and for 2 <= j <= num_inputs, print:
+    ##     "<connection> (<var name> <is or isn't> [<hedge>] <mem func name>) "
+    ## in the specified language. Custom hedges are printed in the form:
+    ##     "<connection> (<var name> <is or isn't> <mem func name>^<hedge>) "
+    ##------------------------------------------------------------------
+
+    first_input_printed = true;
+    for j = 1 : num_inputs
+
+      if (j == 1)
+        printf ("%d.", index_list(i));
+      endif
+
+      input_name = fis.input(j).name;
+      is_or_isnt = get_is_or_isnt (current_ant(j), str);
+
+      if (!isempty (is_or_isnt))
+        hedge = get_verbose_hedge (current_ant(j), str);
+        mf_name = get_mf_name (current_ant(j), fis.input(j));
+
+        if (first_input_printed)
+          first_input_printed = false;
+          printf (" %s", if_str);
+        else
+          printf (" %s", connect_str);
+        endif
+
+        if (isempty (hedge))
+          printf (" (%s %s %s)", input_name, is_or_isnt, mf_name);
+        elseif (ischar (hedge))
+          printf (" (%s %s %s %s)", input_name, is_or_isnt, hedge, mf_name);
+        else
+          printf (" (%s %s %s^%3.1f)", input_name, is_or_isnt, mf_name, hedge);
+        endif
+      endif
+
+    endfor
+
+    ##------------------------------------------------------------------
+    ## Print the consequent in the form:
+    ##     ", then (output-name is [hedge] mem-fcn-name) and
+    ##             (output-name is [hedge] mem-fcn-name) and 
+    ##             ...
+    ##             (output-name is [hedge] mem-fcn-name)"
+    ##
+    ## Only the outputs for which the membership function index is
+    ## non-zero are printed. Negative membership function indices indicate
+    ## "isn't" instead of "is", and the fractional part of the membership
+    ## function index indicates a hedge, which is also printed.
+    ##
+    ## For non-numeric and empty hedges, print each of the outputs
+    ## using the form:
+    ##     "<and> (<var name> <is or isn't> [<hedge>] <mem func name>)"
+    ## For custom and numeric hedges, use the form:
+    ##     "<and> (<var name> <is or isn't> <mem func name>^<hedge>)"
+    ##
+    ## The comma may be suppressed (as it is for symbolic output) by
+    ## calling the function with suppress_comma == true.
+    ##------------------------------------------------------------------
+
+    first_output_printed = true;
+    for j = 1 : num_outputs
+
+      output_name = fis.output(j).name;
+      is_or_isnt = get_is_or_isnt (current_con(j), str);
+
+      if (!isempty (is_or_isnt))
+        hedge = get_verbose_hedge (current_con(j), str);
+        mf_name = get_mf_name (current_con(j), fis.output(j));
+
+        if (first_output_printed)
+          first_output_printed = false;
+          if (suppress_comma)
+            printf (" %s", then_str);
+          else
+            printf (", %s", then_str);
+          endif
+        else
+          printf (" %s", and_str);
+        endif
+
+        if (isempty (hedge))
+          printf (" (%s %s %s)", output_name, is_or_isnt, mf_name);
+        elseif (ischar (hedge))
+          printf (" (%s %s %s %s)", output_name, is_or_isnt, hedge, mf_name);
+        else
+          printf (" (%s %s %s^%3.1f)", output_name, is_or_isnt, mf_name, hedge);
+        endif
+      endif
+
+    endfor
+
+    ##------------------------------------------------------------------
+    ## Finally, print the weight in parens and a newline:
+    ##     " (<weight>)"
+    ##------------------------------------------------------------------
+
+    if is_int (current_wt)
+      printf (" (%d)\n", current_wt);
+    else
+      printf (" (%.4f)\n", current_wt);
+    endif
+  endfor
+
 endfunction
 
+##------------------------------------------------------------------------------
+## Embedded Demos
+##------------------------------------------------------------------------------
+
 %!demo
 %! fis = readfis ('sugeno_tip_calculator.fis');
 %! puts ("Output of: showrule(fis)\n");
--- a/main/fuzzy-logic-toolkit/inst/sigmf.m	Sun Nov 13 18:30:38 2011 +0000
+++ b/main/fuzzy-logic-toolkit/inst/sigmf.m	Sun Nov 13 18:37:05 2011 +0000
@@ -51,8 +51,7 @@
 ## @end itemize
 ##
 ## @noindent
-## To run the demonstration code below, type @t{demo('sigmf')} at the Octave
-## prompt.
+## To run the demonstration code, type @t{demo('sigmf')} at the Octave prompt.
 ##
 ## @seealso{dsigmf, gauss2mf, gaussmf, gbellmf, pimf, psigmf, smf, trapmf, trimf, zmf}
 ## @end deftypefn
@@ -61,7 +60,7 @@
 ## Keywords:      fuzzy-logic-toolkit fuzzy membership-function sigmoidal
 ## Directory:     fuzzy-logic-toolkit/inst/
 ## Filename:      sigmf.m
-## Last-Modified: 7 Jun 2011
+## Last-Modified: 28 Oct 2011
 
 function y = sigmf (x, params)
 
--- a/main/fuzzy-logic-toolkit/inst/smf.m	Sun Nov 13 18:30:38 2011 +0000
+++ b/main/fuzzy-logic-toolkit/inst/smf.m	Sun Nov 13 18:37:05 2011 +0000
@@ -39,8 +39,7 @@
 ## which always returns values in the range [0, 1].
 ##
 ## @noindent
-## To run the demonstration code below, type @t{demo('smf')} at the
-## Octave prompt.
+## To run the demonstration code, type @t{demo('smf')} at the Octave prompt.
 ##
 ## @seealso{dsigmf, gauss2mf, gaussmf, gbellmf, pimf, psigmf, sigmf, trapmf, trimf, zmf}
 ## @end deftypefn
@@ -49,7 +48,7 @@
 ## Keywords:      fuzzy-logic-toolkit fuzzy membership-function s-shaped
 ## Directory:     fuzzy-logic-toolkit/inst/
 ## Filename:      smf.m
-## Last-Modified: 7 Jun 2011
+## Last-Modified: 28 Oct 2011
 
 function y = smf (x, params)
 
--- a/main/fuzzy-logic-toolkit/inst/sugeno_tip_calculator.fis	Sun Nov 13 18:30:38 2011 +0000
+++ b/main/fuzzy-logic-toolkit/inst/sugeno_tip_calculator.fis	Sun Nov 13 18:37:05 2011 +0000
@@ -10,11 +10,11 @@
 Version = 1.0
 NumInputs = 2
 NumOutputs = 3
-NumRules = 4
-AndMethod = 'min'
-OrMethod = 'max'
-ImpMethod = 'min'
-AggMethod = 'max'
+NumRules = 10
+AndMethod = 'einstein_product'
+OrMethod = 'einstein_sum'
+ImpMethod = 'prod'
+AggMethod = 'sum'
 DefuzzMethod = 'wtaver'
 
 [Input1]
@@ -38,31 +38,37 @@
 Name = 'Cheap-Tip'
 Range = [5 25]
 NumMFs = 3
-MF1 = 'Seven-and-a-Half-Percent'      : 'constant', [7.5]
-MF2 = 'Twelve-and-a-Half-Percent'     : 'constant', [12.5]
-MF3 = 'Seventeen-and-a-Half-Percent'  : 'constant', [17.5]
+MF1 = 'Low'     : 'constant', [10]
+MF2 = 'Medium'  : 'constant', [15]
+MF3 = 'High'    : 'constant', [20]
 
 [Output2]
 
 Name = 'Average-Tip'
 Range = [5 25]
 NumMFs = 3
-MF1 = 'Ten-Percent'     : 'constant', [10]
-MF2 = 'Fifteen-Percent' : 'constant', [15]
-MF3 = 'Twenty-Percent'  : 'constant', [20]
+MF1 = 'Low'     : 'constant', [10]
+MF2 = 'Medium'  : 'constant', [15]
+MF3 = 'High'    : 'constant', [20]
 
 [Output3]
 
 Name = 'Generous-Tip'
 Range = [5 25]
 NumMFs = 3
-MF1 = 'Twelve-and-a-Half-Percent'     : 'constant', [12.5]
-MF2 = 'Seventeen-and-a-Half-Percent'  : 'constant', [17.5]
-MF3 = 'Twenty-Two-and-a-Half-Percent' : 'constant', [22.5]
+MF1 = 'Low'     : 'constant', [10]
+MF2 = 'Medium'  : 'constant', [15]
+MF3 = 'High'    : 'constant', [20]
 
 [Rules]
 
-1 1, 1 1 1 (1) : 1
-1 2, 2 2 2 (1) : 1
-2 1, 2 2 2 (1) : 1
-2 2, 3 3 3 (1) : 1
+ 1.30   1.30,   1.30   1.20   1.00 (1) : 1
+ 2.00   1.30,   1.00   1.00   2.00 (1) : 1
+ 2.20   1.20,   1.00   2.00   3.00 (1) : 1
+ 1.00   1.00,   1.00   1.00   2.00 (1) : 1
+ 2.00   1.00,   1.00   2.00   3.00 (1) : 1
+ 2.30   1.00,   1.00   2.00   3.20 (1) : 1
+ 1.00   2.00,   1.00   2.00   3.00 (1) : 1
+ 2.00   2.00,   2.00   2.00   3.20 (1) : 1
+ 1.20   2.20,   1.00   2.00   3.00 (1) : 1
+ 2.40   2.40,   3.00   3.20   3.30 (1) : 1
--- a/main/fuzzy-logic-toolkit/inst/sugeno_tip_demo.m	Sun Nov 13 18:30:38 2011 +0000
+++ b/main/fuzzy-logic-toolkit/inst/sugeno_tip_demo.m	Sun Nov 13 18:37:05 2011 +0000
@@ -19,22 +19,28 @@
 ## -*- texinfo -*-
 ## @deftypefn {Script File} {} sugeno_tip_demo
 ##
-## Demonstrate the use of the Octave Fuzzy Logic Toolkit to read and evaluate
-## a Sugeno-type FIS with multiple outputs stored in a text file.
+## Demonstrate the use of the Octave Fuzzy Logic Toolkit to read and
+## evaluate a Sugeno-type FIS with multiple outputs stored in a text
+## file. Also demonstrate the use of hedges in the FIS rules and the
+## Einstein product and sum as the T-norm/S-norm pair.
 ##
 ## The demo:
 ## @itemize @minus
 ## @item
-## reads an FIS structure from a file
+## reads the FIS structure from a file
+## @item
+## plots the input membership functions
 ## @item
-## plots the input and output membership functions
+## plots the (constant) output functions
 ## @item
-## plots the three outputs as a function of the inputs
+## plots each of the three FIS outputs as a function of the inputs
+## @item
+## displays the FIS rules in verbose format in the Octave window
 ## @item
 ## evaluates the Sugeno-type FIS for six inputs
 ## @end itemize
 ##
-## @seealso{cubic_approx_demo, heart_demo_1, heart_demo_2, linear_tip_demo, mamdani_tip_demo}
+## @seealso{cubic_approx_demo, heart_disease_demo_1, heart_disease_demo_2, investment_portfolio_demo, linear_tip_demo, mamdani_tip_demo}
 ## @end deftypefn
 
 ## Author:        L. Markowsky
@@ -43,7 +49,7 @@
 ##                Dr. Bruce Segee (University of Maine Dept. of ECE).
 ## Directory:     fuzzy-logic-toolkit/inst
 ## Filename:      sugeno_tip_demo.m
-## Last-Modified: 29 Aug 2011
+## Last-Modified: 10 Nov 2011
 
 ## Read the FIS structure from a file.
 fis = readfis ('sugeno_tip_calculator.fis');
@@ -61,6 +67,9 @@
 gensurf (fis, [1 2], 2);
 gensurf (fis, [1 2], 3);
 
+## Demonstrate showrule with hedges.
+showrule (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]
--- a/main/fuzzy-logic-toolkit/inst/trapmf.m	Sun Nov 13 18:30:38 2011 +0000
+++ b/main/fuzzy-logic-toolkit/inst/trapmf.m	Sun Nov 13 18:37:05 2011 +0000
@@ -44,8 +44,7 @@
 ## @end example
 ##
 ## @noindent
-## To run the demonstration code below, type @t{demo('trapmf')} at the Octave
-## prompt.
+## To run the demonstration code, type @t{demo('trapmf')} at the Octave prompt.
 ##
 ## @seealso{dsigmf, gauss2mf, gaussmf, gbellmf, pimf, psigmf, sigmf, smf, trimf, zmf}
 ## @end deftypefn
@@ -54,7 +53,7 @@
 ## Keywords:      fuzzy-logic-toolkit fuzzy membership-function trapezoidal
 ## Directory:     fuzzy-logic-toolkit/inst/
 ## Filename:      trapmf.m
-## Last-Modified: 7 Jun 2011
+## Last-Modified: 28 Oct 2011
 
 function y = trapmf (x, params)
 
--- a/main/fuzzy-logic-toolkit/inst/trimf.m	Sun Nov 13 18:30:38 2011 +0000
+++ b/main/fuzzy-logic-toolkit/inst/trimf.m	Sun Nov 13 18:37:05 2011 +0000
@@ -45,8 +45,7 @@
 ## @end example
 ##
 ## @noindent
-## To run the demonstration code below, type @t{demo('trimf')} at the Octave
-## prompt.
+## To run the demonstration code, type @t{demo('trimf')} at the Octave prompt.
 ##
 ## @seealso{dsigmf, gauss2mf, gaussmf, gbellmf, pimf, psigmf, sigmf, smf, trapmf, trimf_demo, zmf}
 ## @end deftypefn
@@ -55,7 +54,7 @@
 ## Keywords:      fuzzy-logic-toolkit fuzzy membership-function triangular
 ## Directory:     fuzzy-logic-toolkit/inst/
 ## Filename:      trimf.m
-## Last-Modified: 7 Jun 2011
+## Last-Modified: 28 Oct 2011
 
 function y = trimf (x, params)
 
--- a/main/fuzzy-logic-toolkit/inst/writefis.m	Sun Nov 13 18:30:38 2011 +0000
+++ b/main/fuzzy-logic-toolkit/inst/writefis.m	Sun Nov 13 18:37:05 2011 +0000
@@ -53,6 +53,10 @@
 ## @end table
 ##
 ## @noindent
+## NOTE:
+## The GUI dialog requires zenity to be installed on the system.
+##
+## @noindent
 ## KNOWN ERROR:
 ## When using the file dialog, if the user clicks "Cancel" instead of
 ## saving the file, an error message is generated.
@@ -64,9 +68,9 @@
 ## Keywords:      fuzzy-logic-toolkit fuzzy fuzzy-inference-system fis
 ## Directory:     fuzzy-logic-toolkit/inst/
 ## Filename:      writefis.m
-## Last-Modified: 27 Aug 2011
+## Last-Modified: 31 Oct 2011
 
-function writefis (fis, filename='filename.fis', dialog='dummy')
+function writefis (fis, filename = 'filename.fis', dialog = 'dummy')
 
   ## If writefis was not called with between 1 and 3 arguments, or if the
   ## argument values were of the wrong type, print an error message and halt.
@@ -242,16 +246,28 @@
 
     ## Print membership functions for the inputs.
     if (num_inputs > 0)
-      fprintf (fid, "%d", next_ant(1));
+      if (is_int (next_ant(1)))
+        fprintf (fid, "%d", next_ant(1));
+      else
+        fprintf (fid, "%.2f", next_ant(1));
+      endif
     endif
     for j = 2 : num_inputs
-      fprintf (fid, " %d", next_ant(j));
+      if (is_int (next_ant(j)))
+        fprintf (fid, " %d", next_ant(j));
+      else
+        fprintf (fid, " %.2f", next_ant(j));
+      endif
     endfor
     fprintf(fid, ", ");
 
     ## Print membership functions for the outputs.
     for j = 1 : num_outputs
-      fprintf (fid, "%d ", next_con(j));
+      if (is_int (next_con(j)))
+        fprintf (fid, "%d ", next_con(j));
+      else
+        fprintf (fid, "%.2f ", next_con(j));
+      endif
     endfor
 
     ## Print the weight in parens.
--- a/main/fuzzy-logic-toolkit/inst/zmf.m	Sun Nov 13 18:30:38 2011 +0000
+++ b/main/fuzzy-logic-toolkit/inst/zmf.m	Sun Nov 13 18:37:05 2011 +0000
@@ -54,8 +54,7 @@
 ## @end itemize
 ##
 ## @noindent
-## To run the demonstration code below, type @t{demo('zmf')} at the Octave
-## prompt.
+## To run the demonstration code, type @t{demo('zmf')} at the Octave prompt.
 ##
 ## @seealso{dsigmf, gauss2mf, gaussmf, gbellmf, pimf, psigmf, sigmf, smf, trapmf, trimf, zmf_demo}
 ## @end deftypefn
@@ -64,7 +63,7 @@
 ## Keywords:      fuzzy-logic-toolkit fuzzy membership-function z-shaped
 ## Directory:     fuzzy-logic-toolkit/inst/
 ## Filename:      zmf.m
-## Last-Modified: 7 Jun 2011
+## Last-Modified: 28 Oct 2011
 
 function y = zmf (x, params)