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.

Bang–Bang Control, Switching Functions, and Singular Arcs

This section revisits a bounded-control optimal control problem whose Hamiltonian is linear in the control. Such problems commonly produce bang-bang control, singular control, or combinations of both.

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,\begin{aligned} \dot{x}_1 &= x_2,\\ \dot{x}_2 &= -x_2+u, \end{aligned}

with

0u(t)2,0\leq u(t)\leq 2,

and boundary conditions

x1(0)=0,x2(0)=1,x1(1)=1,x2(1)=1.\begin{aligned} x_1(0)&=0, & x_2(0)&=1,\\ x_1(1)&=1, & x_2(1)&=1. \end{aligned}

Hamiltonian

The Hamiltonian is

H=x2u+λ1x2+λ2(x2+u)=(x2+λ2)u+(λ1λ2)x2.\begin{aligned} \mathcal{H} &= x_2u + \lambda_1x_2 + \lambda_2(-x_2+u)\\ &= (x_2+\lambda_2)u + (\lambda_1-\lambda_2)x_2. \end{aligned}

Thus,

H=ϕ(t)u+(λ1λ2)x2,\boxed{ \mathcal{H} = \phi(t)u + (\lambda_1-\lambda_2)x_2, }

where

ϕ(t)=x2(t)+λ2(t)\boxed{ \phi(t) = x_2(t)+\lambda_2(t) }

is the switching function.

Bang-Bang Minimization Rule

Because the Hamiltonian is affine in uu,

u=argmin0u2H.u^* = \arg\min_{0\leq u\leq 2}\mathcal{H}.

Therefore,

