Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Exercises

  1. Equality path constraints and the augmented Hamiltonian

    Consider the Bolza problem

    minu()  J=Φ ⁣(x(tf))+t0tfL(x,u,t)dt,\min_{\boldsymbol{u}(\cdot)} \; J = \Phi\!\left(\boldsymbol{x}(t_f)\right) + \int_{t_0}^{t_f} L(\boldsymbol{x},\boldsymbol{u},t)\,\mathrm{d}t,

    subject to

    x˙=f(x,u,t)\dot{\boldsymbol{x}} = \boldsymbol{f}(\boldsymbol{x},\boldsymbol{u},t)

    and the mixed equality path constraint

    c(x,u,t)=0.\boldsymbol{c}(\boldsymbol{x},\boldsymbol{u},t) = \boldsymbol{0}.

    (a) Introduce a time-varying multiplier μ(t)\boldsymbol{\mu}(t) for the path constraint and construct the augmented Hamiltonian

    H=L+λTf+μTc.\overline{H} = L + \boldsymbol{\lambda}^{\mathsf T}\boldsymbol{f} + \boldsymbol{\mu}^{\mathsf T}\boldsymbol{c}.

    (b) Derive the state equation, costate equation, and control-stationarity condition in terms of H\overline{H}.

    (c) Show that variation with respect to μ(t)\boldsymbol{\mu}(t) recovers the path constraint.

    (d) Specialize the result to a control-only constraint

    c(u,t)=0.\boldsymbol{c}(\boldsymbol{u},t) = \boldsymbol{0}.

    (e) Specialize the result to a state-only constraint

    c(x,t)=0\boldsymbol{c}(\boldsymbol{x},t) = \boldsymbol{0}

    and identify the additional term in the costate equation.

  2. Inequality path constraints and complementarity

    Suppose a minimization problem contains the scalar inequality path constraint

    c(x,u,t)0.c(\boldsymbol{x},\boldsymbol{u},t) \leq 0.

    Using

    H=H+μc,\overline{H} = H+\mu c,

    derive the pointwise conditions

    c0,μ0,μc=0.c\leq0, \qquad \mu\geq0, \qquad \mu c=0.

    Then:

    (a) derive the necessary conditions on an inactive arc;

    (b) derive the necessary conditions on an active arc;

    (c) explain why the active-set structure is generally unknown in advance;

    (d) for the control bound

    u(t)umax0,u(t)-u_{\max}\leq0,

    determine the multiplier behavior when u(t)<umaxu(t)<u_{\max} and when u(t)=umaxu(t)=u_{\max};

    (e) state how the inequality would be imposed in a direct-collocation nonlinear program.

  3. Order of a state inequality constraint

    Consider the double integrator

    x˙1=x2,x˙2=u,\dot{x}_1=x_2, \qquad \dot{x}_2=u,

    with the state path constraint

    c(x)=x1xmax0.c(\boldsymbol{x}) = x_1-x_{\max} \leq 0.

    (a) Differentiate cc repeatedly along the dynamics until the control appears explicitly.

    (b) Show that the constraint has order two.

    (c) On a constrained arc, derive the tangency conditions

    x1=xmax,x2=0.x_1=x_{\max}, \qquad x_2=0.

    (d) Determine the control required to remain on the constrained arc.

    (e) State the consistency conditions that must hold at entry into the constrained arc.

    (f) Explain why enforcing x1xmaxx_1\leq x_{\max} only at collocation nodes does not guarantee continuous-time feasibility.

    (g) Formulate a dense-grid verification test for the reconstructed state trajectory.

  4. Principle of optimality and the HJB equation

    Define the optimal cost-to-go

    J(x,t)=minu()[Φ ⁣(x(tf))+ttfL(x(τ),u(τ),τ)dτ].J^*(\boldsymbol{x},t) = \min_{\boldsymbol{u}(\cdot)} \left[ \Phi\!\left(\boldsymbol{x}(t_f)\right) + \int_t^{t_f} L(\boldsymbol{x}(\tau),\boldsymbol{u}(\tau),\tau) \,\mathrm{d}\tau \right].

    Starting from Bellman’s principle of optimality over the short interval [t,t+Δt][t,t+\Delta t]:

    (a) write the dynamic-programming recursion;

    (b) expand J(x(t+Δt),t+Δt)J^*(\boldsymbol{x}(t+\Delta t),t+\Delta t) to first order;

    (c) derive the Hamilton–Jacobi–Bellman equation

    0=Jt+minu[L+xJTf];0 = J_t^* + \min_{\boldsymbol{u}} \left[ L + \nabla_{\boldsymbol{x}}J^{*\mathsf T} \boldsymbol{f} \right];

    (d) derive the terminal condition for JJ^*;

    (e) show that, along the optimal trajectory,

    dJdt=L(x,u,t);\frac{\mathrm{d}J^*}{\mathrm{d}t} = - L(\boldsymbol{x}^*,\boldsymbol{u}^*,t);

    (f) identify the relationship between the value-function gradient and the costate.

  5. Scalar HJB equation and Riccati feedback

    Consider

    x˙=2x+u\dot{x} = -2x+u

    with

    J=12x2(tf)+12ttf(x2+u2)dτ.J = \frac{1}{2}x^2(t_f) + \frac{1}{2} \int_t^{t_f} \left( x^2+u^2 \right)\,\mathrm{d}\tau.

    Assume

    J(x,t)=12P(t)x2.J^*(x,t) = \frac{1}{2}P(t)x^2.

    (a) Derive JtJ_t^* and JxJ_x^*.

    (b) Substitute the assumed value function into the HJB equation.

    (c) Minimize the HJB expression with respect to uu.

    (d) Derive the optimal feedback law.

    (e) Show that P(t)P(t) satisfies

    P˙=P2+4P1.\dot{P} = P^2+4P-1.

    (f) Show that the terminal condition is

    P(tf)=1.P(t_f)=1.

    (g) Derive the optimal closed-loop state equation.

    (h) Show that

    λ(t)=P(t)x(t).\lambda(t) = P(t)x^*(t).
  6. Matrix HJB formulation of finite-horizon LQR

    Consider

    x˙=A(t)x+B(t)u,\dot{\boldsymbol{x}} = A(t)\boldsymbol{x} + B(t)\boldsymbol{u},

    with performance index

    J=12xT(tf)Sfx(tf)+12ttf[xTQx+uTRu]dτ,J = \frac{1}{2} \boldsymbol{x}^{\mathsf T}(t_f) S_f \boldsymbol{x}(t_f) + \frac{1}{2} \int_t^{t_f} \left[ \boldsymbol{x}^{\mathsf T}Q\boldsymbol{x} + \boldsymbol{u}^{\mathsf T}R\boldsymbol{u} \right] \,\mathrm{d}\tau,

    where Q(t)=QT(t)0Q(t)=Q^{\mathsf T}(t)\succeq0 and R(t)=RT(t)0R(t)=R^{\mathsf T}(t)\succ0.

    Assume

    J(x,t)=12xTS(t)x.J^*(\boldsymbol{x},t) = \frac{1}{2} \boldsymbol{x}^{\mathsf T} S(t) \boldsymbol{x}.

    (a) Derive

    Jt=12xTS˙x.J_t^* = \frac{1}{2} \boldsymbol{x}^{\mathsf T} \dot{S} \boldsymbol{x}.

    (b) Derive the minimizing control.

    (c) Derive the Riccati differential equation

    S˙=ATS+SASBR1BTS+Q.-\dot{S} = A^{\mathsf T}S + SA - SBR^{-1}B^{\mathsf T}S + Q.

    (d) Derive the terminal condition

    S(tf)=Sf.S(t_f)=S_f.

    (e) Derive the feedback gain and the closed-loop state equation.

    (f) Show that

    λ=Sx.\boldsymbol{\lambda} = S\boldsymbol{x}^*.

    (g) Explain why the Riccati equation is integrated backward while the state equation is integrated forward.

  7. Bang–bang and singular control

    Consider

    minu()  J=01x2(t)u(t)dt\min_{u(\cdot)} \; J = \int_0^1 x_2(t)u(t)\,\mathrm{d}t

    subject to

    x˙1=x2,x˙2=x2+u,\dot{x}_1=x_2, \qquad \dot{x}_2=-x_2+u,
    0u(t)2,0\leq u(t)\leq2,

    and

    x1(0)=0,x2(0)=1,x1(1)=1,x2(1)=1.x_1(0)=0, \qquad x_2(0)=1, \qquad x_1(1)=1, \qquad x_2(1)=1.

    (a) Construct the Hamiltonian.

    (b) Derive the costate equations.

    (c) Define the switching function

    ϕ(t)=x2(t)+λ2(t).\phi(t) = x_2(t)+\lambda_2(t).

    (d) Derive the bang–bang minimization rule for ϕ>0\phi>0 and ϕ<0\phi<0.

    (e) Impose

    ϕ=ϕ˙=0\phi=\dot{\phi}=0

    on a candidate singular arc.

    (f) Derive the singular control.

    (g) Verify that the singular state and control satisfy all endpoint conditions.

    (h) Determine the order of the singular arc and state the corresponding generalized Legendre–Clebsch check.

  8. Analytical direct shooting for the minimum-energy double integrator

    Consider

    minu()  J=120Tu2(t)dt\min_{u(\cdot)} \; J = \frac{1}{2} \int_0^T u^2(t)\,\mathrm{d}t

    subject to

    x˙1=x2,x˙2=u,\dot{x}_1=x_2, \qquad \dot{x}_2=u,

    with fixed endpoint data

    x1(0)=a0,x2(0)=v0,x1(T)=af,x2(T)=vf.x_1(0)=a_0, \qquad x_2(0)=v_0, \qquad x_1(T)=a_f, \qquad x_2(T)=v_f.

    (a) Derive the Hamiltonian and costate equations.

    (b) Show that λ1\lambda_1 is constant and λ2\lambda_2 is affine in time.

    (c) Derive the optimal control as an affine function of time.

    (d) Integrate the state equations analytically.

    (e) Reduce the terminal conditions to a 2×22\times2 linear system for the two unknown initial costates.

    (f) Solve this system explicitly.

    (g) Explain why the original infinite-dimensional problem has been reduced to a finite-dimensional shooting problem.

  9. General neighboring-optimal-control derivation

    Let (x,u,λ)(\boldsymbol{x}^*,\boldsymbol{u}^*,\boldsymbol{\lambda}^*) be a nominal nonlinear optimal trajectory. Define

    δx=xx,δu=uu,δλ=λλ.\delta\boldsymbol{x} = \boldsymbol{x}-\boldsymbol{x}^*, \qquad \delta\boldsymbol{u} = \boldsymbol{u}-\boldsymbol{u}^*, \qquad \delta\boldsymbol{\lambda} = \boldsymbol{\lambda}-\boldsymbol{\lambda}^*.

    Assume the neighboring dynamics and second-order cost are

    δx˙=F(t)δx+G(t)δu,\delta\dot{\boldsymbol{x}} = F(t)\delta\boldsymbol{x} + G(t)\delta\boldsymbol{u},
    δ2J=12δxT(tf)Pfδx(tf)+12t0tf[δxTQδx+2δxTMδu+δuTRδu]dt.\delta^2J = \frac{1}{2} \delta\boldsymbol{x}^{\mathsf T}(t_f) P_f \delta\boldsymbol{x}(t_f) + \frac{1}{2} \int_{t_0}^{t_f} \left[ \delta\boldsymbol{x}^{\mathsf T}Q\delta\boldsymbol{x} + 2\delta\boldsymbol{x}^{\mathsf T}M\delta\boldsymbol{u} + \delta\boldsymbol{u}^{\mathsf T}R\delta\boldsymbol{u} \right] \,\mathrm{d}t.

    (a) Construct the neighboring Hamiltonian.

    (b) Derive the neighboring costate equation.

    (c) Derive the stationarity condition.

    (d) Show that

    δu=R1(MTδx+GTδλ).\delta\boldsymbol{u} = - R^{-1} \left( M^{\mathsf T}\delta\boldsymbol{x} + G^{\mathsf T}\delta\boldsymbol{\lambda} \right).

    (e) Assume

    δλ=P(t)δx\delta\boldsymbol{\lambda} = P(t)\delta\boldsymbol{x}

    and derive the generalized Riccati equation.

    (f) Show that

    P(tf)=Pf.P(t_f)=P_f.

    (g) Derive the neighboring feedback gain

    K(t)=R1(MT+GTP).K(t) = R^{-1} \left( M^{\mathsf T} + G^{\mathsf T}P \right).

    (h) Show that the standard time-varying LQR Riccati equation is recovered when M=0M=\boldsymbol{0}.

  10. Neighboring feedback for a nonlinear scalar system

    Consider the nonlinear dynamics

    x˙=x+x2+u\dot{x} = x+x^2+u

    and the nominal trajectory

    x(t)=0,u(t)=0.x^*(t)=0, \qquad u^*(t)=0.

    The neighboring cost is

    δ2J=12pfδx2(tf)+120tf(qδx2+2mδxδu+rδu2)dt,\delta^2J = \frac{1}{2}p_f\delta x^2(t_f) + \frac{1}{2} \int_0^{t_f} \left( q\delta x^2 + 2m\delta x\,\delta u + r\delta u^2 \right) \,\mathrm{d}t,

    with r>0r>0.

    (a) Linearize the dynamics about the nominal trajectory and identify FF and GG.

    (b) Derive the scalar neighboring Riccati equation.

    (c) Derive the feedback gain

    K(t)=m+GP(t)r.K(t) = \frac{m+G P(t)}{r}.

    (d) Write the neighboring correction

    δu(t)=K(t)δx(t).\delta u(t) = -K(t)\delta x(t).

    (e) Write the complete implemented control u=u+δuu=u^*+\delta u.

    (f) Show that the correction is zero on the nominal trajectory.

    (g) Describe a numerical test using several initial perturbation magnitudes.

    (h) State the residuals and qualitative behaviors that should be checked to determine when the neighboring approximation is no longer reliable.