<figure><img src="image_1.png" /></figure>

HAL
open science

# Optimal Fuzzy Controller Mapped from LQR under Power and Torque Constraints

Ping-Ho Chen, Kuang-Yow Lian

► To cite this version:

Ping-Ho Chen, Kuang-Yow Lian. Optimal Fuzzy Controller Mapped from LQR under Power and Torque Constraints. 12th Engineering Applications of Neural Networks (EANN 2011) and 7th Artificial Intelligence Applications and Innovations (AIAI), Sep 2011, Corfu, Greece. pp.104-109, 10.1007/978-3-642-23960-1_13 . hal-01571465

HAL Id: hal-01571465

https://inria.hal.science/hal-01571465

Submitted on 2 Aug 2017

**HAL** is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entific research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d'enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.

<figure><img src="image_2.png" /></figure>

Distributed under a Creative Commons Attribution 4.0 International License
# Optimal Fuzzy Controller Mapped from LQR under Power and Torque Constraints

Ping-Ho Chen<fnref n="1" />, Kuang-Yow Lian<fnref n="2" />

**Abstract.** Dealing with a LQR controller surface subject to power and torque constraints, is an issue of nonlinear problem that is difficult to implement. This paper employs a fuzzy controller surface to replace the LQR surface subject to power and torque constraints by using class stacking, least square and Sugeno-type fuzzy inference mode. Through this type of transformation, called "Optimal fuzzy controller mapped from LQR", control of the system remains optimal.

**Keywords:** LQR, FLC, Fuzzy, Sugeno, Optimal, Class stacking.

## 1 Linear Quadratic Regulator (LQR)

The development of optimal control for a MIMO system [1][2] is mature nowadays. Approach of linear quadratic regulator (LQR) offers Kalman gain for state feedback to regulate a MIMO system in state-space form. But subject to power and torque limitation of motor drive, implementation of system becomes difficult using LQR approach. This section introduces some basis for LQR approach for further improvement.

### 1.1 LQR Approach

For a MIMO system in state-space form

$$ \dot{X} = AX + Bu \quad (1) $$

where $X \in R^n$ is the state vector. The control $u \in R^m$ includes state-feedback torque in motor application, command for desired state output and disturbance that the system might encounter. Control $u$ is thus expressed by

$$ u = -KX + u_{com} + u_{dist} \quad (2) $$

where $K$: Kalman gain. $u_{dist}$: disturbance torque (colored noise). $u_{com}$: command for desired state output. Eq. (2) is a general form of input in LQG (Linear Quadratic

<footnote n="1">¹Department of EE, Tungnan University, Taipei, Taiwan, phc@mail.tnu.edu.tw</footnote>

<footnote n="2">²Department of EE, National Taipei University of Technology, Taipei, Taiwan, kylan@ntut.edu.tw</footnote>
Gaussian) problems. When $\mathbf{u}_{\text{dist}} = \mathbf{o}$ and $\mathbf{u}_{\text{com}} \neq \mathbf{o}$, the system becomes a tracking problem expressed by

$$ \dot{\mathbf{X}} = (\mathbf{A} - \mathbf{B}\mathbf{K})\mathbf{X} + \mathbf{B}\mathbf{u}_{\text{com}} \quad (3) $$

At steady state it satisfies

$$ \mathbf{O} = (\mathbf{A} - \mathbf{B}\mathbf{K})\mathbf{X} + \mathbf{B}\mathbf{u}_{\text{com}} \quad (4) $$

In case $\mathbf{u}_{\text{com}} = \mathbf{o}$ in Eq. (4), the system becomes a regulator problem further called “linear quadratic regulator (LQR)” , if we select a gain $\mathbf{K}$, called Kalman gain such that $\mathbf{u} = -\mathbf{K}\mathbf{X}$ to minimize the cost $\mathbf{J}$ in quadratic form as

