%This is an old version of the derivation of the Fuzzy logic controller.
%It uses the composition rule
%=================================

\subsection{Fuzzy Logic Controller Revisited}
A typical fuzzy logic controller~(FLC) architecture, discussed in this section, is depicted in Figure~\ref{fig:typ_flc}.
\begin{figure}
\vspace{3in}
\hskip1.25in\special{bmp:c:/mybook/typ_flc.bmp x=4in y=3in}
\caption{A diagram of a fuzzy logic controller with inputs $e$ and $\Delta e$.}
\label{fig:typ_flc}
\end{figure}
The controller inputs are the error $e$ and the change-in-error $\Delta e$ or $\dot{e}$. The controller is composed of two basic components: a decision making logic module, also referred to as an inference engine, and a defuzzifier.

The inference engine stores $M$ fuzzy rules of the form
\begin{center}
IF $e$ is $F_1^{l}$ AND $\Delta e$ is $F_2^{l}$, THEN $u$ is $G^{l}$,\quad $l=1,2,\ldots,M$.\\
\end{center}
These rules constitute knowledge base of the inference engine. Each input pair, $(e,\Delta e)$, fires the rules to some degree. An IF-THEN rule such as
\begin{center}
IF $e$ is $F_1^{l}$ AND $\Delta e$ is $F_2^{l}$, THEN $u$ is $G^{l}$,\\
\end{center}
is implemented by a fuzzy implication $R_l$ with the membership function
\[
\mu_{R_l}:U_1 \times U_2 \times V \to \left[ 0,\, 1\right],
\]
where $U_1$, $U_2$, and $V$ are the universes of discourse of the error, the change-in-error, and control action, respectively.

The outputs of the inference engine are fuzzy sets that are converted into crisp values, defuzzified, by a defuzzifier. We represent this operation as
\[
u_0=\mbox{defuzzifier}(u),
\]
where $u_0$ is the crisp control action value and $u$ is a corresponding fuzzy control action. Defuzzification may also involve scaling that converts the ranges of universes of discourse into the ranges of the controller outputs.

