1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250
|
<!DOCTYPE html>
<html lang="en">
<head>
<title>Octave Fuzzy Logic Toolkit: evalfis</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css" integrity="sha512-1ycn6IcaQQ40/MKBW2W4Rhis/DbILU74C1vSrLJxCq57o941Ym01SwNsOMqvEBFlcgUa6xLiPY/NS5R+E6ztJQ==" crossorigin="anonymous" referrerpolicy="no-referrer">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.0/dist/css/bootstrap.min.css" integrity="sha384-KyZXEAg3QhqLMpG8r+8fhAXLRk2vvoC2f3B09zVXn8CA5QIVfZOJ3BCsw2P0p/We" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.0/dist/js/bootstrap.bundle.min.js" integrity="sha384-U1DAWAznBHeqEIlVSCgzq+c9gqGAJn5c/t99JyeKa9xxaYpSvHU5awsuZVVFIhvj" crossorigin="anonymous"></script>
<script type="text/javascript" async
src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_CHTML">
</script>
<style>
var {
font-style: italics;
font-weight: bold;
}
td {
vertical-align: top;
}
</style>
</head>
<body>
<div class="bg-dark">
<div class="container-xl">
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<div class="container-fluid">
<a class="navbar-brand" href=index.html>
<img src="assets/fuzzy-logic-toolkit.png" alt="fuzzy-logic-toolkit" class="d-inline-block align-top" width="25" height="25">
Octave Fuzzy Logic Toolkit
</a>
<button type="button" class="navbar-toggler" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="index.html#Evaluation">
<i class="fas fa-list-alt"></i>
Evaluation
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="https://gnu-octave.github.io/packages/">
<img src="assets/octave-logo.svg" alt="GNU Octave logo" class="d-inline-block align-top" width="25" height="25">
Octave Packages
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="https://www.octave.org">
<i class="fas fa-home"></i>
GNU Octave website
</a>
</li>
</ul>
</div>
</div>
</nav>
</div>
</div>
<div class="container-xl my-4">
<div class="card rounded">
<div class="card-header card-header-mod">
<div class="row d-flex flex-wrap align-items-center">
<div class="col-sm-3 col-md-5 mb-2 mb-sm-0">
<h3 class="d-inline-block mr-2">
Function Reference: <b><code>evalfis</code></b>
</h3>
</div>
</div>
</div>
<div class="card-body">
<dl>
<dt><u>Function File:</u> <var>output</var> = <b>evalfis</b><i> (<var>user_input</var>, <var>fis</var>)</i></dt>
<dt><u>Function File:</u> <var>output</var> = <b>evalfis</b><i> (<var>user_input</var>, <var>fis</var>, <var>num_points</var>)</i></dt>
<dt><u>Function File:</u> [<var>output</var>, <var>rule_input</var>, <var>rule_output</var>, <var>fuzzy_output</var>] = <b>evalfis</b><i> (<var>user_input</var>, <var>fis</var>)</i></dt>
<dt><u>Function File:</u> [<var>output</var>, <var>rule_input</var>, <var>rule_output</var>, <var>fuzzy_output</var>] = <b>evalfis</b><i> (<var>user_input</var>, <var>fis</var>, <var>num_points</var>)</i></dt>
</dl>
<p> Return the crisp output(s) of an FIS for each row in a matrix of crisp input
values.
Also, for the last row of <var>user_input</var>, return the intermediate results:
</p>
<div class="ms-5">
<table>
<thead><tr><th width="25%">Intermediate Result</th><th width="65%">Value Returned</th></tr></thead>
<tr><td width="25%"><var>rule_input</var></td><td width="65%">a matrix of the degree to which each FIS rule matches each
FIS input variable</td></tr>
<tr><td width="25%"><var>rule_output</var></td><td width="65%">a matrix of the fuzzy output for each (rule, FIS output) pair</td></tr>
<tr><td width="25%"><var>fuzzy_output</var></td><td width="65%">a matrix of the aggregated output for each FIS output variable</td></tr>
</table>
<br>
<p> The optional argument <var>num_points</var> specifies the number of points over
which to evaluate the fuzzy values. The default value of <var>num_points</var> is
101.
</p>
<p> <strong>Argument <var>user_input</var>:</strong>
<var>user_input</var> is a matrix of crisp input values. Each row
represents one set of crisp FIS input values. For an FIS that has N inputs,
an input matrix of z sets of input values will have the form:
</p>
<pre class="verbatim"> [[input_11 input_12 ... input_1N] <-- 1st row is 1st set of inputs
[input_21 input_22 ... input_2N] <-- 2nd row is 2nd set of inputs
[ ... ] ...
[input_z1 input_z2 ... input_zN]] <-- zth row is zth set of inputs
</pre>
<p> <strong>Return value <var>output</var>:</strong>
<var>output</var> is a matrix of crisp output values. Each row represents
the set of crisp FIS output values for the corresponding row of
<var>user_input</var>. For an FIS that has M outputs, an <var>output</var> matrix
corresponding to the preceding input matrix will have the form:
</p>
<pre class="verbatim"> [[output_11 output_12 ... output_1M] <-- 1st row is 1st set of outputs
[output_21 output_22 ... output_2M] <-- 2nd row is 2nd set of outputs
[ ... ] ...
[output_z1 output_z2 ... output_zM]] <-- zth row is zth set of outputs
</pre>
<p> <strong>The intermediate result <var>rule_input</var>:</strong>
The matching degree for each (rule, input value) pair is specified by the
<var>rule_input</var> matrix. For an FIS that has Q rules and N input variables,
the matrix will have the form:
</p><pre class="verbatim"> in_1 in_2 ... in_N
rule_1 [[mu_11 mu_12 ... mu_1N]
rule_2 [mu_21 mu_22 ... mu_2N]
[ ... ]
rule_Q [mu_Q1 mu_Q2 ... mu_QN]]
</pre>
<p> <strong>Evaluation of hedges and "not":</strong>
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.
</p>
<p> 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.
</p>
<p> 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</var> will be computed by applying
the hedge and "not" in two steps. First, the hedge is applied:
</p>
<pre class="verbatim"> (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)
</pre>
<p> After applying the appropriate hedge, "not" is calculated by:
</p>
<pre class="verbatim"> minus sign present <=> not x <=> 1 - mu(x)
minus sign and hedge present <=> not <hedge> x <=> 1 - mu(x)^(dd/10)
</pre>
<p> Hedges and "not" in the consequent are handled similarly.
</p>
<p> <strong>The intermediate result <var>rule_output</var>:</strong>
For either a Mamdani-type FIS (that is, an FIS that does not have constant or
linear output membership functions) or a Sugeno-type FIS (that is, an FIS
that has only constant and linear output membership functions),
<var>rule_output</var> specifies the fuzzy output for each (rule, FIS output) pair.
The format of rule_output depends on the FIS type.
</p>
<p> For a Mamdani-type FIS, <var>rule_output</var> is a <var>num_points</var> x (Q * M)
matrix, where Q is the number of rules and M is the number of FIS output
variables. Each column of this matrix gives the y-values of the fuzzy
output for a single (rule, FIS output) pair.
</p>
<pre class="verbatim"> Q cols Q cols Q cols
--------------- --------------- ---------------
out_1 ... out_1 out_2 ... out_2 ... out_M ... out_M
1 [[ ]
2 [ ]
... [ ]
num_points [ ]]
</pre>
<p> For a Sugeno-type FIS, <var>rule_output</var> is a 2 x (Q * M) matrix.
Each column of this matrix gives the (location, height) pair of the
singleton output for a single (rule, FIS output) pair.
</p>
<pre class="verbatim"> Q cols Q cols Q cols
--------------- --------------- ---------------
out_1 ... out_1 out_2 ... out_2 ... out_M ... out_M
location [[ ]
height [ ]]
</pre>
<p> <strong>The intermediate result <var>fuzzy_output</var>:</strong>
The format of <var>fuzzy_output</var> depends on the FIS type (’mamdani’ or
’sugeno’).
</p>
<p> For either a Mamdani-type FIS or a Sugeno-type FIS, <var>fuzzy_output</var>
specifies the aggregated fuzzy output for each FIS output.
</p>
<p> For a Mamdani-type FIS, the aggregated <var>fuzzy_output</var> is a
<var>num_points</var> x M matrix. Each column of this matrix gives the y-values
of the fuzzy output for a single FIS output, aggregated over all rules.
</p>
<pre class="verbatim"> out_1 out_2 ... out_M
1 [[ ]
2 [ ]
... [ ]
num_points [ ]]
</pre>
<p> For a Sugeno-type FIS, the aggregated output for each FIS output is a 2 x L
matrix, where L is the number of distinct singleton locations in the
<var>rule_output</var> for that FIS output:
</p>
<pre class="verbatim"> singleton_1 singleton_2 ... singleton_L
location [[ ]
height [ ]]
</pre>
<p> Then <var>fuzzy_output</var> is a vector of M structures, each of which has an index and
one of these matrices.
</p>
<p> <strong>Examples:</strong>
Five examples of using evalfis are shown in:
</p><ul>
<li>
heart_disease_demo_2.m
</li><li>
investment_portfolio_demo.m
</li><li>
linear_tip_demo.m
</li><li>
mamdani_tip_demo.m
</li><li>
sugeno_tip_demo.m
</li></ul>
<p> <strong>See also: </strong>
<a href="cubic_approx_demo.html">cubic_approx_demo</a>,
<a href="heart_disease_demo_1.html">heart_disease_demo_1</a>,
<a href="heart_disease_demo_2.html">heart_disease_demo_2</a>,
<a href="investment_portfolio_demo.html">investment_portfolio_demo</a>,
<a href="linear_tip_demo.html">linear_tip_demo</a>,
<a href="mamdani_tip_demo.html">mamdani_tip_demo</a>,
<a href="sugeno_tip_demo.html">sugeno_tip_demo</a>
</p>
</div>
</div>
</div>
</div>
</body>
</html>
|