u(t)={0,ϕ(t)>0,2,ϕ(t)<0,undetermined by first-order minimization,ϕ(t)=0.\boxed{ u^*(t) = \begin{cases} 0, & \phi(t)>0,\\ 2, & \phi(t)<0,\\ \text{undetermined by first-order minimization}, & \phi(t)=0. \end{cases} }

The case ϕ=0\phi=0 is the candidate singular case.

Costate Equations

The costate equations are

λ˙1=Hx1=0,λ˙2=Hx2.\begin{aligned} \dot{\lambda}_1 &= -\frac{\partial \mathcal{H}}{\partial x_1} = 0,\\ \dot{\lambda}_2 &= -\frac{\partial \mathcal{H}}{\partial x_2}. \end{aligned}

Since

Hx2=u+λ1λ2,\frac{\partial \mathcal{H}}{\partial x_2} = u+\lambda_1-\lambda_2,

we obtain

λ˙2=uλ1+λ2.\boxed{ \dot{\lambda}_2 = -u-\lambda_1+\lambda_2. }

Also,

λ1=constant.\boxed{ \lambda_1=\text{constant}. }

Testing Constant Bang Controls

Before pursuing a singular arc, one should test whether u=0u=0 or u=2u=2 over the entire interval can satisfy the boundary conditions.

Case u=0u=0

Then

x˙2=x2,\dot{x}_2=-x_2,

so

x2(t)=et.x_2(t)=e^{-t}.

Thus,

x2(1)=e11.x_2(1)=e^{-1}\neq 1.

Therefore, u=0u=0 over the full interval is infeasible.

Case u=2u=2

Then

x˙2=x2+2.\dot{x}_2=-x_2+2.

With x2(0)=1x_2(0)=1,

x2(t)=2et.x_2(t)=2-e^{-t}.

Hence,

x2(1)=2e11.x_2(1)=2-e^{-1}\neq 1.

Therefore, u=2u=2 over the full interval is also infeasible.

Singular-Arc Condition

On a singular arc,

ϕ(t)=x2(t)+λ2(t)=0.\boxed{ \phi(t) = x_2(t)+\lambda_2(t) = 0. }

Therefore,

λ2=x2.\lambda_2=-x_2.

Differentiating,

ϕ˙=x˙2+λ˙2.\dot{\phi} = \dot{x}_2+\dot{\lambda}_2.

Using

x˙2=x2+u,λ˙2=uλ1+λ2,\begin{aligned} \dot{x}_2&=-x_2+u,\\ \dot{\lambda}_2&=-u-\lambda_1+\lambda_2, \end{aligned}

we obtain

ϕ˙=(x2+u)+(uλ1+λ2)=x2λ1+λ2.\begin{aligned} \dot{\phi} &= (-x_2+u) + (-u-\lambda_1+\lambda_2)\\ &= -x_2-\lambda_1+\lambda_2. \end{aligned}

On the singular arc, λ2=x2\lambda_2=-x_2, so

ϕ˙=2x2λ1.\dot{\phi} = -2x_2-\lambda_1.

Hence,

2x2+λ1=0.\boxed{ 2x_2+\lambda_1=0. }

Therefore,

x2=λ12.x_2 = -\frac{\lambda_1}{2}.

Because λ1\lambda_1 is constant, x2x_2 is constant on the singular arc.

Determination of the Singular Control

Since x2x_2 is constant,

x˙2=0.\dot{x}_2=0.

Using the state equation,

0=x2+u.0=-x_2+u.

Thus,

using=x2.\boxed{ u_{\mathrm{sing}}=x_2. }

The boundary conditions require

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

Therefore, the constant singular state is

x2(t)=1.x_2(t)=1.

Hence,

u(t)=1for 0t1.\boxed{ u^*(t)=1 \qquad \text{for }0\leq t\leq1. }

Verification of the State Trajectory

With u=1u=1,

x˙2=x2+1.\dot{x}_2=-x_2+1.

Since x2(0)=1x_2(0)=1,

x2(t)=1.x_2(t)=1.

Then

x˙1=x2=1.\dot{x}_1=x_2=1.

With x1(0)=0x_1(0)=0,

x1(t)=t.x_1(t)=t.

Therefore,

x1(1)=1,x2(1)=1.\begin{aligned} x_1(1)&=1,\\ x_2(1)&=1. \end{aligned}

All boundary conditions are satisfied.

Costate Values

From

2x2+λ1=02x_2+\lambda_1=0

and x2=1x_2=1,

λ1=2.\boxed{ \lambda_1=-2. }

Since

λ2=x2,\lambda_2=-x_2,

we obtain

λ2=1.\boxed{ \lambda_2=-1. }

These values satisfy

λ˙2=uλ1+λ2=1(2)1=0.\dot{\lambda}_2 = -u-\lambda_1+\lambda_2 = -1-(-2)-1 = 0.

Hamiltonian along the Singular Arc

The Hamiltonian is

H=x2u+λ1x2+λ2(x2+u).\mathcal{H} = x_2u + \lambda_1x_2 + \lambda_2(-x_2+u).

Using

x2=1,u=1,λ1=2,λ2=1,x_2=1,\quad u=1,\quad \lambda_1=-2,\quad \lambda_2=-1,

we obtain

H=12+0=1.\mathcal{H} = 1-2+0 = -1.

Thus, the Hamiltonian is constant, as expected for an autonomous fixed-final-time problem.

Order of the Singular Arc

The control does not appear explicitly in

ϕ=x2+λ2.\phi=x_2+\lambda_2.

It also cancels from

ϕ˙.\dot{\phi}.

The control appears when enforcing constancy of x2x_2, or equivalently in the next derivative of the switching function.

Differentiate

ϕ˙=2x2λ1.\dot{\phi} = -2x_2-\lambda_1.

Since λ1\lambda_1 is constant,

ϕ¨=2x˙2=2(x2+u).\ddot{\phi} = -2\dot{x}_2 = -2(-x_2+u).

On the singular arc,

ϕ¨=0,\ddot{\phi}=0,

so

u=x2.u=x_2.

The control appears in the second derivative of the switching function.

Generalized Legendre–Clebsch Check

For a minimization problem, a singular arc must satisfy an appropriate generalized Legendre–Clebsch condition.

Here,

ϕ¨=2x22u.\ddot{\phi} = 2x_2-2u.

Therefore,

ϕ¨u=2.\frac{\partial \ddot{\phi}}{\partial u} = -2.

Using the common sign convention for a first-order singular arc,

(1)1ϕ¨u=2>0.(-1)^1 \frac{\partial \ddot{\phi}}{\partial u} = 2>0.

Thus, the singular control is consistent with local minimization.

Why Pure Bang-Bang Reasoning Is Insufficient

A common error is to conclude that a Hamiltonian linear in the control always implies bang-bang control.

The correct statement is:

In this problem, the entire feasible optimal solution lies on the singular arc.

Alternative Direct Verification

Because the dynamics imply

u=x˙2+x2,u=\dot{x}_2+x_2,

the cost becomes

J=01x2(x˙2+x2)dt=01x2x˙2dt+01x22dt.\begin{aligned} J &= \int_0^1 x_2(\dot{x}_2+x_2)\,\mathrm{d} t\\ &= \int_0^1 x_2\dot{x}_2\,\mathrm{d} t + \int_0^1 x_2^2\,\mathrm{d} t. \end{aligned}

The first term is

01x2x˙2dt=12[x22(1)x22(0)]=0.\int_0^1 x_2\dot{x}_2\,\mathrm{d} t = \frac{1}{2} \left[ x_2^2(1)-x_2^2(0) \right] = 0.

Hence,

J=01x22(t)dt.J = \int_0^1x_2^2(t)\,\mathrm{d} t.

Also,

x1(1)x1(0)=01x2(t)dt=1.x_1(1)-x_1(0) = \int_0^1x_2(t)\,\mathrm{d} t = 1.

By Cauchy–Schwarz,

(01x2(t)dt)2(0112dt)(01x22(t)dt).\left( \int_0^1x_2(t)\,\mathrm{d} t \right)^2 \leq \left( \int_0^1 1^2\,\mathrm{d} t \right) \left( \int_0^1x_2^2(t)\,\mathrm{d} t \right).

Therefore,

1J.1\leq J.

Equality occurs only when x2(t)x_2(t) is constant. Since its average is one,

x2(t)=1.x_2(t)=1.

Therefore,

u(t)=1.u(t)=1.

This provides an independent global-optimality argument.

Optimal Cost

Using

x2=1,u=1,x_2=1, \qquad u=1,

the optimal cost is

J=011dt=1.\boxed{ J^* = \int_0^1 1\,\mathrm{d} t = 1. }

Numerical Verification in MATLAB

function verify_session31_part2

    tspan = [0 1];
    x0 = [0;1];

    u = @(t) 1;

    dyn = @(t,x) [x(2); -x(2)+u(t)];

    [t,x] = ode45(dyn,tspan,x0);

    J = trapz(t,x(:,2).*arrayfun(u,t));

    fprintf('x1(tf) = %.12f\n',x(end,1));
    fprintf('x2(tf) = %.12f\n',x(end,2));
    fprintf('J       = %.12f\n',J);

    figure;
    plot(t,x,'LineWidth',1.5);
    xlabel('Time');
    ylabel('State');
    legend('x_1','x_2');
    grid on;
end
  1. Form the Hamiltonian.

  2. Identify the switching function.

  3. Determine the bang controls from its sign.

  4. Test whether constant bang arcs satisfy the boundary conditions.

  5. Set the switching function equal to zero for a singular arc.

  6. Differentiate until the control appears explicitly.

  7. Solve for the singular control.

  8. Verify the control bounds.

  9. Verify state and costate equations.

  10. Check Hamiltonian constancy.

  11. Verify second-order singular optimality conditions.

Common Errors

Summary

  1. The Hamiltonian is affine in the control.

  2. The switching function is ϕ=x2+λ2\phi=x_2+\lambda_2.

  3. The bang controls are u=0u=0 and u=2u=2.

  4. Neither constant bang control satisfies the terminal conditions.

  5. A singular arc satisfies ϕ=0\phi=0.

  6. Differentiation yields x2=λ1/2x_2=-\lambda_1/2.

  7. Since λ1\lambda_1 is constant, x2x_2 is constant.

  8. The state equation gives u=x2u=x_2.

  9. Boundary conditions imply x2=1x_2=1.

  10. Therefore, u=1u^*=1 over the entire interval.

  11. The optimal state is x1=tx_1=t, x2=1x_2=1.

  12. The optimal cost is J=1J^*=1.

Connection. Finally, neighboring optimal control uses local sensitivity information to correct a nominal solution without resolving the full nonlinear problem after every disturbance.