$$ J = \frac{1}{2} \mathbf{X}^{\text{T}}(T)\mathbf{S}(T)\mathbf{X} + \int_{0}^{T} \left[ \frac{1}{2}(\mathbf{X}^{\text{T}}\mathbf{Q}\mathbf{X} + \mathbf{u}^{\text{T}}\mathbf{R}\mathbf{u}) + \mathbf{\lambda}^{\text{T}}(\mathbf{A}\mathbf{X} + \mathbf{B}\mathbf{u} - \dot{\mathbf{X}}) \right] dt \quad (5) $$

where $\mathbf{Q}$: dynamic state weighting, $\mathbf{R}$: control weighting, $\mathbf{S}$: terminal state weighting and $\mathbf{\lambda}$: Lagrange multiplier. After several algebra operations to minimize the cost, we have the following Hamiltonian matrix presenting as the transition matrix in Eq. (6):

$$ \begin{bmatrix} \dot{\mathbf{X}} \\ \dot{\mathbf{\lambda}} \end{bmatrix} = \begin{bmatrix} \mathbf{A} & -\mathbf{B}\mathbf{R}^{\text{T}}\mathbf{B}^{\text{T}} \\ -\mathbf{Q} & -\mathbf{A}^{\text{T}} \end{bmatrix} \begin{bmatrix} \mathbf{X} \\ \mathbf{\lambda} \end{bmatrix} \quad (6) $$

$$ \mathbf{\lambda}(t) = \mathbf{S}(t)\mathbf{X}(t) \quad (7) $$

$$ \mathbf{\lambda}(T) = \mathbf{S}(T)\mathbf{X}(T) \quad (8) $$

$$ \mathbf{U}(t) = -\mathbf{R}^{-1}\mathbf{B}^{\text{T}}\mathbf{\lambda}(t) = -\mathbf{R}^{-1}\mathbf{B}^{\text{T}}\mathbf{S}(t)\mathbf{X}(t) = -\mathbf{K}(t)\mathbf{X}(t) \quad (9) $$

The steady gain is

$$ \mathbf{K} = \lim_{t \to \infty} \mathbf{K}(t) = \mathbf{R}^{-1}\mathbf{B}^{\text{T}}\lim_{t \to \infty} \mathbf{S}(t) = \mathbf{R}^{-1}\mathbf{B}\psi_{21}(\psi_{11})^{-1} \quad (10) $$

where $\psi_{21}$ and $\psi_{11}$ are the first-column block matrix of $\mathbf{\Psi}$ which is the modal form of the Hamiltonian matrix in Eq. (6).

## 1.2 Constraints of LQR Control

While implementing the optimal control $\mathbf{u}$ aforementioned, we always meet difficulty when subject to constraints of torque limit $\mathbf{u}_t$ and power limit $p_t$. The torque constraint, caused by stall current in motor application, is expressed by

$$ \mathbf{u} \le \mathbf{u}_t, \quad \mathbf{u}_t = k_t \dot{\mathbf{i}}_s \quad (11) $$

where $k_t$: current constant of motor. $\dot{\mathbf{i}}_s$: stall current of motor. As usual the control $\mathbf{u}$ is associated with states of position and rate. Mechanical power $p_m$, constrained by maximum power $p_t$ of motor, is represented by
$$p_m = \mathbf{u}^T \dot{\mathbf{\theta}} \le p_l \qquad (12)$$

where $\dot{\mathbf{\theta}}$ is rate-related state vector.

## 2 Class Stacking

From Eq. (2), the LQR control is $\mathbf{u} = -\mathbf{KX} = [u_1 \ u_2 \ \dots \ u_w]^T$ where $\mathbf{K} = [k_{ji}] \in \mathbb{R}^{w \times n}$ and $u_j = -\sum_{i=1}^{n} k_{ji} x_i$ for $j = 1, \dots, w$. Since each component $u_j$ of $\mathbf{u}$ will be solved one by one by the same approach of class stacking, $u_j$ will be replaced by $\mathbf{u} = \sum_{i=1}^{n} k_i x_i$ for illustration without loss of generality. Obviously for $j^{th}$ component $u_j$ of $\mathbf{u}$, $k_i = -k_{ji}$. The form of $\mathbf{u} = \sum_{i=1}^{n} k_i x_i$ is a hyper plane of n-D. All the states $x_i$ for $i = 1, \dots, n$ are sorted out into two classes. One class, having $m$ states, is position-related and piled up by

