Commit 0fad7f11 authored by Kristian Soltesz's avatar Kristian Soltesz
Browse files

Written most of docu text, some polishing left to be done

parent 6922173d
......@@ -2,6 +2,7 @@
\usepackage[left=3cm,right=3cm,top=3cm,bottom=3cm]{geometry}
\usepackage{amsmath}
\usepackage{filecontents}
\usepackage{xspace}
\usepackage{tikz}
\usetikzlibrary{shapes,positioning}
......@@ -48,9 +49,10 @@ isbn={978-3-033-03962-9 (eBook)}
\newcommand{\secref}[1]{Section~\ref{sec:#1}}
\newcommand{\tabref}[1]{Table~\ref{tab:#1}}
\newcommand{\pidIE}{\href{https://gitlab.control.lth.se/kristian/PIDopt/blob/master/pidIE.m}{\tt pidIE.m}}
\newcommand{\pidIAE}{\href{https://gitlab.control.lth.se/kristian/PIDopt/blob/master/pidIAE.m}{\tt pidIiAE.m}}
\newcommand{\pidfIAE}{\href{https://gitlab.control.lth.se/kristian/PIDopt/blob/master/pidfIAE.m}{\tt pidfIAE.m}}
\newcommand{\pidIE}{\href{https://gitlab.control.lth.se/kristian/PIDopt/blob/master/pidIE.m}{\tt pidIE.m}\xspace}
\newcommand{\pidIAE}{\href{https://gitlab.control.lth.se/kristian/PIDopt/blob/master/pidIAE.m}{\tt pidIiAE.m}\xspace}
\newcommand{\pidfIAE}{\href{https://gitlab.control.lth.se/kristian/PIDopt/blob/master/pidfIAE.m}{\tt pidfIAE.m}\xspace}
\newcommand{\PIDopt}{\href{https://gitlab.control.lth.se/kristian/PIDopt}{\tt PIDopt} }
\bibliographystyle{plain}
\usepackage{bibentry}
......@@ -61,16 +63,12 @@ isbn={978-3-033-03962-9 (eBook)}
\begin{document}
\nobibliography*
%\nobibliography*{}
\title{{PIDopt} -- Matlab software for robust optimization-based\\{PID} controller design}
\author{Kristian Soltesz}
\date{\today}
\maketitle
\section{Acknowledgement\label{sec:ack}}
The software consists of three scripts for {PID} design, explained later. The underlying methods for these files are:
The software consists of three scripts for {PID}. The underlying methods for these files are:
\begin{itemize}
\item\pidfIAE\\
\bibentry{pidfIAE}
......@@ -82,18 +80,18 @@ The software consists of three scripts for {PID} design, explained later. The un
\bibentry{pidIE}
\end{itemize}
\noindent The code present in the \href{https://gitlab.control.lth.se/kristian/PIDopt}{\tt PIDopt} package is due to the authors of the above works. Please acknowledge these works through citation if you use the methods in your research.
\noindent The code present in the \PIDopt package is due to the authors of the above works. Please acknowledge these works through citation if you use the methods in your research.
\section{Getting started}
\subsection{Installation}
The software can be downloaded from the git repository \url{git@gitlab.control.lth.se:kristian/PIDopt.git}, accessible online at \url{https://gitlab.control.lth.se/kristian/PIDopt}. See\\\href{https://gitlab.control.lth.se/kristian/PIDopt/blob/master/example.m}{\tt example.m} at the base of the repository for an example illustrating how to run and evaluate the designs.
To execute the software you will need Matlab. In addition, \pidIE relies on CVX for Matlab, which can be downloaded for free from \url{http://www.cvxr.com}.
To run the software you will need Matlab. In addition, \pidIE relies on CVX for Matlab, which can be downloaded for free from \url{http://www.cvxr.com}.
\subsection{Bug reporting}
Feel free to report/correct bugs through the issue system available at the \href{https://gitlab.control.lth.se/kristian/PIDopt}{\tt web page of the repository}. Make sure to read \secref{practical} before reporting a bug.
Feel free to report/correct bugs through the issue system available at \url{https://gitlab.control.lth.se/kristian/PIDopt/issues}. Make sure to read \secref{practical}, and check so that your issue has not already been reported, before opening a new issue.
The remainder of this document is dedicated to briefly describe the design method (\secref{design}), and to provide . If you remain with any questions, please send them to \url{mailto:kristian@control.lth.se}{kristian at control dot lth dot se}.
The remainder of this document is dedicated to briefly describe the design method (\secref{design}), and to provide . If you remain with any questions, please send them to \href{mailto:kristian@control.lth.se}{\tt kristian@control.lth.se}.
\clearpage
\section{Design Methods\label{sec:design}}
\subsection{Design problem}
......@@ -104,7 +102,7 @@ The remainder of this document is dedicated to briefly describe the design metho
\node[sumcircle,right=13mm of K](sum2){};
\node[block,right=10mm of sum2](P){$P$};
\node[sumcircle,right=10mm of P](sum3){};
\node[block,below=9mm of sum2](G3){$-1$};
\node[block,below=9mm of sum2](FB){$-1$};
\node[sumcircle,left=12mm of K](sum){};
\node[coordinate, left=10mm of sum](ref){};
\node[coordinate, right=12mm of sum3](output){};
......@@ -118,24 +116,22 @@ The remainder of this document is dedicated to briefly describe the design metho
\draw[->](noise)--node[yshift=2mm](){$n$}(sum3);
\draw[->](P)--(sum3);
\draw[->](sum3)--node[xshift=0mm](Y){$y$}(output);
\draw[->](Y)|-(G3);
\draw[->](G3)-|(sum);
\draw[->](Y)|-(FB);
\draw[->](FB)-|(sum);
\end{tikzpicture}
\label{fig:cc}
\caption{The considered closed-loop control system with process $P$ and (filtered) PID controller $K$. The reference $r$ is not considered here ($r=0$ can be assumed). The remaining signals are the control error $e$, the control signal $u$, the measurement signal $y$, the load disturbance $l$, and measurement noise $n$.}
\end{figure}
All the design methods consider a closed-loop system as depicted in \figref{cc}. The process model $P$ is a SISO LTI system. The design objective is to minimize the influence of an additive (unit) load disturbance step $l$, entering at the process input at $t=0$, on the control error $e$.
In \pidIE the objective is to minimize the integral error,
All the design methods consider a closed-loop system as depicted in \figref{cc}. The process model $P$ is a SISO LTI system. The design objective is to minimize the influence of an additive (unit) load disturbance step $l$, entering at the process input at $t=0$, on the control error $e$, see \figref{cc}. In \pidIE (see \cite{pidIE} for details) the objective is to minimize the integral error,
\begin{equation}
\text{IE} = \int_0^\infty e(t) dt,
\end{equation}
whereas \pidIAE and \pidfIAE aim to minimize the $\mathcal{L}_1$-norm of $e$, also known as the integrated absolute error,
whereas \pidIAE (see \cite{pidIAE} for details) and \pidfIAE (see \cite{pidfIAE} for details) aim to minimize the $\mathcal{L}_1$-norm of $e$, also known as the integrated absolute error,
\begin{equation}
\text{IAE} = \int_0^\infty |e(t)| dt.
\end{equation}
These constraints are standard within process control, and sound within a much broader application scope.
These objectives are standard within process control, and sound within a much broader application scope. A thorough introduction is provided in \cite{astrom06}.
Robustness of the control loop is enforced by constraining the sensitivity function
\begin{equation}
......@@ -147,67 +143,79 @@ the complementary sensitivity function
T = \dfrac{L}{1+L},
\nonumber
\end{equation}
as well as the noise sensitivity function $KS$. We use $L=KP$ to denote the loop transfer function. Interpretation of The sensitivity function $S$ and its complement $T=1-S$ are thoroughly covered in most introductory control textbooks. The noise sensitivity $KS$ is the transfer function from $y$ to $u$ in \figref{cc}, and determines how much measurement noise is attenuated (or amplified). The methods covered here impose robustness through $\mathcal{H}_\infty$-constraints:
as well as the noise sensitivity function $KS$. We use $L=KP$ to denote the loop transfer function. Interpretation of The sensitivity function $S$ and its complement $T=1-S$ are thoroughly covered in most introductory control textbooks, such as \cite{astrom06}. The noise sensitivity $KS$ is the transfer function from $y$ to $u$ in \figref{cc}, and determines how much measurement noise is attenuated (or amplified). Noise sensitivity is further discussed in \cite{pidfIAE}. The methods covered here impose robustness through $\mathcal{H}_\infty$-constraints:
\begin{align}
\|S\|_\infty &\leq M_s,\nonumber\\
\|T\|_\infty &\leq M_t,\nonumber\\
\|KS\|_\infty &\leq M_{ks}.\nonumber
\end{align}
Smaller values of $M_s$, $M_t$, and $M_{ks}$, correspond to better robustness, but typically correspond to an increase in objective. A reasonable default is $M_s=M_t=1.5$. It is not possible to give a default for $M_{ks}$ as it is unit dependent -- it is affected by the gain of $P$.
The reader is referred to the works listed in \secref{ack} for detailed information on the methods used to solve the constrained optimization problems described above. Related aspects of practical relevance are given in \secref{practical}.
\subsection{Controller and filter structure}
Process and controller representation herein is in continuous time. (Adapting the code to discrete time settings should be straightforward.) The controllers synthesized by \pidIE= and \pidIAE are on the form
Process and controller representation herein is in continuous time. The controllers synthesized by \pidIE and \pidIAE are on the form
\begin{equation}
K(s) = k_p+\dfrac{ki}{s}+k_ds.
\label{eq:pid}
\end{equation}
Their parallel form representation
Their (more common) parallel form representation,
\begin{equation}
??\nonumber
K(s) = K\left(1+\dfrac{1}{T_i s} + T_ds \right),\nonumber
\end{equation}
has parameters ??, and exists if ??. (The code can be modified to include \eqref{} as a constraint if it is crucial that the resulting controllers have a parallel form representation.)
can be obtained through $K=k_p$, $T_i=k_p/k_i$, $T_d=k_d/k_p$. See for example \cite{astrom06} if your controller needs to be on series form.
The controllers synthesized by \pidfIAE are a series connection of a controller on the form \eqref{pid}
and a second-order low-pass filter
The controllers synthesized by \pidfIAE are a series connection of a controller on the form \eqref{eq:pid} and a second-order low-pass filter,
\begin{equation}
F(s) = \dfrac{1}{T^2s^2+2\zeta T s +1}.
\label{eq:filter}
\end{equation}
The filter is implemented with $\zeta=1/\sqrt{2}$. The role of the filter is to ensure high-frequency roll-off. In order to achieve this also with \pidIE and \pidIAE simply design a low-pass filter and include it as a series connected component of $P$ prior to conducting the design.
The filter is implemented with relative damping $\zeta=1/\sqrt{2}$. The role of the filter is to ensure high-frequency roll-off. In order to achieve this also with \pidIE and \pidIAE, simply design a low-pass filter and include it as a series connected component of $P$ prior to conducting the design.
\subsection{Which method to use?}
The robustness constraints are generally not convex in the controller parameters. The optimum (when either IE or IAE is minimized) is still unique for many processes \cite{garpinger}, although it is possible to construct pathological examples, for which this is not true.
Minimizing IE \eqref{eq:ie}, as is done by \pidIE, has the advantage of being equivalent to maximizing $k_i$ of the controller \eqref{eq:pid}. This makes the objective convex (actually linear) in the controller parameters, while also being independent of the process dynamics. The resulting constrained optimization problem makes it possible to apply a very fast convex-concave method \cite{pidIE}. Furthermore, for closed-loop systems with a non-oscillating load step response it holds that IE and IAE are equal. Combinations of poor performance and low IE-values are, however, possible for oscillating responses, as illustrated in \figref{ievsiae}. In practice, this can be avoided by reasonable constraints on sensitivity and complementary sensitivity. For instance, the controllers optimized by \pidIE and \pidIAE, respectively, yield almost equivalent IAE-values for all processes of the extensive test batch reported in \cite{}, when $M_s=M_t=1.5$ is used.
\begin{figure}[b]
\centering
\caption{The figure shows the load step response of two closed-loop control systems. They both have equal IE values, while the IAE of the blue response is only half of that of the red response. IAE is consequently a more reliable performance measure for systems where oscillating load step responses cannot be ruled out.}
\label{fig:ievsiae}
\end{figure}
A disadvantage with \pidIE, is that it does not provide low-pass filtering of the control signal. Hence the high-frequency asymptote associated with the derivative part is infinite. This generally results in poor noise attenuation properties. It is possible to limit the noise sensitivity by constraining $M_{ks}$, but since the optimization is carried out over a frequency grid, there is no guaranteed for frequencies. Also, constraining $M_{ks}$ in \pidIE (as well as \pidIAE) typically results in severe performance degradation (in terms of the optimization objective).
% IE vs IAE optimization
% - convexity
The \pidIAE and \pidfIAE methods rely on gradient-based methods to find a (local optimum) to the constrained optimization design problem. Since most practical applications result in problems with unique optima, the methods are broadly applicable. They both rely on computing the sensitivities of objective and constraints with respect to the controller (and filter) parameters, in order to obtain the Jacobian matrix by the optimization tool. They execute slower than \pidIE, and since the two often result in similar performance, \pidIE is almost always preferred to \pidIAE for practical purposes.
\section{Practical aspects\label{sec:practical}}
Below is a list of practical aspects and considerations.
In addition to the PID controller, \pidfIAE, synthesizes a low-pass filter \eqref{eq:filter}, which allows for a controller with high-frequency roll-off, and thus good noise attenuation properties. This makes constraining $K_{ks}$ practically feasible. An alternative is to manually iterate between filter and controller design, and incorporate the filter as a series connected component of $P$ when running either \pidIE or \pidIAE. In this context, it can can be mentioned that it is common in academic work on PID control to consider minimization of IAE or IE under constraints on sensitivity (and complementary sensitivity), while disregarding noise sensitivity. One reason for this might be that it is complicated to decide on a reasonable constraint level, as it depends both on the gain of the process and on the spectral density of the measurement noise. However, disregarding noise sensitivity can result in very aggressive controllers, not suitable for practical use.
% infeasible starting points
\section{Practical aspects\label{sec:practical}}
Below is an unsorted list of practical aspects, which could be worth considering.
\begin{itemize}
% finding the global optimum
\item\emph{Frequency grid} All three design scripts supplied in \PIDopt rely on frequency domain design over a finite set of points (referred to as the frequency grid). It is crucial that this grid is selected sufficiently dense over the frequency range withing which constraints can be expected to be active. In most PID control applications, the bandwidth of the closed-loop system lies reasonably close to that of the controlled process, making it possible to select this grid based on process dynamics alone. The provided scripts rely on process-dependent frequency grids, which work most of the time. For certain use cases, it might, however, be necessary or desirable to change the method of grid selection by modifying the scripts. Relatedly, there is no restriction on using identical grids for the individual constraints. It is advisable to evaluate constraint fulfilment on denser grids than the ones used in the optimization, as there is no guarantee on the behaviour between grid points.
% robust stability /instability
\item\emph{Feasible initial controller} The \pidIE script relies on a feasible initial controller. For inherently stable processes, the zero controller $k_p=k_i=k_d$ constitutes a feasible choice. If the process is unstable, a stabilizing controller needs to be obtained -- methods for this are not provided within \PIDopt. The \pidIAE and \pidfIAE scripts do not explicitly rely on a stable initial controller. However, computation time is normally shortened if the initial controller has similar properties to the optimal one. In cases with local optima, a \emph{good} initial controller is also desirable
% grid selection. No guarantees inbetween grid points
\item\emph{Hot-start}
A viable strategy to decrease computational speed when using \pidfIAE is to use the result of \pidIE (invokes with the same process and constraint levels) as initial controller (together with a small filter constant) to hot-start the optimization. See \url{https://gitlab.control.lth.se/kristian/PIDopt/blob/master/example.m} for an example of this.
% discrete time
\item\emph{Stability}
The time domain evaluation of IAE in \pidIAE and \pidfIAE ensures stability. The convex-concave method used in \pidIE does not involve the time domain, only the gridded frequency domain. While robustness is ensured, stability is not. It is therefore possible to end up with robustly \emph{unstable} controllers. This is why it is important that an initially stabilizing controller is supplied to \pidIE. Relatedly, there is a possibility that the optimizer jumps from a robustly stable controller to a robustly unstable one between two iterations. However, the practical risk for this is very with a reasonably dense and wide frequency grid.
% All constraints not necessarily simultaneously active
\item\emph{Filter damping} The relative damping of the filter \eqref{eq:filter} optimized by \pidfIAE could of course be set to another value. It is also straightforward to modify the code, so that the filter damping is co-optimized with the controller parameters and filter time constants. This is not done in the supplied code, as the performance increase did not justify the encountered computational overhead, in for the few examples it has been evaluated in.
% note on reference handling
\item\emph{Discrete time} All process models and controllers in \PIDopt are continuous time LTI objects. Continuous time was chosen in favor of discrete time only because many control system designers have better intuition for it. It is straight forward to discretize the obtained controllers. Likewise, it should be straight forward to modify the scripts for discrete time designs -- the underlying methods are not particularity geared toward continuous time implementation.
% note on using ISE (2-norm) instead
\item\emph{Alternative objectives and constraints}
It is straight forward to impose constraints on other closed-loop transfer functions. In \pidIAE and \pidfIAE it would also be possible to change the objective to minimization of for instance the integrated square error (ISE), being the $\mathcal{L}_2$-norm of the load response $e$ (of which IAE is the $\mathcal{L}_1$-norm). The choices in the provided code were motivated by what is most commonly used in industrial applications. It is also possible to impose frequency-dependent robustness constraints, in which each frequency grid point is independently constrained.
% change filter damping, make part of optimization
\item\emph{Reference handling} The transfer functions from reference $r$ to control signal $u$ and measurement $y$ has not been considered. The reason for this is that they can be shaped by adding a reference pre-filter in combination with a feed-forward path from $r$ to $u$, to shape these transfer functions once the feedback controller $K$ has been designed. See for instance \cite{hast} for a discussion on the topic.
% add references? If so, to reference FF, the standard test batch, Tore and KJs book
\item\emph{Active constraints} For most practical design scenarios, at least one of the robustness constraints will be active. There are many situations, where the degrees of freedom result in only one active constraints.
\item\emph{Hessian matrix} The current implementations of \pidIAE and \pidfIAE relies on a Jacobian obtained through exact gradient computations. It is likely that computational efficiency could be improved by also providing a Hessian computed by similar means (rather than by finite differences).
\end{itemize}
% filter roll off within grid
\nobibliography{\jobname}
\nobibliography{\jobname} % FIXME: add references here
\end{document}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment