Chapter 11: Policy Search
In our case study on perching aircraft, we solved a challenging control problem, but our approach to control design was based on only linear optimal control (around an optimized trajectory). We've also discussed some approaches to nonlinear optimal control that could scale beyond small, discretized state spaces. These were based on estimating the cost-to-go function, including value iteration using function approximation and approximate dynamic programming as a linear program or as a sums-of-squares program.
There are a lot of things to like about methods that estimate the cost-to-go function (aka value function). The cost-to-go function reduces the long-term planning problem into a one-step planning problem; it encodes all relevant information about the future (and nothing more). The HJB gives us optimality conditions for the cost-to-go that give us a strong algorithmic handle to work with.
In this chapter, we will explore another very natural idea: let us parameterize a controller with some decision variables, and then search over those decision variables directly in order to achieve a task and/or optimize a performance objective. One specific motivation for this approach is the (admittedly somewhat anecdotal) observation that often times simple policies can perform very well on complicated robots and with potentially complicated cost-to-go functions.
We'll refer to this broad class of methods as "policy search" or, when optimization methods are used, we'll sometimes use "policy optimization". This idea has not received quite as much attention from the controls community, probably because we know many relatively simple cases where it does not work well. But it has become very popular again lately due to the empirical success of "policy gradient" algorithms in reinforcement learning (RL). This chapter includes a discussion of the "model-based" version of these RL policy-gradient algorithms; we'll describe their "model-free" versions in a future chapter.
Problem formulation
Consider a static full-state feedback policy,
Using our prescription for optimal control using additive costs, we can evaluate the performance of this controller from any initial condition using, e.g.: \begin{align*} J_\balpha(\bx) =& \int_0^\infty \ell(\bx(t), \bu(t)) dt, \ \subjto \quad & \dot\bx = f(\bx, \bu), \quad \bu = \bpi_\balpha(\bx), \quad \bx(0) = \bx.\end{align*} In order to provide a scalar cost for each set of policy parameters, , we need one more piece: a relative importance for the different initial conditions.
As we will further elaborate when we discuss stochastic optimal control, a very natural choice -- one that preserves the recursive structure of the HJB -- is to optimize the expected value of the cost, given some distribution over initial conditions:
Linear Quadratic Regulator
To start thinking about the problem of searching directly in the policy parameters, it's very helpful to start with a problem we know and can understand well. In LQR problems for linear, time-invariant systems, we know that the optimal policy is a linear function: So far, we have always obtained indirectly -- by solving a Riccati equation to find the cost-to-go and then backing out the optimizing policy. Here, let us study the case where we parameterize the elements of as decision variables, and attempt to optimize the expected cost-to-go directly.
Policy Evaluation
First, let's evaluate our objective for a given . This step is known as "policy evaluation". If we use a Gaussian with mean zero and covariance as our distribution over initial conditions, then for LQR we have \begin{align*} & E\left[ \int_0^\infty [\bx^T{\bf Q}\bx + \bu^T\bR\bu] dt \right], \ \subjto \quad & \dot\bx = {\bf A}\bx + {\bf B}\bu, \quad \bu = - {\bf K}\bx, \quad \bx(0) \sim \mathcal{N}(0, {\bf \Omega}).\end{align*} This problem is also known as the optimal control problem[1], since the expected-cost-to-go here is the -norm of the linear system from disturbance input (here only an impulse that generates our initial conditions) to performance output (which here would be e.g. $\bz = \begin{bmatrix} \bQ^{\frac{1}{2}}\bx \ \bR^{\frac{1}{2}}\bu \end{bmatrix}).$
To evaluate a policy , let us first re-arrange the cost function slightly, using the properties of the matrix trace: \begin{gather*} \bx^T\bQ\bx + \bx^T\bK^T\bR\bK\bx = \bx^T(\bQ + \bK^T\bR\bK)\bx^T = \trace\left((\bQ + \bK^T\bR\bK)\bx\bx^T\right), \end{gather*} and the linearity of the integral and expected value:
A nonconvex objective in
Unfortunately, the Lyapunov equation represents a nonlinear constraint (on the pair , ). Indeed, it is well known that even the set of controllers that stabilizing a linear systems can be nonconvex in the parameters when there are 3 or more state variables[2].
Example: The set of stabilizing can be non-convex
The following example was given in [2]. Consider a discrete-time linear system with $\bA = {\bf I}{3 \times 3}, \bB = {\bf I}{3 \times 3}$. The controllers given by
are both stabilizing controllers for this system (all eigenvalues of are inside the unit circle of the complex plane). However the controller $\hat{\bK} = (\bK_1 + \bK_2)/2$ has two eigenvalues outside the unit circle.
Since the set of controllers that achieve finite total cost is non-convex, clearly the cost function we consider here is also non-convex.
As an aside, for this problem we do actually know a change of variables that make the problem convex. Let's introduce a new variable Since is PSD, we can back out $\bK = {\bf YX}^{-1}.$ Now we can rewrite the optimization: \begin{align*} \min_{{\bf X}, {\bf Y}} & \quad \trace{\bQ^\frac{1}{2} {\bf X} \bQ^\frac{1}{2}} + \trace{\bR^\frac{1}{2} {\bf Y} {\bf X}^{-1} {\bf Y}^T \bR^\frac{1}{2}} \ \subjto & \quad \bA{\bf X} - \bB{\bf Y} + {\bf X}\bA^T - {\bf Y}^T\bB^T + {\bf \Omega} = 0, \ & \quad {\bf X} \succ 0.\end{align*} The second term in the objective appears to be nonconvex, but is actually convex. In order to write it as a SDP, we can replace it exactly with one more slack variable, , and a Schur complement[3]: \begin{align*} \min_{{\bf X}, {\bf Y}, {\bf Z}} & \quad \trace{\bQ^\frac{1}{2} {\bf X} \bQ^\frac{1}{2}} + \trace{\bf Z} \ \subjto & \quad \bA{\bf X} - \bB{\bf Y} + {\bf X}\bA^T - {\bf Y}^T\bB^T + {\bf \Omega} = 0, \ & \quad \begin{bmatrix} {\bf Z} & \bR^\frac{1}{2} {\bf Y} \ {\bf Y}^T \bR^\frac{1}{2} & {\bf X} \end{bmatrix} \succeq 0.\end{align*}
Nevertheless, our original question is asking about searching directly in the original parameterization, . If the objective in nonconvex in those parameters, then how should we perform the search?
No local minima
Although convexity is sufficient to guarantee that an optimization landscape does not have any local minima, it is not actually necessary. [2] showed that for this LQR objective, all local optima are in fact global optima. This analysis was extended in [4] to give a simpler analysis and include convergence rates.
How does one show that an optimization landscape has no local minima (even though it may be non-convex)? One of the most popular tools is to demonstrate gradient dominance with the famous Polyak-Lojasiewicz (PL) inequality [5]. For an optimization problem
Example: A nonconvex function with no local minima
Consider the function
▶ Embedded content: https://underactuated.mit.edu/data/pl_inequality.html
We can establish that this function is not convex by observing that for , , we have
We can establish the PL conditions using the gradient
We can establish that this function is -smooth with bybecause Finally, we have gradient-dominance from the PL-inequality:with . (I confirmed this with a small dReal program).▶ Embedded content: https://underactuated.mit.edu/data/pl_inequality_grad.html
[5] gives a convergence rate for convergence to an optima for gradient descent given the PL conditions. [4] showed that the gradients of the LQR cost we examine here with respect to satisfy the PL conditions on any sublevel set of the cost-to-go function.
True gradient descent
The results described above suggest that one can use gradient descent to obtain the optimal controller, for LQR. For the variations we've seen so far (where we know the model), I would absolutely recommend that solving the Riccati equations is a much better algorithm; it is faster and more robust, with no parameters like step-size to tune. But gradient descent becomes more interesting / viable when we think of it as a model for a less perfect algorithm, e.g. where the plant model is not given and the gradients are estimated from noisy samples.
It is a rare luxury, due here to our ability to integrate the linear plants/controllers, quadratic costs, and Gaussian initial conditions, that we could compute the value function exactly in (\ref{eq:lqr_evaluation}). We can also compute the true gradient -- this is a pinnacle of exactness we should strive for in our methods but will rarely achieve again. The gradient is given by
Note that the term policy gradient used in reinforcement learning typically refers to the slightly different class of algorithms I hinted at above. In those algorithms, we use the true gradients of the policy (only), but estimate the remainder of the terms in the gradient through sampling. These methods typically require many samples to estimate the gradients we compute here, and should only be weaker (less efficient) than the algorithms in this chapter. The papers investigating the convergence of gradient descent for LQR have also started exploring these cases. We will study these so-called model-free" policy search algorithms soon.
More convergence results and counter-examples
LQR / control is one of the good cases, where we know that for the objective parameterized directly in , all local optima are global optima. [6] extended this result for mixed control. [7] gives a recent treatment of the tabular (finite) MDP case.
For LQR, we also know alternative parameterizations of the controller which make the objective actually convex, including the LMI formulation and the Youla parameterization. Their utility in a policy search setting was studied initially in [8].
Unfortunately, we do not expect these nice properties to hold in general. There are a number of nearby problems which are known to be nonconvex in the original parameters, and which will not have a smooth change of variables which makes them convex. The case of [static output feedback is an important one. There are many other known counter-examples. [9] gives a particularly simple one with a two state MDP. One of the big open questions is whether deep network parameterizations are an example of a good case.](016_2024-01-01_output-feedback.md#static)
# Trajectory-based policy search
Although we cannot expect gradient descent to converge to a global
minima in general, it is still very reasonable to try using gradient
descent to find policies for more complicated nonlinear control problems.
In the general form, this means that the first step of optimizing
The most common/general technique (despite it not being very efficient), is to approximate the expected cost-to-go using a sampling (Monte-Carlo) approximation using a large number, , of samples:
Using the Monte-Carlo estimator, the total gradient update is just a sum over gradients with respect to particular initial conditions, But for finite-horizon objectives, these are precisely the gradients that we have already studied in the context of trajectory optimization. They can be computed efficiently using an adjoint method. The difference is that here we think of as the parameters of a feedback controller, whereas before we thought of them as the parameters of a trajectory, but this makes no difference to the chain rule.
Example: LQR with true gradients vs approximate gradients
Example: Pendulum Swing-Up And Balance
Infinite-horizon objectives
Search strategies for global optimization
To combat local minima... Evolutionary strategies, ...
Policy Iteration
In the chapter on Lyapunov analysis we also explored a handful techniques for control design. One of these even directly parameterized the controller (as a polynomial feedback), and used alternations to switch between policy evaluation and policy optimization. Another generated lower-bounds to the optimal cost-to-go.
Coming soon...
References
Ben M. Chen, "H2 Optimal Control", Encyclopedia of Systems and Control , pp. 515--520, 2015.
Maryam Fazel and Rong Ge and Sham M. Kakade and Mehran Mesbahi, "Global Convergence of Policy Gradient Methods for the Linear Quadratic Regulator", International Conference on Machine Learning , 2018.
Erik A Johnson and Baris Erkus, "Dissipativity and performance analysis of smart dampers via LMI synthesis", Structural Control and Health Monitoring: The Official Journal of the International Association for Structural Control and Monitoring and of the European Association for the Control of Structures, vol. 14, no. 3, pp. 471--496, 2007.
Hesameddin Mohammadi and Armin Zare and Mahdi Soltanolkotabi and Mihailo R Jovanovi'c, "Global exponential convergence of gradient methods over the nonconvex landscape of the linear quadratic regulator", 2019 IEEE 58th Conference on Decision and Control (CDC) , pp. 7474--7479, 2019.
Hamed Karimi and Julie Nutini and Mark Schmidt, "Linear convergence of gradient and proximal-gradient methods under the polyak-\lojasiewicz condition", Joint European Conference on Machine Learning and Knowledge Discovery in Databases , pp. 795--811, 2016.
Kaiqing Zhang and Bin Hu and Tamer Basar, "Policy Optimization for ℋ₂ Linear Control with ℋ∞ Robustness Guarantee: Implicit Regularization and Global Convergence", Proceedings of the 2nd Conference on Learning for Dynamics and Control , vol. 120, pp. 179--190, 10--11 Jun, 2020.
Alekh Agarwal and Sham M. Kakade and Jason D. Lee and Gaurav Mahajan, "On the Theory of Policy Gradient Methods: Optimality, Approximation, and Distribution Shift", , 2020.
John Roberts and Ian Manchester and Russ Tedrake, "Feedback Controller Parameterizations for Reinforcement Learning", Proceedings of the 2011 IEEE Symposium on Adaptive Dynamic Programming and Reinforcement Learning (ADPRL) , 2011. [ link ]
Jalaj Bhandari and Daniel Russo, "Global Optimality Guarantees For Policy Gradient Methods", arXiv:1906.01786 [cs, stat], oct, 2020.
Reuven Y Rubinstein and Dirk P Kroese, "Simulation and the Monte Carlo method", John Wiley & Sons , vol. 10, 2016.