$$v_1 = \sum_{i=1}^{m} k_i x_i \qquad (13)$$

and the other class, having $n-m$ states, is rate-related and piled up by

$$v_2 = \sum_{i=m+1}^{n} k_i x_i \qquad (14)$$

$$u = v_1 + v_2 \qquad (15)$$

The torque constraint is

$$v_1 + v_2 = u \le u_l \qquad (16)$$

The power constraint $u v_2 \le p_l$ from Eq. (12) can be rewritten by

$$(v_1 + v_2)v_2 \le p_l \qquad (17)$$

Eq. (13)~(15) thus reduce the system from $n$-D into 3-D with variables $v_1$ and $v_2$.

Eq. (16) indicates a plane $v_1 + v_2 = u$ with known LQR control $u$ but upper bounded by $u_l$. Eq. (17) indicates a nonlinear constraint. The process, called “class stacking”, thus make it feasible to plot a hyper plane of $n$-D in terms of 3-D. An example using computer-aided plot is given as follows. A LQR control $u$, with number of total states $n=5$ and number of position-related states $m=3$, is expressed by
$$u = \sum_{i=1}^{5} k_i x_i = v_1 + v_2, \quad v_1 = \sum_{i=1}^{3} k_i x_i, \quad v_2 = \sum_{i=4}^{5} k_i x_i \quad (18)$$

where $|x_i| \le 1$ (normalized) and $k_i = i$ for $i = 1, \dots, 5$. Obviously maximum of $v_1$ is 6 and maximum of $v_2$ is 9, subject to constraints: $v_1 + v_2 \le 12$ (Upper bound) and $(v_1 + v_2)v_2 \le 75$ (Inequality constraint).

By using computer-aided plot [3], Fig. 1(a)-(d) shows a sequence of transformations from LQR surface to cases of constraints are obtained. Fig. 1(a) shows the interception of a LQR surface, a torque-constrained surface and a hyperboloid due to power constraint. Fig. 1(b) shows LQR surface bounded by all constraints.

<figure><img src="image_3.png" /><figcaption>Fig. 1. Computer-aided plot (a) Interception of LQR plane, torque constraint plane and power constraint hyperboloid (b) LQR surface bounded by all constraints.</figcaption></figure>

# 3 Fuzzy Logic Controller (FLC)

Although the approach of class stacking reduces the hyper plane from the LQR controller of n-D into a bounded and constrained plane in 3-D, the 3-D controller surface shown in Fig. 1.(b) is still nonlinear. Therefore we may employ a fuzzy-logic-controller (FLC) to implement this 3-D controller surface shown in Fig. 1.(b).

## 3.1 Fuzzy inference system (FIS)

A fuzzy logic controller (FLC) [4][5][6] is configured by processing a sequence of fuzzification, inference and defuzzification as follows. The fuzzy inference system (FIS) to be selected is Sugeno model [7] given in Fig. 2 with $v_1$ and $v_2$ as input fuzzy variables and the control $u$ as known output variable which is bounded, constrained and expressed by plane s1: $u = v_1 + v_2$, plane s2: $u = 12$ (Upper bound) and hyperboloid: $uv_2 \le 75$ (Inequality constraint).

## 3.2 Fuzzification
Input fuzzy variables are $v_1$ and $v_2$. $v_1$ has five triangle membership functions, equally partitioned and spaced as shown in Fig. 2. Membership functions are defined by linguistic terms, i.e. S, SM, M, MB and B. Output variable is the control $u$ that has five membership functions, i.e. S+, SM+, M+, MB+ and B as shown in Fig. 2.

<figure><img src="image_4.png" /><figcaption>Fig. 2. Fuzzy inference system (FIS) using Sugeno model</figcaption></figure>

### 3.3 Inference

