### FLCU – Fuzzy logic controller unit

Function Description
The FLCU block implements a simple fuzzy logic controller with two inputs and one output. Introduction to fuzzy logic problems can be found in [3].

The output is defined by trapezoidal membership functions of linguistic terms of the u and v inputs, impulse membership functions of linguistic terms of the y output and inference rules in the form

If (u is ${U}_{i}$) AND (v is ${V}_{j}$), then (y is ${Y}_{k}$),

where ${U}_{i},i=1,\dots ,\mathtt{\text{nu}}$ are the linguistic terms of the u input; ${V}_{j},j=1,\dots ,\mathtt{\text{nv}}$ are the linguistic terms of the v input and ${Y}_{k},k=1,\dots ,\mathtt{\text{ny}}$ are the linguistic terms of the y output. Trapezoidal (triangular) membership functions of the u and v inputs are defined by four numbers as depicted below.

Not all numbers ${x}_{1},\dots ,{x}_{4}$ are mutually different in triangular functions. The matrices of membership functions of the u and v input are composed of rows $\left[{x}_{1},{x}_{2},{x}_{3},{x}_{4}\right]$. The dimensions of matrices mfu and mfv are ($\mathtt{\text{nu}}×4$) and ($\mathtt{\text{nv}}×4$) respectively.

The impulse 1st order membership functions of the y output are defined by the triplet

${\mathtt{\text{y}}}_{k},\phantom{\rule{1em}{0ex}}{a}_{k},\phantom{\rule{1em}{0ex}}{b}_{k},$

where ${\mathtt{\text{y}}}_{k}$ is the value assigned to the linguistic term ${Y}_{k},k=1,\dots ,\mathtt{\text{ny}}$ in the case of ${a}_{k}={b}_{k}=0$. If ${a}_{k}\ne 0$ and ${b}_{k}\ne 0$, then the term ${Y}_{k}$ is assigned the value of ${\mathtt{\text{y}}}_{k}+{a}_{k}\mathtt{\text{u}}+{b}_{k}\mathtt{\text{v}}$. The output membership function matrix sty has a dimension of ($\mathtt{\text{ny}}×3$) and contains the rows $\left[{\mathtt{\text{y}}}_{k},{a}_{k},{b}_{k}\right],k=1,\dots ,\mathtt{\text{ny}}$.

The set of inference rules is also a matrix whose rows are $\left[{i}_{l},{j}_{l},{k}_{l},{w}_{l}\right],l=1,\dots ,\mathtt{\text{nr}}$, where ${i}_{l},{j}_{l}$ and ${k}_{l}$ defines a particular linguistic term of the $\mathtt{\text{u}}$ and $\mathtt{\text{v}}$ inputs and $\mathtt{\text{y}}$ output respectively. The number ${w}_{l}$ defines the weight of the rule in percents ${w}_{l}\in \left\{0,1,\dots ,100\right\}$. It is possible to suppress or emphasize a particular inference rule if necessary.

Inputs

 umax Upper limit of the u input  $\odot$1.0 Double (F64) umin Lower limit of the u input  $\odot$-1.0 Double (F64) nu Number of membership functions of the input u  $↓$1 $↑$25 $\odot$3 Long (I32) vmax Upper limit of the v input  $\odot$1.0 Double (F64) vmin Lower limit of the v input  $\odot$-1.0 Double (F64) nv Number of membership functions of the input v  $↓$1 $↑$25 $\odot$3 Long (I32) ny Number of membership functions of the output y  $↓$1 $↑$100 $\odot$3 Long (I32) nr Number of inference rules  $↓$1 $↑$25 $\odot$3 Long (I32) mfu Matrix of membership functions of the input u  $\odot$[-1 -1 -1 0; -1 0 0 1; 0 1 1 1] Double (F64) mfv Matrix of membership functions of the input v  $\odot$[-1 -1 -1 0; -1 0 0 1; 0 1 1 1] Double (F64) sty Matrix of membership functions of the output y  $\odot$[-1 0 0; 0 0 0; 1 0 0] Double (F64) rls Matrix of inference rules  $\odot$[1 2 3 100; 1 1 1 100; 1 0 3 100] Byte (U8)