Hamiltonian (control theory) explained
The Hamiltonian is a function used to solve a problem of optimal control for a dynamical system. It can be understood as an instantaneous increment of the Lagrangian expression of the problem that is to be optimized over a certain time period.[1] Inspired by—but distinct from—the Hamiltonian of classical mechanics, the Hamiltonian of optimal control theory was developed by Lev Pontryagin as part of his maximum principle.[2] Pontryagin proved that a necessary condition for solving the optimal control problem is that the control should be chosen so as to optimize the Hamiltonian.[3]
Problem statement and definition of the Hamiltonian
Consider a dynamical system of
first-order
differential equations
where
x(t)=\left[x1(t),x2(t),\ldots,xn(t)\right]T
denotes a vector of state variables, and
u(t)=\left[u1(t),u2(t),\ldots,ur(t)\right]T
a vector of control variables. Once initial conditions
and controls
are specified, a solution to the differential equations, called a
trajectory
, can be found. The problem of optimal control is to choose
(from some set
) so that
maximizes or minimizes a certain
objective function between an initial time
and a terminal time
(where
may be
infinity). Specifically, the goal is to optimize over a performance index
defined at each point in time,
, with
subject to the above equations of motion of the state variables. The solution method involves defining an ancillary function known as the control Hamiltonianwhich combines the objective function and the state equations much like a
Lagrangian in a static optimization problem, only that the multipliers
—referred to as
costate variables—are functions of time rather than constants.
The goal is to find an optimal control policy function
and, with it, an optimal trajectory of the state variable
, which by
Pontryagin's maximum principle are the arguments that maximize the Hamiltonian,
H(x\ast(t),u\ast(t),λ(t),t)\geqH(x(t),u(t),λ(t),t)
for all
The first-order necessary conditions for a maximum are given by
| \partialH(x(t),u(t),λ(t),t) |
\partialu |
=0
which is the maximum principle,
| \partialH(x(t),u(t),λ(t),t) |
\partialλ |
=
(t)
which generates the state transition function
,
| \partialH(x(t),u(t),λ(t),t) |
\partialx |
=-
(t)
which generates the
costate equations
(t)=-\left[Ix(x(t),u(t),t)+λT(t)fx(x(t),u(t),t)\right]
Together, the state and costate equations describe the Hamiltonian dynamical system (again analogous to but distinct from the Hamiltonian system in physics), the solution of which involves a two-point boundary value problem, given that there are
boundary conditions involving two different points in time, the initial time (the
differential equations for the state variables), and the terminal time (the
differential equations for the costate variables; unless a final function is specified, the boundary conditions are
, or
for infinite time horizons).
[4] A sufficient condition for a maximum is the concavity of the Hamiltonian evaluated at the solution, i.e.
Huu(x\ast(t),u\ast(t),λ(t),t)\leq0
where
is the optimal control, and
is resulting optimal trajectory for the state variable.
[5] Alternatively, by a result due to
Olvi L. Mangasarian, the necessary conditions are sufficient if the functions
and
are both concave in
and
.
[6] Derivation from the Lagrangian
A constrained optimization problem as the one stated above usually suggests a Lagrangian expression, specifically
L=
I(x(t),u(t),t)+λT(t)\left[f(x(t),u(t),t)-
(t)\right]dt
where
compares to the
Lagrange multiplier in a static optimization problem but is now, as noted above, a function of time. In order to eliminate
, the last term on the right-hand side can be rewritten using
integration by parts, such that
-
λT(t)
(t)dt=-λT(t1)x(t1)+λT(t0)x(t0)+
T(t)x(t)dt
which can be substituted back into the Lagrangian expression to give
L=
\left[I(x(t),u(t),t)+λT(t)f(x(t),u(t),t)+
T(t)x(t)\right]dt-λT(t1)x(t1)+λT(t0)x(t0)
To derive the first-order conditions for an optimum, assume that the solution has been found and the Lagrangian is maximized. Then any perturbation to
or
must cause the value of the Lagrangian to decline. Specifically, the
total derivative of
obeys
dL=
\left[\left(Iu(x(t),u(t),t)+λT(t)fu(x(t),u(t),t)\right)du(t)+\left(Ix(x(t),u(t),t)+λT(t)fx(x(t),u(t),t)+
(t)\right)dx(t)\right]dt-λT(t1)dx(t1)+λT(t0)dx(t0)\leq0
For this expression to equal zero necessitates the following optimality conditions:
\begin{align}
\underbrace{Iu(x(t),u(t),t)+λT(t)fu
(x(t),u(t),t)} | |
| = | | \partialH(x(t),u(t),λ(t),t) | \partialu |
|
|
&=0\\
\underbrace{Ix(x(t),u(t),t)+λT(t)fx
(x(t),u(t),t)} | |
| = | | \partialH(x(t),u(t),λ(t),t) | \partialx |
|
|
+
(t)&=0
\end{align}
If both the initial value
and terminal value
are fixed, i.e.
, no conditions on
and
are needed. If the terminal value is free, as is often the case, the additional condition
is necessary for optimality. The latter is called a transversality condition for a fixed horizon problem.
[7] It can be seen that the necessary conditions are identical to the ones stated above for the Hamiltonian. Thus the Hamiltonian can be understood as a device to generate the first-order necessary conditions.[8]
The Hamiltonian in discrete time
When the problem is formulated in discrete time, the Hamiltonian is defined as:
H(xt,ut,λt+1
f(xt,ut,t)+I(xt,ut,t)
and the costate equations are
(Note that the discrete time Hamiltonian at time
involves the costate variable at time
[9] This small detail is essential so that when we differentiate with respect to
we get a term involving
on the right hand side of the costate equations. Using a wrong convention here can lead to incorrect results, i.e. a costate equation which is not a backwards difference equation).
Behavior of the Hamiltonian over time
From Pontryagin's maximum principle, special conditions for the Hamiltonian can be derived.[10] When the final time
is fixed and the Hamiltonian does not depend explicitly on time
\left(\tfrac{\partialH}{\partialt}=0\right)
, then:
[11] H(x*(t),u*(t),λ*(t))=constant
or if the terminal time is free, then:
Further, if the terminal time tends to
infinity, a
transversality condition on the Hamiltonian applies.
[12]
The Hamiltonian of control compared to the Hamiltonian of mechanics
William Rowan Hamilton defined the Hamiltonian for describing the mechanics of a system. It is a function of three variables and related to the Lagrangian as
l{H}(p,q,t)=\langlep,
\rangle-L(q,
,t)
where
is the
Lagrangian, the extremizing of which determines the dynamics (
not the Lagrangian defined above) and
is the state variable. The Lagrangian is evaluated with
representing the time derivative of the state's evolution and
, the so-called "conjugate momentum", relates to it as
.
Hamilton then formulated his equations to describe the dynamics of the system as
The Hamiltonian of control theory describes not the dynamics of a system but conditions for extremizing some scalar function thereof (the Lagrangian) with respect to a control variable
. As normally defined, it is a function of 4 variables
H(q,u,p,t)=\langlep,
\rangle-L(q,u,t)
where
is the state variable and
is the control variable with respect to that which we are extremizing.
The associated conditions for a maximum are
This definition agrees with that given by the article by Sussmann and Willems.[13] (see p. 39, equation 14). Sussmann and Willems show how the control Hamiltonian can be used in dynamics e.g. for the brachistochrone problem, but do not mention the prior work of Carathéodory on this approach.[14]
Current value and present value Hamiltonian
In economics, the objective function in dynamic optimization problems often depends directly on time only through exponential discounting, such that it takes the form
I(x(t),u(t),t)=e-\rho\nu(x(t),u(t))
where
is referred to as the instantaneous utility function, or felicity function.
[15] This allows a redefinition of the Hamiltonian as
H(x(t),u(t),λ(t),t)=e-\rho\bar{H}(x(t),u(t),λ(t))
where
\begin{align}
\bar{H}(x(t),u(t),λ(t))\equiv&e\rho\left[I(x(t),u(t),t)+λT(t)f(x(t),u(t),t)\right]\\
=&\nu(x(t),u(t),t)+\muT(t)f(x(t),u(t),t)
\end{align}
which is referred to as the current value Hamiltonian, in contrast to the present value Hamiltonian
defined in the first section. Most notably the costate variables are redefined as
, which leads to modified first-order conditions.
| \partial\bar{H |
(x(t),u(t),λ(t))}{\partial |
u
} = 0,
| \partial\bar{H |
(x(t),u(t),λ(t))}{\partial |
x
} = - \dot(t) + \rho \mathbf(t)which follows immediately from the
product rule. Economically,
represent current-valued
shadow prices for the capital goods
.
Example: Ramsey–Cass–Koopmans model
In economics, the Ramsey–Cass–Koopmans model is used to determine an optimal savings behavior for an economy. The objective function
is the
social welfare function,
to be maximized by choice of an optimal consumption path
. The function
indicates the
utility the
representative agent of consuming
at any given point in time. The factor
represents
discounting. The maximization problem is subject to the following differential equation for
capital intensity, describing the time evolution of capital per effective worker:
=f(k(t))-(n+\delta)k(t)-c(t)
where
is period t consumption,
is period t capital per worker (with
),
is period t production,
is the population growth rate,
is the capital depreciation rate, the agent discounts future utility at rate
, with
and
.
Here,
is the state variable which evolves according to the above equation, and
is the control variable. The Hamiltonian becomes
H(k,c,\mu,t)=e-\rhou(c(t))+\mu(t)
=e-\rhou(c(t))+\mu(t)[f(k(t))-(n+\delta)k(t)-c(t)]
The optimality conditions are
⇒ \mu(t)[f'(k)-(n+\delta)]=-
in addition to the transversality condition
. If we let
, then
log-differentiating the first optimality condition with respect to
yields
Inserting this equation into the second optimality condition yields
which is known as the Keynes–Ramsey rule, which gives a condition for consumption in every period which, if followed, ensures maximum lifetime utility.
Further reading
- Book: Daniel . Léonard . Ngo Van . Long . Optimal Control Theory and Static Optimization in Economics . New York . Cambridge University Press . 1992 . The Maximum Principle . 0-521-33158-7 . 127–168 . https://books.google.com/books?id=gSHxK5Cq4BgC&pg=PA127 .
- Book: Takayama, Akira . Mathematical Economics . Developments of Optimal Control Theory and Its Applications . New York . Cambridge University Press . 2nd . 1985 . 0-521-31498-4 . 600–719 . https://books.google.com/books?id=j6PLOBFotPQC&pg=PA600 .
- Book: Wulwick, Nancy . 1995 . The Hamiltonian Formalism and Optimal Growth Theory . Measurement, Quantification, and Economic Analysis . I. H. . Rima . London . Routledge . 978-0-415-08915-9 .
Notes and References
- Book: Brian S. . Ferguson . G. C. . Lim . Introduction to Dynamic Economic Problems . Manchester . Manchester University Press . 1998 . 0-7190-4996-2 . 166–167 .
- Book: Dixit, Avinash K. . Optimization in Economic Theory . New York . Oxford University Press . 1990 . 978-0-19-877210-1 . 145–161 .
- Book: Kirk, Donald E. . Optimal Control Theory : An Introduction . Englewood Cliffs . Prentice Hall . 1970 . 0-13-638098-0 . 232 .
- Book: Gandolfo, Giancarlo . Economic Dynamics . Berlin . Springer . Third . 1996 . 3-540-60988-1 . 375–376 .
- Book: Atle . Seierstad . Knut . Sydsæter . Knut Sydsæter . Optimal Control Theory with Economic Applications . Amsterdam . North-Holland . 1987 . 107–110 . 0-444-87923-4 .
- SIAM Journal on Control . 4 . 1966 . 1 . 139–152 . Sufficient Conditions for the Optimal Control of Nonlinear Systems . O. L. . Mangasarian . 10.1137/0304013 .
- Book: Daniel . Léonard . Ngo Van . Long . Optimal Control Theory and Static Optimization in Economics . New York . Cambridge University Press . 1992 . Endpoint Constraints and Transversality Conditions . 0-521-33158-7 . 222 [Theorem 7.1.1] . https://books.google.com/books?id=gSHxK5Cq4BgC&pg=PA222 .
- Book: Morton I. . Kamien . Nancy L. . Schwartz . Dynamic Optimization : The Calculus of Variances and Optimal Control in Economics and Management . Amsterdam . North-Holland . Second . 1991 . 0-444-01609-0 . 126–127 .
- Web site: U. . Jönsson . A DISCRETE VERSION OF PMP . 2005 . 25 . January 22, 2023 . https://web.archive.org/web/20230122192015/https://www.math.kth.se/optsyst/grundutbildning/5B1872/Discrete.pdf .
- Book: Naidu, Desineni S. . Optimal Control Systems . Boca Raton . CRC Press . 2003 . 0-8493-0892-5 . 259–260 .
- Delfim F. M. . Torres . A Remarkable Property of the Dynamic Optimization Extremals . Investigacao Operacional . 22 . 2 . 2002 . 253–263 . math/0212102 . 2002math.....12102T .
- Philippe . Michel . Philippe Michel (economist) . On the Transversality Condition in Infinite Horizon Optimal Problems . . 50 . 4 . 1982 . 975–985 . 10.2307/1912772 . 1912772 . 16503488 .
- 300 Years of Optimal Control . Sussmann . Willems . IEEE Control Systems Magazine . June 1997 . 10.1109/37.588098 . July 30, 2010 . https://web.archive.org/web/20100730033612/http://yima.csl.illinois.edu/psfile/ECE553/sussmann-willems.pdf .
- See H. J. . Pesch . R. . Bulirsch . The maximum principle, Bellman's equation, and Carathéodory's work . . 80 . 1994 . 2 . 199–225 . 10.1007/BF02192933 . 121749702 .
- Web site: Econ 4350: Growth and Investment: Lecture Note 7 . Department of Economics, University of Oslo . Kåre . Bævre . Spring 2005 .