We now present an analytical description of fuzzy logic controllers. We first discuss inference engines and defuzzifiers that we will be using. We assume that we have a single-input plant to control, that is, the controller has one output, and the given fuzzy rule base consists of $M$ IF-THEN rules of the form
\begin{center}
IF $e$ is $F_1^{l}$ AND $\Delta e$ is $F_2^{l}$, THEN $u$ is $G^{l}$,
\end{center}
where $l=1,2,\ldots,M$, the ERROR $e$, CHANGE-IN-ERROR $\Delta e$, and CONTROL $u$ are linguistic variables whose values are fuzzy sets $F_1^{l}$, $F_2^{l}$, and $G^{l}$, respectively. There are two inputs to the fuzzy logic controller. Suppose an input signal $\left[\begin{array}{cc}
e & \Delta e
\end{array}\right]^T$ has been applied to the controller. Consider one of the rules  that fired and the corresponding to $e$ and $\Delta e$ fuzzy sets. Assume that the universes of discourse of these two fuzzy sets are $U_1$ and $U_2$, respectively. We form a fuzzy relation $E$ in the product space $U_1 \times U_2$ with a membership function
\[
\mu_{E}(e,\Delta e):U_1 \times U_2 \to \left[ 0,\, 1 \right].
\]
The membership function $\mu_{E}(e, \Delta e)$ can have, for example, the following forms:
\begin{itemize}
\item $\mu_{E}(e, \Delta e)=\mu_{F_1^{l}}(e) \star \mu_{F_2^{l}}(\Delta e)$, or
\item $\mu_{E}(e, \Delta e)=\mu_{F_1^{l}}(e) \dot{+} \mu_{F_2^{l}}(\Delta e)$.
\end{itemize}
We will be using the algebraic product $\mu_{E}(e, \Delta e)=\mu_{F_1^{l}}(e)\mu_{F_2^{l}}(\Delta e)$, however, we could use, for example, the fuzzy intersection, that is, $\mu_{E}(e, \Delta e)=\min\left\{\mu_{F_1^{l}}(e), \mu_{F_2^{l}}(\Delta e)\right\}$. The operation of the fuzzy engine is described by the $\max-\star$ composition rule. Let $V$ be the universe of discourse of the output of the inference engine, and let $G^{l}$, $l=1,2,\dots,M$ be fuzzy sets representing possible values of the linguistic variable CONTROL. Then, the composition rule yields a fuzzy set $B^{l}$ in $V$ whose membership function has the form
\[
\mu_{B^{l}}(u)=\bigvee_{(e, \Delta e)\in U_1 \times U_2}\left\{\mu_{F_1^{l} \times F_2^{l} \to G^{l}}(e, \Delta e, u) \star \mu_{A'}(e, \Delta e) \right\}.
\]
In our discussion we choose for $\star$ the algebraic product. We could also use, for example, the fuzzy intersection as the $\star$ operator.

The defuzzifier transforms a fuzzy output from the inference engine into a crisp point in the control action space. Possible kinds of defuzzification operators are:
\begin{itemize}
\item the center average defuzzifier, defined as
\[
u=\frac{\sum_{l=1}^{M}{u}^{l}\mu_{B^{l}}\left({u}^{l}\right)}{\sum_{l=1}^{M}\mu_{B^{l}}\left({u}^{l}\right)},
\]
where ${u}^{l}$ is the point in $V$ at which $\mu_{G^{l}}(u)$ achieves its maximum. We assume that $\mu_{G^{l}}\left({u}^{l}\right)=1$;
\item the modified center average defuzzifier, defined as
\[
u=\frac{\sum_{l=1}^{M}{u}^{l}\mu_{B^{l}}\left({u}^{l}\right)/\sigma ^{l}}{\sum_{l=1}^{M}\mu_{B^{l}}\left({u}^{l}\right)/\sigma ^{l}},
\] 
where $\sigma^{l}$ is a parameter characterizing the shape of $\mu_{G^{l}}(u)$.
\end{itemize}
We can use, for example, the bell-shaped membership functions of the form
\[
\mu(x)=\exp\left(-\left(\frac{x-m}{\sigma}\right)^2\right),
\]
where $m$ and $\sigma$ are adjustable parameters, or triangular shape membership functions that we employed in Example~\ref{ex:fuzzy_vehi}.
\begin{thm}
The fuzzy logic controller with $e$ and $\Delta e$ as its inputs, the center average defuzzifier, and the algebraic product inference engine can be described analytically as
\[
u(e, \Delta e) =\frac{\sum_{l=1}^{M}{u}^{l}\mu_{F_1^{l}}(e)\mu_{F_2^{l}}(\Delta e) }{\sum_{l=1}^{M}\mu_{F_1^{l}}(e)\mu_{F_2^{l}}(\Delta e)}
\]
\end{thm}
{\bf Proof}\quad The center average defuzzifier is defined as
\begin{equation}
u=\frac{\sum_{l=1}^{M}{u}^{l}\mu_{B^{l}}({u}^{l})}{\sum_{l=1}^{M}\mu_{B^{l}}({u}^{l})},
\label{eq:cenavedef}
\end{equation}
where ${u}^{l}$ is the point in $V$ at which $\mu_{G^{l}}(u)$ achieves its maximum. Recall that we assumed that $\mu_{G^{l}}({u}^{l})=1$. Suppose now that the input to the controller is the crisp pair $\left(e^{'},\Delta e^{'}\right)$. We can view the pair $\left(e^{'}, \Delta e^{'}\right)$ as a singleton fuzzy set denoted $A^{'}$ whose membership function $\mu_{A'}(e,\Delta e)$ is such that
\begin{equation}
\mu_{A'}(e', \Delta e')=1 \quad \mbox{for} \quad e'=e,\quad  \Delta e' =\Delta e,
\label{eq:muaprimo}
\end{equation}
and
\begin{equation}
\mu_{A'}(e', \Delta e')=0 \quad \mbox{for}\quad e' \ne e\quad\mbox{or}\quad  \Delta e' \ne \Delta e.
\label{eq:muprimz}
\end{equation}
The algebraic product inference rule gives
\begin{eqnarray*}
\mu_{B^{l}}({u}^{l}) &=& \bigvee_{(e', \Delta e')\in U_1 \times U_2}\left\{\mu_{F_1^{l} \times F_2^{l} \to G^{l}}(e, \Delta e, {u}^{l}) \mu_{A'}(e', \Delta e') \right\}\\
&=& \bigvee_{(e, \Delta e)\in U_1 \times U_2}\left\{\left(\mu_{F_1^{l}}(e')\mu_{F_2^{l}}(\Delta e')\right)\mu_{G^{l}}({u}^{l})\mu_{A'}(e', \Delta e') \right\}.
\end{eqnarray*}
Taking into account~(\ref{eq:muaprimo}) and~(\ref{eq:muprimz}), we obtain
\[
\mu_{B^{l}}({u}^{l})=\mu_{F_1^{l}}(e)\mu_{F_2^{l}}(\Delta e).
\]
Substituting the above into the expression for the center average defuzzifier~(\ref{eq:cenavedef}) yields the result.\\
\hspace*{5.5in} $\Box$