Output variable is the control $u$ that is composed of plane s1 and a hyperboloid. The plane s1 is $u = v_1 + v_2$. The hyperboloid ABCD in Fig. 1(b) is approximately replaced by another plane in Fig. 3.(a), named s2 and obtained by least square with

$$s2: \quad u = \Lambda [v_2 \ v_1 \ 1]^T \qquad (19)$$

$$\Lambda = [-0.8025 \ 0.2566 \ 14.7253] \qquad (20)$$

$\Lambda$ is obtained by

$$\Lambda^T = (Y^T Y)^{-1} (Y^T Z) \qquad (21)$$

with

$$Y = \begin{bmatrix} v_{2A} & v_{IA} & 1 \\ v_{2B} & v_{IB} & 1 \\ v_{2C} & v_{IC} & 1 \\ v_{2D} & v_{ID} & 1 \end{bmatrix}, Z = \begin{bmatrix} u_A \\ u_B \\ u_C \\ u_D \end{bmatrix} \qquad (22)$$

The selected $\Lambda$ is able to minimize error $\|Z - Y\Lambda\|$.

After finishing the definition of linear planes, we are able to develop the inference that includes ten rules. The former half governs the surface s2 and the latter half governs the surface s1. Rules are written as follows.

1. If ($v_1$ is S) and ($v_2$ is B) then ($u$ is s2); 2. If ($v_1$ is SM) and ($v_2$ is MB+) then ($u$ is s2)

3. If ($v_1$ is M) and ($v_2$ is M+) then ($u$ is s2); 4. If ($v_1$ is MB) and ($v_2$ is SM+) then ($u$ is s2)

5. If ($v_1$ is B) and ($v_2$ is S+) then ($u$ is s2); 6. If ($v_1$ is S) and ($v_2$ is not B) then ($u$ is s1)

7. If ($v_1$ is SM) and ($v_2$ is not MB+) then ($u$ is s1); 8. If ($v_1$ is M) and ($v_2$ is not M+) then ($u$ is s1); 9. If ($v_1$ is MB) and ($v_2$ is not SM+) then ($u$ is s1); 10. If ($v_1$ is B) and ($v_2$ is not S+) then ($u$ is s1).
<figure><img src="image_5.png" /><figcaption>(a)</figcaption></figure>

<figure><img src="image_6.png" /><figcaption>(b)</figcaption></figure>

Fig. 3.(a) Hyperboloid is approximately replaced by plane s2 (b) Rule surface after fuzzy defuzzification.

## 3.4. Defuzzification

A rule surface after defuzzification is generated as shown in Fig. 3(b) which is observed to be an approximation of Fig. 3.(a).

## 4 Conclusion

LQR control surface in hyperspace, subject to power and torque constraints, is difficult to implement. This paper employs class stacking to transform LQR surface in hyper space into a surface in 3-D and further applies a Sugeno-type fuzzy logic controller to plot the 3-D nonlinear surface. This approach makes LQR feasible and visible.

## References

1. Frank L. Lewis, : Applied Optimal Control & Estimation. Prentice Hall, 1992.

2. Jeffrey B. Burl, : Linear Optimal Control. Addison-Wesley, 1999.

3. Matlab: toolbox : Fuzzy, 2010 ed.

4. Zadeh, L.A., : The concept of a linguistic variable and its application to approximate reasoning, Parts 1, 2, and 3. Information Sciences, 1975, 8:199-249, 8:301-357, 9:43-80.

5. Mamdani, E. H. and S. Assilian, : An Experiment in Linguistic Synthesis with Fuzzy Logic Controller. Int. J. Man Mach. Studies, 7, No.1, pp1-13, 1975.

6. Mamdani, E.H., : Advances in the linguistic synthesis of fuzzy controllers. International Journal of Man-Machine Studies, Vol. 8, pp. 669-678, 1976.

7. Sugeno, M., : Fuzzy measures and fuzzy integrals: a survey. (M.M. Gupta, G. N. Saridis, and B.R. Gaines, editors), Fuzzy Automata and Decision Processes, pp. 89-102, North-Holland, NY, 1977.