How to Optimize PID Gains Non-Heuristically

In robotics, variables that control processes (usually voltage output to actuators) are continually adjusted by a PID (Proportional Integral Derivative) Control algorithm to improve the result of a process (usually, the process is volatile or not well understood). More formally, $v(t)$ is the aforementioned variable that is defined by a PID Control algorithm at a given time, $t$, $e(t)$ is the error in the result of some process at a given time, $t$. The PID Control algorithm can be modeled with the equation

$$v(t) = K_pe(T) + K_i\int_0^t{e(\tau)}d\tau+K_d\frac{de(t)}{dt}$$ where $K_p$, $K_i$, $K_d$ are tuning parameters for the algorithm (these are called "gains"). Normally, the PID gains are adjusted heuristically by a human until the algorithm is sufficiently optimized.

My question: In an ideal setting, what factors should be taken into consideration to optimize the PID gains, and how can those factors be used to mathematically optimize the PID gains without testing? I am not looking for a definitive answer, rather a variety of mathematical insights into this problem.

Some possible factors may include:

• the time interval between each successive calculation of $v$
• some inertial property of the process
• the volatility of the process ($e$ may experience uncontrollable jitters)
• the initial error, $e(0)$
• $v$'s mathematical roll in the process
• the units assigned to $v$ and $e$ (e.g. $v$ may be expressed in volts, while $e$ may be expressed in $\frac{m}{s}$)
• Did you consider the cost of using the input? Or the energy usage of the input? You said $v$ could be voltage right, as you type on your laptop you are well aware electricity cost both energy and money, how do you achieve the control objective with the least cost and least energy? – Carlos - the Mongoose - Danger Mar 27 '16 at 20:50
• That is a very good point @Lookbehindyou. If $|v|$ represents energy expenditure or fuel consumption, we want $\int{|v(t)|}$ to be as small as possible! It is important that the graph of $e(t)$ reaches $e=0$ when $\frac{de(t)}{dt} = 0$, otherwise we would waste energy/fuel by overshooting the target. – pseudoeuclidean Mar 27 '16 at 21:17
• Yes, now suppose we are only considering a $P$ controller, i.e. $v(t) = K_p e(t)$, where $v(t)$ is the input and $e(t)$ is the difference between reference and the feedback term, your question reduces to what $K_p$ is the best $K_p$ that minimizes cost and minimizes energy while satisfying control objectives – Carlos - the Mongoose - Danger Mar 27 '16 at 23:50
• It turns out in order to answer this question without using heuristics, you need to know modern control theory formulated in state space, and using the controllability, observability, detectability and stabilizability notions of Kalman. The answer lies in optimal control, and the Hamilton Jacobi equation. – Carlos - the Mongoose - Danger Mar 27 '16 at 23:51
• Yes the Hamilton Jacobi equation is a pde very difficult to solve and arises in many situations. But interestingly it was Kalman himself who simplified the HJB equation and provided and sufficient condition for the existence of an optimal controller en.wikipedia.org/wiki/Optimal_control#Linear_quadratic_control This is called the linear quadratic control problem. – Carlos - the Mongoose - Danger Mar 29 '16 at 4:06