Problem statement and definition of the Hamiltonian
Consider a dynamical system of
first-order differential equations
![{\displaystyle {\dot {\mathbf {x} ))(t)=\mathbf {f} (\mathbf {x} (t),\mathbf {u} (t),t)}](https://wikimedia.org/api/rest_v1/media/math/render/svg/37335478a66de29ff76abb3981e71bab50a0173f)
where
denotes a vector of state variables, and
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 ![{\displaystyle J=\int _{t_{0))^{t_{1))I[\mathbf {x} (t),\mathbf {u} (t),t]\,\mathrm {d} t}](https://wikimedia.org/api/rest_v1/media/math/render/svg/e412bcdcc33873c718b2219f5ad4f636aeaa84cd)
subject to the above equations of motion of the state variables. The solution method involves defining an ancillary function known as the control Hamiltonian
which 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,
for all ![{\displaystyle \mathbf {u} (t)\in {\mathcal {U))}](https://wikimedia.org/api/rest_v1/media/math/render/svg/3c18cd344cf1531d5154f47405149b428abb2983)
The first-order necessary conditions for a maximum are given by
which is the maximum principle,
which generates the state transition function
,
which generates the costate equations ![{\displaystyle \,{\dot {\mathbf {\lambda } ))(t)=-\left[I_{\mathbf {x} }(\mathbf {x} (t),\mathbf {u} (t),t)+\mathbf {\lambda } ^{\mathsf {T))(t)\mathbf {f} _{\mathbf {x} }(\mathbf {x} (t),\mathbf {u} (t),t)\right]}](https://wikimedia.org/api/rest_v1/media/math/render/svg/e9622f9e710e33d342ef45a14d56d303a3fda2b1)
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.
![{\displaystyle H_{\mathbf {uu} }(\mathbf {x} ^{\ast }(t),\mathbf {u} ^{\ast }(t),\mathbf {\lambda } (t),t)\leq 0}](https://wikimedia.org/api/rest_v1/media/math/render/svg/0fd0932ebd81b6c58baa082505bd91760fa4e34b)
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
![{\displaystyle L=\int _{t_{0))^{t_{1))I(\mathbf {x} (t),\mathbf {u} (t),t)+\mathbf {\lambda } ^{\mathsf {T))(t)\left[\mathbf {f} (\mathbf {x} (t),\mathbf {u} (t),t)-{\dot {\mathbf {x} ))(t)\right]\,\mathrm {d} t}](https://wikimedia.org/api/rest_v1/media/math/render/svg/a4b75a91941402414d4025e57b1a6e405369c905)
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
![{\displaystyle -\int _{t_{0))^{t_{1))\mathbf {\lambda } ^{\mathsf {T))(t){\dot {\mathbf {x} ))(t)\,\mathrm {d} t=-\mathbf {\lambda } ^{\mathsf {T))(t_{1})\mathbf {x} (t_{1})+\mathbf {\lambda } ^{\mathsf {T))(t_{0})\mathbf {x} (t_{0})+\int _{t_{0))^{t_{1)){\dot {\mathbf {\lambda } ))^{\mathsf {T))(t)\mathbf {x} (t)\,\mathrm {d} t}](https://wikimedia.org/api/rest_v1/media/math/render/svg/24cf7333e7ebea0e0c45e8a2d5812b84b1b0487a)
which can be substituted back into the Lagrangian expression to give
![{\displaystyle L=\int _{t_{0))^{t_{1))\left[I(\mathbf {x} (t),\mathbf {u} (t),t)+\mathbf {\lambda } ^{\mathsf {T))(t)\mathbf {f} (\mathbf {x} (t),\mathbf {u} (t),t)+{\dot {\mathbf {\lambda } ))^{\mathsf {T))(t)\mathbf {x} (t)\right]\,\mathrm {d} t-\mathbf {\lambda } ^{\mathsf {T))(t_{1})\mathbf {x} (t_{1})+\mathbf {\lambda } ^{\mathsf {T))(t_{0})\mathbf {x} (t_{0})}](https://wikimedia.org/api/rest_v1/media/math/render/svg/faa3d1c13c957da2116f6fbb684a1bd58224d477)
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
![{\displaystyle \mathrm {d} L=\int _{t_{0))^{t_{1))\left[\left(I_{\mathbf {u} }(\mathbf {x} (t),\mathbf {u} (t),t)+\mathbf {\lambda } ^{\mathsf {T))(t)\mathbf {f} _{\mathbf {u} }(\mathbf {x} (t),\mathbf {u} (t),t)\right)\mathrm {d} \mathbf {u} (t)+\left(I_{\mathbf {x} }(\mathbf {x} (t),\mathbf {u} (t),t)+\mathbf {\lambda } ^{\mathsf {T))(t)\mathbf {f} _{\mathbf {x} }(\mathbf {x} (t),\mathbf {u} (t),t)+{\dot {\mathbf {\lambda } ))(t)\right)\mathrm {d} \mathbf {x} (t)\right]\mathrm {d} t-\mathbf {\lambda } ^{\mathsf {T))(t_{1})\mathrm {d} \mathbf {x} (t_{1})+\mathbf {\lambda } ^{\mathsf {T))(t_{0})\mathrm {d} \mathbf {x} (t_{0})\leq 0}](https://wikimedia.org/api/rest_v1/media/math/render/svg/0d3ee0a3c6c33269d5a5ae883b46f24fedfccb75)
For this expression to equal zero necessitates the following optimality conditions:
![{\displaystyle {\begin{aligned}\underbrace {I_{\mathbf {u} }(\mathbf {x} (t),\mathbf {u} (t),t)+\mathbf {\lambda } ^{\mathsf {T))(t)\mathbf {f} _{\mathbf {u} }(\mathbf {x} (t),\mathbf {u} (t),t)} _{={\frac {\partial H(\mathbf {x} (t),\mathbf {u} (t),\mathbf {\lambda } (t),t)}{\partial \mathbf {u} ))}&=0\\\underbrace {I_{\mathbf {x} }(\mathbf {x} (t),\mathbf {u} (t),t)+\mathbf {\lambda } ^{\mathsf {T))(t)\mathbf {f} _{\mathbf {x} }(\mathbf {x} (t),\mathbf {u} (t),t)} _{={\frac {\partial H(\mathbf {x} (t),\mathbf {u} (t),\mathbf {\lambda } (t),t)}{\partial \mathbf {x} ))}+{\dot {\mathbf {\lambda } ))(t)&=0\end{aligned))}](https://wikimedia.org/api/rest_v1/media/math/render/svg/f052eba791e8b0dbbfdd1b93f4d6b4a6567d574c)
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:
![{\displaystyle H(x_{t},u_{t},\lambda _{t+1},t)=\lambda _{t+1}^{\top }f(x_{t},u_{t},t)+I(x_{t},u_{t},t)\,}](https://wikimedia.org/api/rest_v1/media/math/render/svg/6cf60ac08349645f7276486048af84857b982275)
and the costate equations are
![{\displaystyle \lambda _{t}={\frac {\partial H}{\partial x_{t))))](https://wikimedia.org/api/rest_v1/media/math/render/svg/ed673879ccc939ca9930af066533819373e8654f)
(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
, then:[11]
![{\displaystyle H(x^{*}(t),u^{*}(t),\lambda ^{*}(t))=\mathrm {constant} \,}](https://wikimedia.org/api/rest_v1/media/math/render/svg/fc594b206b13aa02194e09645c616c57d3f12391)
or if the terminal time is free, then:
![{\displaystyle H(x^{*}(t),u^{*}(t),\lambda ^{*}(t))=0.\,}](https://wikimedia.org/api/rest_v1/media/math/render/svg/da82810c898d2bd344f19eec1bb4a990c0e2897e)
Further, if the terminal time tends to infinity, a transversality condition on the Hamiltonian applies.[12]
![{\displaystyle \lim _{t\to \infty }H(t)=0}](https://wikimedia.org/api/rest_v1/media/math/render/svg/62ea88caf1d452187dcbe4395e41459a4719600a)
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
![{\displaystyle {\mathcal {H))(p,q,t)=\langle p,{\dot {q))\rangle -L(q,{\dot {q)),t)}](https://wikimedia.org/api/rest_v1/media/math/render/svg/e722a38bb240722b5d6157ea9ec93f01d2396747)
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
![{\displaystyle {\frac {d}{dt))p(t)=-{\frac {\partial }{\partial q)){\mathcal {H))}](https://wikimedia.org/api/rest_v1/media/math/render/svg/39faa5adf331b2e969903d5c893901b09a119dda)
![{\displaystyle {\frac {d}{dt))q(t)=~~{\frac {\partial }{\partial p)){\mathcal {H))}](https://wikimedia.org/api/rest_v1/media/math/render/svg/e93626e0ebd1ac6de5be935c8671a8642ab85300)
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
![{\displaystyle H(q,u,p,t)=\langle p,{\dot {q))\rangle -L(q,u,t)}](https://wikimedia.org/api/rest_v1/media/math/render/svg/5326e2877f7df942e831b2f7ae0ce02df1a78e1e)
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
![{\displaystyle {\frac {dp}{dt))=-{\frac {\partial H}{\partial q))}](https://wikimedia.org/api/rest_v1/media/math/render/svg/a2851b75043e72abfc0de698695a2799de609c77)
![{\displaystyle {\frac {dq}{dt))=~~{\frac {\partial H}{\partial p))}](https://wikimedia.org/api/rest_v1/media/math/render/svg/7b5320d6a4d7386caa7efc34ab5fcbfd46351239)
![{\displaystyle {\frac {\partial H}{\partial u))=0}](https://wikimedia.org/api/rest_v1/media/math/render/svg/e44b5ff1ad0419c73a597de1fcde6816ce06f1ba)
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
![{\displaystyle I(\mathbf {x} (t),\mathbf {u} (t),t)=e^{-\rho t}\nu (\mathbf {x} (t),\mathbf {u} (t))}](https://wikimedia.org/api/rest_v1/media/math/render/svg/a103abcefa21c7a9b5894763834b353b460c6a20)
where
is referred to as the instantaneous utility function, or felicity function.[15] This allows a redefinition of the Hamiltonian as
where
![{\displaystyle {\begin{aligned}{\bar {H))(\mathbf {x} (t),\mathbf {u} (t),\mathbf {\lambda } (t))\equiv &\,e^{\rho t}\left[I(\mathbf {x} (t),\mathbf {u} (t),t)+\mathbf {\lambda } ^{\mathsf {T))(t)\mathbf {f} (\mathbf {x} (t),\mathbf {u} (t),t)\right]\\=&\,\nu (\mathbf {x} (t),\mathbf {u} (t),t)+\mathbf {\mu } ^{\mathsf {T))(t)\mathbf {f} (\mathbf {x} (t),\mathbf {u} (t),t)\end{aligned))}](https://wikimedia.org/api/rest_v1/media/math/render/svg/b209d34cddfd4bf27304c7734db0d9571a22743e)
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.
,
![{\displaystyle {\frac {\partial {\bar {H))(\mathbf {x} (t),\mathbf {u} (t),\mathbf {\lambda } (t))}{\partial \mathbf {x} ))=-{\dot {\mathbf {\mu } ))(t)+\rho \mathbf {\mu } (t)}](https://wikimedia.org/api/rest_v1/media/math/render/svg/4edfe525ef2816cc03c7b5d2a94268bde8614c69)
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,
![{\displaystyle J(c)=\int _{0}^{T}e^{-\rho t}u(c(t))dt}](https://wikimedia.org/api/rest_v1/media/math/render/svg/20e076b39ea813d548cd80abcda9387626753b2b)
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:
![{\displaystyle {\dot {k))={\frac {\partial k}{\partial t))=f(k(t))-(n+\delta )k(t)-c(t)}](https://wikimedia.org/api/rest_v1/media/math/render/svg/b643e33505ed174682d8fc02cdf5d0cc8e4595f2)
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
![{\displaystyle H(k,c,\mu ,t)=e^{-\rho t}u(c(t))+\mu (t){\dot {k))=e^{-\rho t}u(c(t))+\mu (t)[f(k(t))-(n+\delta )k(t)-c(t)]}](https://wikimedia.org/api/rest_v1/media/math/render/svg/ec42cb2c1452bfe95945ca3e526cbb565930c3fd)
The optimality conditions are
![{\displaystyle {\frac {\partial H}{\partial c))=0\Rightarrow e^{-\rho t}u'(c)=\mu (t)}](https://wikimedia.org/api/rest_v1/media/math/render/svg/07dbafde54f12793a94e6fae1956e9050d0a6d12)
![{\displaystyle {\frac {\partial H}{\partial k))=-{\frac {\partial \mu }{\partial t))=-{\dot {\mu ))\Rightarrow \mu (t)[f'(k)-(n+\delta )]=-{\dot {\mu ))}](https://wikimedia.org/api/rest_v1/media/math/render/svg/fa359da70f6163fd5343ddea0bf2c69f1f9fcf94)
in addition to the transversality condition
. If we let
, then log-differentiating the first optimality condition with respect to
yields
![{\displaystyle -\rho -{\frac {\dot {c)){c(t)))={\frac {\dot {\mu )){\mu (t)))}](https://wikimedia.org/api/rest_v1/media/math/render/svg/8b4026dda1ee2c8fde424cba8d9b9eb055776047)
Inserting this equation into the second optimality condition yields
![{\displaystyle \rho +{\frac {\dot {c)){c(t)))=f'(k)-(n+\delta )}](https://wikimedia.org/api/rest_v1/media/math/render/svg/33c13b8335086e710b77c03e2186e54e065d4638)
which is known as the Keynes–Ramsey rule, which gives a condition for consumption in every period which, if followed, ensures maximum lifetime utility.