Docsity

Mechatronics_A_Q&A_2025_2026, Appunti di Meccatronica

Toggle sidebar
bg1
MECHATRONICS Q & A
Possible oral questions
Matteo Cristofolini
A.y. 2025/2026
Contents
1 NLP, CoV and OC 3
1.1 KKTConditions ........................................... 3
1.2 Why OCP is more general than CoV? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.3 Difference between Lagrangian and Hamiltonian (OC) . . . . . . . . . . . . . . . . . . . . . . 4
1.4 1st Order Necessary condition: Euler-Lagrangian equations (CoV) . . . . . . . . . . . . . . . 5
1.5 2nd Order Necessary Conditions: Legendre equation (CoV) . . . . . . . . . . . . . . . . . . . 6
1.6 MinimumTimeproblem(OC) ................................... 7
1.7 1st Order Necessary Conditions: fixed-end time (OC) . . . . . . . . . . . . . . . . . . . . . . . 8
1.8 1st Order Necessary Conditions: open-end time (OC) . . . . . . . . . . . . . . . . . . . . . . . 9
1.9 2nd Order Necessary Conditions: Legendre-Clebsch equations (OC) . . . . . . . . . . . . . . . 11
1.10 How to deal with control input saturation? (OC) . . . . . . . . . . . . . . . . . . . . . . . . . 11
1.11 Terminal state equality constraints (OC) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
1.12 Equality constraints on control and state (OC) . . . . . . . . . . . . . . . . . . . . . . . . . . 14
1.13 Inequality constraints on state and control (OC) . . . . . . . . . . . . . . . . . . . . . . . . . 15
2 Dynamic Programming (DP) 18
2.1 Principle of Optimality and traveller problem . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
2.2 TheCurseofDimensionality .................................... 19
2.3 DP in classical OC - computation of u in particular cases . . . . . . . . . . . . . . . . . . . . 20
2.4 1st Order Sufficient condition: Hamilton-Jacobi-Bellman equations (DP) . . . . . . . . . . . 21
2.5 Pontryagin Maximum Principle - free end-time, fixed end-point . . . . . . . . . . . . . . . . . 23
2.6 Pontryagin Maximum Principle - fixed end-time, free end-point . . . . . . . . . . . . . . . . . 24
2.7 Differences between PMP and Principle of Optimality (DP) . . . . . . . . . . . . . . . . . . . 25
3 Numerical methods 26
3.1 Summary table and main differences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
3.2 Differences between direct and indirect methods . . . . . . . . . . . . . . . . . . . . . . . . . . 26
3.3 Collocationmethods ......................................... 27
3.4 Shootingmethods .......................................... 30
3.5 How to deal with constraints and how to implement them in numerical methods . . . . . . . 32
3.6 How to deal with input saturation in numerical methods . . . . . . . . . . . . . . . . . . . . . 32
3.7 SteepestDescentMethod ...................................... 33
4 LQR 34
4.1 Perturbedtrajectory......................................... 34
4.2 LQR - necessary condition (EL approach) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
4.3 LQR - sufficient condition (HJB approach) . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
4.4 How does a LQR work in practise? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
4.5 SummaryofLQR........................................... 39
4.6 StabilityofLQR ........................................... 40
4.7 Steady-stateLQR .......................................... 41
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c

Anteprima parziale del testo

Scarica Mechatronics_A_Q&A_2025_2026 e più Appunti in PDF di Meccatronica solo su Docsity!

MECHATRONICS Q & A

Possible oral questions

- A.y. 2025/ Matteo Cristofolini
  • 1 NLP, CoV and OC Contents
    • 1.1 KKT Conditions
    • 1.2 Why OCP is more general than CoV?
    • 1.3 Difference between Lagrangian and Hamiltonian (OC)
    • 1.4 1 st Order Necessary condition: Euler-Lagrangian equations (CoV)
    • 1.5 2 nd Order Necessary Conditions: Legendre equation (CoV)
    • 1.6 Minimum Time problem (OC)
    • 1.7 1 st Order Necessary Conditions: fixed-end time (OC)
    • 1.8 1 st Order Necessary Conditions: open-end time (OC)
    • 1.9 2 nd Order Necessary Conditions: Legendre-Clebsch equations (OC)
    • 1.10 How to deal with control input saturation? (OC)
    • 1.11 Terminal state equality constraints (OC)
    • 1.12 Equality constraints on control and state (OC)
    • 1.13 Inequality constraints on state and control (OC)
  • 2 Dynamic Programming (DP)
    • 2.1 Principle of Optimality and traveller problem
    • 2.2 The Curse of Dimensionality
    • 2.3 DP in classical OC - computation of u in particular cases
    • 2.4 1 st Order Sufficient condition: Hamilton-Jacobi-Bellman equations (DP)
    • 2.5 Pontryagin Maximum Principle - free end-time, fixed end-point
    • 2.6 Pontryagin Maximum Principle - fixed end-time, free end-point
    • 2.7 Differences between PMP and Principle of Optimality (DP)
  • 3 Numerical methods
    • 3.1 Summary table and main differences
    • 3.2 Differences between direct and indirect methods
    • 3.3 Collocation methods
    • 3.4 Shooting methods
    • 3.5 How to deal with constraints and how to implement them in numerical methods
    • 3.6 How to deal with input saturation in numerical methods
    • 3.7 Steepest Descent Method
  • 4 LQR
    • 4.1 Perturbed trajectory
    • 4.2 LQR - necessary condition (EL approach)
    • 4.3 LQR - sufficient condition (HJB approach)
    • 4.4 How does a LQR work in practise?
    • 4.5 Summary of LQR
    • 4.6 Stability of LQR
    • 4.7 Steady-state LQR
  • 5 State estimate - Kalman filtering
    • 5.1 Least square minimization
    • 5.2 Discrete-time Kalman filter
    • 5.3 Why is P 0 not set to 0?
    • 5.4 How many states can the KF estimate?
    • 5.5 Alternative formulation - KF
    • 5.6 KF - correlated process
    • 5.7 KF - coloured measurement noise
    • 5.8 Summary - KF generalization
    • 5.9 Continuous-time Kalman filter: KBF
    • 5.10 Duality between LQR (optimal controller) and KBF (optimal observer)
    • 5.11 How could be the covariance matrices of noises estimated
    • 5.12 Linearized KBF - LKBF
    • 5.13 Neighboring optimal estimator- Pro & Cons
    • 5.14 Extended KF - EKF
    • 5.15 EKF - Parameter estimation and 1DoF system example
    • 5.16 EKF Matlab implementation
    • 5.17 KF vs EKF
    • 5.18 NOE vs EKF
    • 5.19 Unscented KF - UKF
    • 5.20 UKF - parameter estimation
    • 5.21 EKF vs UKF
    • 5.22 Particle Filter
    • 5.23 Choice of filters
  • 6 Stochastic control - LQG
    • 6.1 What is an LQG?
    • 6.2 Why can we do decoupling? Separation and certainty equivalence principles
    • 6.3 Central limit theorem
  • 7 World of Control
    • 7.1 Bang-Bang control
    • 7.2 Gain Scheduling
    • 7.3 Feedback linearization
    • 7.4 Variable Structure Control - Sliding Mode Control
    • 7.5 Adaptive control
    • 7.6 Fuzzy logic control
  • 8 MPC
    • 8.1 MPC no constraints & no reference
    • 8.2 MPC constraints & no reference
    • 8.3 MPC constraints & reference
    • 8.4 In MPC can you compute control action u? Why?
    • 8.5 MPC - Pro & Cons

1.2 Why OCP is more general than CoV?

Calculus of Variations: in CoV one seeks a function f (x∗) that minimizes (or maximizes) an integral cost (functional) subject to different constraints. The focus is on continuous function spaces and smooth variations. It represents a special case of the Optimal Control Problem, in which the dynamics is simplified.

F^ ˜ [x] =

Z (^) t 2

t 1

f (x(t), x˙(t), t) + λ(t)T^ g(x(t), x˙(t), t)

dt (2)

where: g(x(t), x˙(t), t) : Rn^ × Rn^ × [ti, tf ] 7 → Rm^ (m ≤ n)

We seek optimum extremal x∗(t) : [ti, tf ] 7 → Rn^ and Lagrange multipliers λ∗(t) : [ti, tf ] 7 → Rm.

Optimal Control: it expands the framework by treating both state evolution x and control inputs u as independent variables, as control functions directly influence system dynamics. It enforces dynamical constraints through costate variables (Lagrange multipliers), leading to a Hamiltonian formulation that unifies dynamics and cost.

J^ ˜[u] = ϕ(x(tf ), tf ) +

Z (^) tf

ti

n L(x(t), u(t), t) + λT^ (t)[f (x(t), u(t), t) − x˙(t)]

o dt (3)

with: g(x(t), u(t), x˙(t), t) = f (x(t), u(t), t) − x˙(t) = 0

The unknown is u(t) : [ti, tf ] 7 → Rm^ and must be found in a continuous and piecewise differentiable space to ensure that the control action allows for consistent state evolution over time without introducing abrupt discontinuities. Piecewise differentiability also accommodates practical scenarios where control values may change behavior abruptly (for example Bang-Bang controls). ϕ(x(tf ), tf ) is the terminal cost and takes in account penalties to quantify how far you ended up from your target, while R (^) tf ti

n L(x(t), u(t), t) + λT^ (t)[f (x(t), u(t), t) − x˙(t)]

o dt is called integral cost and takes in account penalties

throughout all the path (i.e. loss of efficiency).

1.3 Difference between Lagrangian and Hamiltonian (OC)

The general formulation of a functional for an optimum control problem, including the Hamiltonian H, is the following one:

J[u] = ϕ(x(tf ), tf ) +

Z (^) tf

ti

Lagrangian L z }| { L(x(t), u(t), t) +λ⊤(t)[f (x(t), u(t), t) | {z } Hamiltonian H

− x˙(t)]dt

  • x(t) is a vector in Rn.
  • λ(t) is a vector in Rn
  • u(t) is a vector in Rm^ with m < n to avoid an overconstrained problem
  • f (x, u, t) is a vector in Rn
  • L(x, u, t) is generally a time-dependent scalar function

Given this, we have that λ⊤f is scalar, therefore H(x, u, λ, t) is itself generally a time-dependent scalar function. But there are exceptions:

  • L may also remain constant if it does not explicitly depend on x, u, or t. This might occur in cases where the cost is purely time-independent and uniform over the trajectory (e.g., minimum time problems where L = 1).
  • H can remain constant along an optimal trajectory if L and f (system dynamics) are independent of time (autonomous system).
  • In free-final-time problems where the terminal time tf is also optimized, and the terminal cost ϕ(x(t)) does not explicitly depend on t, H can be equal to zero.

The Lagrangian is typically the integrand of the cost functional. It represents the instantaneous cost or performance measure at each point in time. As said, the Lagrangian is scalar and varies depending on the problem formulation. Moreover, Lagrangian is related to an "energetical method" of optimality: it defines the best path in case of a free system (best theoretical scenario) and doesn’t take in account all the constraints and the physics of the real world.

The Hamiltonian combines the Lagrangian and the system dynamics. It incorporates the adjoint variables (costate variables) λ, which are introduced to enforce the system’s dynamics as constraints. The Hamiltonian is also scalar. For this reason, the Hamiltonian can define the best path accounting the physics of the external environment (best bounded scenario, related to a "geometrical approach").

1.4 1 st^ Order Necessary condition: Euler-Lagrangian equations (CoV)

Hypotheses:

  • Cost functional defined as: F [x] =

Z (^) t 2

t 1

f (x(t), x˙(t), t) dt (4)

  • The solution function x*(t) satisfies the Euler-Lagrange equations (n scalar equations):

∂f ∂x

d dt

∂f ∂ x˙

Thesis: The solution function x*(t) is an extremal of functional F[x] with boundaries on x(t 1 ) and x(t 2 ). (hence, it minimizes the functional).

PROOF:

  1. Assume x*(t) is an extremum of F[x]
  2. Consider a small variation in neighborhood of x*(t):

x(t) = x∗(t) + α ξ(t) (6)

The cost functional evaluated along x is:

F [x] = F [x 0 + α ξ] (7)

If x 0 and ξ are fixed: F [x] = F [x∗^ + αξ] ≡ g(α) (8)

  1. Let’s expand g(α) in Taylor series around α = 0 (nominal trajectory):

g(α) = g(0) +

dg dα (^0)

α + o(α) (9)

  1. Since x∗^ is an extremum, for NLP problems (sufficient condition), the first variation of F must be 0 ∀ξ. Let’s compute the 1 st^ variation:

F [x(t)∗^ + αξ(t)] =

Z (^) t 2

t 1

f (x(t)∗^ + αξ(t), x˙(t)∗^ + α ξ˙(t), t) dt (10)

d dα

F [x(t)∗^ + αξ(t)] 0

d dα

Z (^) t 2

t 1

f (x∗(t) + αξ(t), x˙∗(t) + α ξ˙(t), t) dt 0

The 2 nd^ order NECESSARY condition holds:

δ^2 Fx∗^ [ξ] =

d^2 g dα^2

To satisfy it, the matrix defining the quadratic term in ξ˙ must be positive semi-definite at each time instant (Legendre Condition):

P(x∗(t), x˙∗(t), t) =

∂^2 f ∂ x˙^2

(x∗(t), x˙∗(t), t) = f (^) x˙ x˙ ⪰ 0 (24)

NOTICE: Legendre condition is only a necessary local condition for optimality; it can becomes sufficient only if the problem is convex. If convex:

  • Any LOCAL minimizer x* is a GLOBAL minimizer of f.
  • If, in addition, f is differentiable, then any stationary point x* is a GLOBAL minimizer of f.

Most of the problems can be simply solved with necessary conditions as long as the knowledge of the problem is enough to guarantee optimality (I must know the physics of the problem).

NOTICE 2: Using the 1st and 2nd necessary conditions, we perform a second-order Taylor expansion around the point of interest. This expansion captures only the local behavior of the function—focusing on its imme- diate slope and curvature—while neglecting higher-order terms that describe its overall (global) structure. As a result, these conditions identify candidate points that are locally optimal. However, to confirm that a candidate is truly the global optimum, additional sufficient conditions must also be satisfied. Necessary conditions identify local candidate points; they must be satisfied at any extremum (local or global) but don’t by themselves ensure global optimality. Sufficient conditions (especially when additional structure like convexity is present) guarantee that the candidate is indeed optimal on a global scale.

1.6 Minimum Time problem (OC)

Is a typical case of Optimal control problem. Generic form of cost function (OC problem with constraints):

J[u] = ϕ(x(t 1 ), t 1 ) +

Z (^) t 1

t 0

L(x, u, t) + λT^ (t) · [f (x, u, t) − x˙(t)]

dt (25)

= ϕ(x(t 1 ), t 1 ) +

Z (^) t 1

t 0

H(x, u, t, λ) dt −

Z (^) t 1

t 0

λT^ (t) ˙x(t) dt (26)

The cost functional in this case holds (with free-end time):

J[u] =

Z (^) t 1

t 0

1 dt = t 1 − t 0 (27)

We exploit the Pontryagin Maximum Principle and, for example, in a simple system which the control action on acceleration is bounded (− 1 ≤ u ≤ 1):

  • Dynamics: I have a system with x˙ 1 = x 2 (velocity) and x˙ 2 = u (acceleration)
  • Hamiltonian: we couple in the Hamiltonian the cost and the dynamics, using the adjoint vector λ: H = λ 1 x 2 + λ 2 u + 1 =⇒ H∗^ = min |u|≤ 1

{λ∗ 1 (t)x∗ 2 (t) + λ∗ 2 (t)u + 1} (28)

Since we want to minimize the terms linked to the control action: u∗(t) = arg min |u|≤ 1

{λ∗ 1 (t)x∗ 2 (t) + λ∗ 2 (t)u + 1} = arg min |u|≤ 1

{λ∗ 2 (t)u} (29)

u∗(t) =

1 if λ∗ 2 (t) < 0 − 1 if λ∗ 2 (t) > 0 ? if λ∗ 2 (t) = 0 (hp. u∗(t) = 1)

=⇒ u∗(t) = −sign(λ∗ 2 (t)) (30)

In time–optimal problems, the control u∗(t) is typically “Bang-Bang,” meaning it alternates between its maximum and minimum allowable values. The switching structure is determined by the sign of the switching function λ∗ 2 (t).

1.7 1 st^ Order Necessary Conditions: fixed-end time (OC)

Assumption: the optimal control input u(t) we’re searching for will lead to generate the optimal trajectory x(t), which is the solution of x˙(t) = f (x(t), u(t), t).

  1. Let’s consider a control input variation: u(t) = u∗(t) + αω(t)
  2. This input generates a perturbation of the optimal trajectory as: x(t) = x∗(t) + αξ(t)
  3. x(t) must be a solution of the differential equation describing the dynamical system:

x ˙∗(t) + α ξ˙(t) = f (x∗(t) + αξ(t), u∗(t) + αω(t), t) (31)

  1. Let’s expand the RHS term up to 1st-order in α:

f (x∗^ + αξ, u∗^ + αω, t) = f (x∗, u∗, t) +

∂f (x∗, u∗, t) ∂x ξ |{z} ( d dαx )

∂f (x∗, u∗, t) ∂u |{z}ω ( d dαu )

α (32)

  1. x˙∗(t) = f (x∗(t), u∗(t), t) → it’s possible to derive a differential eq. for ξ(t) if we rewrite small orders:

f^ (·) +^ α^ ξ˙(t) = ^ f^ (x

∗, u∗, t) +

∂f (x∗, u∗, t) ∂x

ξ +

∂f (x∗, u∗, t) ∂u

ω

α =⇒ (33)

ξ^ ˙(t) = ∂f^ (x

∗(t), u∗(t), t) ∂x

ξ(t) + ∂f (x∗(t), u∗(t), t) ∂u

ω(t) (34)

ξ(t 0 ) = 0 := initial condition due to x(t 0 ) = x∗(t 0 ) = x 0 (no perturb.)

NOTICE: This differential eq. describes the evolution of linearized system around the optimal trajectory. The Jacobians computed at optimal trajectory are time-varying matrices.

  1. The Linear-Time Varying (LTV) system is:

( ξ˙(t) = [A(t)]∗ξ(t) + [B(t)]∗ω(t) ξ(t 0 ) = 0

knowing ω(t), this system allows to deter- mine ξ(t) and so x(t) (it says where pertur- bation is going on).

  1. Let’s compute the 1 st^ variation of the augmented cost functional around optimal control input:

δJu∗ [ω] =

d dα (^0)

J[u∗^ + αω] (36)

u∗^ affects x∗, so we have also x = x∗^ + αξ:

J[u∗^ + αω] = ϕ(x(t 1 )∗^ + αξ(t 1 ), t 1 ) | {z } ○^1

Z (^) t 1

t 0

H(x∗^ + αξ, u∗^ + αω, λ(t), t) | {z } ○^2

dt+

Z (^) t 1

t 0

λ^ ˙T^ (t)[x∗^ + αξ] | {z } ○^3

dt + λT^ (t 0 )[x∗(t 0 ) + αξ(t 0 )] − λT^ (t 1 )[x∗(t 1 ) + αξ(t 1 )] | {z } ○^4

Carrying out derivatives term by term:

d dα (^) ∗

ϕ(x(t 1 )∗^ + αξ(t 1 ), t 1 ) = ∂ϕ(x∗(t 1 ) + αξ(t 1 ), t 1 ) ∂x

∂x ∂α (^) t 1 | {z } =ξ(t 1 )

d dα (^) ∗

Z (^) t 1

t 0

H(x∗^ + αξ, u + αω, λ(t), t) dt =

Z (^) t 1

t 0

∂H(x∗(t), u∗(t), t) ∂x

ξ(t) +

∂H(x∗(t), u∗(t), t) ∂u

ω(t)

dt (38)

In 1 st^ variation evaluation we expect to find an additional necessary conditon to find t∗ 1.

  1. Add equation of motion to the cost functional, obtaining an augmented cost functional. The equation of motions are written as equality constraints:

J[u] = ϕ(x(t 1 ), t 1 ) +

Z (^) t 1

t 0

L(x(t), u(t), t) + λT^ (t)[f (x(t), u(t), t) − x˙(t)]dt (47)

  1. Evaluate the augmented cost functional along perturbed curves, by applying initial conditions ξ(x 0 ) = 0 :

J[u∗^ + αω] = ϕ(x(t∗ 1 + ατ )∗, t∗ 1 + ατ )+

Z (^) t∗ 1 +ατ

t 0

H(x(t)∗^ + αξ(t), u(t)∗^ + αω(t), λ(t), t) dt+

Z (^) t∗ 1 +ατ

t 0

λ^ ˙(t)T^ [x(t)∗^ + αξ(t)] dt+

  • λ(t 0 )T^ x(t 0 ) − λ(t∗ 1 + ατ )T^ [x(t∗ 1 + ατ )∗^ + αξ(t∗ 1 + ατ )]

NOTICE: the 3 rd^ and the 4 th^ term derive from integration by parts of the

R (^) t 1 t 0 λ

T (^) x˙ term.

  1. Searching the set of 1 st-order necessary conditions =⇒ we obtain them by imposing the first variation of the augmented cost function equal to 0:

δJu∗^ [ω] =

d dα (^) ∗ J[u∗^ + αω] (49)

Term ○ 1 : Final Cost ϕ(x(t 1 ), t 1 ) Using the chain rule, we account for both the change in state and the change in the final time:

d dα (^) ∗

ϕ(x(t 1 ), t 1 ) = ∂ϕ ∂x

( ˙x∗(t∗ 1 )τ + ξ(t∗ 1 )) + ∂ϕ ∂t

τ (50)

Term ○^2 : Integral of the Hamiltonian H Applying the Leibniz Rule, we obtain the variation of the integrand plus the value of the Hamiltonian at the moving boundary: d dα (^) ∗

Z (^) t 1

t 0

H dt =

Z (^) t∗ 1

t 0

∂H

∂x

ξ +

∂H

∂u

ω

dt + H(t∗ 1 )τ (51)

Term ○^3 : Integral of the Adjoint Dynamics λ˙T^ x Similarly, applying the Leibniz Rule to the term arising from integration by parts:

d dα (^) ∗

Z (^) t 1

t 0

λ^ ˙T^ x dt =

Z (^) t∗ 1

t 0

λ^ ˙T^ ξ dt + λ˙T^ (t∗ 1 )x∗(t∗ 1 )τ (52)

Term ○ 4 : Boundary terms from Integration by Parts The derivative of the boundary term −λT^ (t 1 )x(t 1 ) is calculated using the product rule:

d dα (^) ∗

λT^ (t 1 )x(t 1 ) = − λ˙T^ (t∗ 1 )x∗(t∗ 1 )τ − λT^ (t∗ 1 ) ( ˙x∗(t∗ 1 )τ + ξ(t∗ 1 )) (53)

Summing all terms and grouping by the time variation parameter τ , we find the condition for the optimal terminal time t∗ 1 : (^)  ∂ϕ ∂t

∂ϕ ∂x

− λT

x ˙∗^ + H

t∗ 1

Applying the transversality condition λT^ (t∗ 1 ) = ∂ϕ∂x , the middle term vanishes, leading to the final necessary condition: ∂ϕ(x∗(t∗ 1 ), t∗ 1 ) ∂t

  • H(x∗(t∗ 1 ), u∗(t∗ 1 ), λ∗(t∗ 1 ), t∗ 1 ) = 0 (55)

Finally we obtain the following conditions:                       

x ˙∗(t) = f (x∗(t), u∗(t), t) =

∂H(x∗(t), u∗(t), λ∗(t), t) ∂λ

T (n eqs.)

x∗(ti) = x 0 (n eqs.)

λ∗(t∗ f ) =

∂ϕ(x∗(t∗ f ), t∗ f ) ∂x

T (n eqs.)

λ˙∗(t) = − ∂H(x

∗(t), u∗(t), λ∗(t), t) ∂x

T (n eqs.)

∂H(x∗(t), u∗(t), λ∗(t), t) ∂u = 0 (m eqs.)

∂ϕ(x∗(t∗ f ), t∗ f ) ∂t

  • H(x∗(t∗ f ), u∗(t∗ f ), λ∗(t∗ f ), t∗ f ) = 0 (1 eq =⇒ to find terminal time)

The first 5 equations are the same conditions valid also for fixe time problems.

Property I: on the optimal trajectory, the total time derivative of the Hamiltonian is equal to its partial time derivative: dH∗ dt

∂H∗

∂t

= λT^ ∂f ∗ ∂t

∂L∗

∂t

Property II: if the functions L and f are not explicitly dependent on time, then the Hamiltonian is constant:

H(x∗(t), u∗(t), λ∗(t), t) = H∗^ = c c ∈ R (58)

Property III: If ϕ does not explicitly depend on time (i.e. ϕ = ϕ(x(t))) then the Hamiltonian is equal to zero along the optimal trajectory: H∗^ = 0 ∀t ∈ [ti, t∗ f ] (59)

1.9 2 nd^ Order Necessary Conditions: Legendre-Clebsch equations (OC)

Hypothesis: Throughout the solution time interval, the optimal triple (x∗, u∗, λ∗) must satisfy the following condition: ∂^2 H ∂u^2

[x∗(t), u∗(t), λ∗(t), t] ⪰ 0 ∀t ∈ [t 0 , t 1 ] (60)

NOTICE: H is a scalar function of time =⇒ its second derivative wrt control is a time-varying matrix:

∂^2 H ∂u^2

[x∗(t), u∗(t), λ∗(t), t] = M ∗(t) ∈ ℜmxm^ (61)

NOTICE 2: As seen for Legendre conditions (in CoV), also these equations provide a local necessary condition for optimality (hence, they’re not sufficient unless the problem is convex).

1.10 How to deal with control input saturation? (OC)

Saturation in control inputs refers to enforcing constraints on the allowable values of u, ensuring they stay within a predefined range umin ≤ u ≤ umax. There are several ways to implement saturation:

  • Hard constraints: If u is constrained, the problem is formulated as an inequality-constrained opti- mization problem. The optimality conditions must include complementary slackness conditions that determine whether the constraint is active or inactive at each time step.
  1. The optimality conditions of the costate (2 adjoint equations for each state, coming from N.C. for opti- mality, the Euler-Lagrange equation) are:

        

λ 0 (t 1 ) = ∂ϕ(x ∂(tx^1 ),t^1 )

T t 1

λ^ ˙ 0 (t) = − ∂H^0 (x(t),u(t),λ(t),t) ∂x

T = −

∂f (x(t), u(t), t) ∂x

T

| {z } =−[A(t)]T

λ 0 (t) − ∂L(x(t ∂)x,u(t),t)

T (68)

λ 1 (t 1 ) = ∂ψ(x ∂(tx^1 ),t^1 )

T t 1

λ^ ˙ 1 (t) = − ∂H^1 (x(t),u(t),t) ∂x

T = −

∂f (x(t), u(t), t) ∂x

T

| {z } =−[A(t)]T

·λ 1 (t)

  1. Computing the variation of both terms of cost functional after the perturbation on x∗^ and on u∗, then apply the derivative on the form (H − λ x˙) wrt α around α = 0:

δJ 0 =

Z (^) t 1

t 0

∂H 0

∂u

· ω(t) +

∂H 0

∂x

· ξ(t) + λ˙T 0 · ξ(t)

dt (70)

δJ 1 =

Z (^) t 1

t 0

∂H 1

∂u

· ω(t) +

∂H 1

∂x

· ξ(t) + λ˙T 1 · ξ(t)

dt (71)

  1. Substituting the previous re-arranged adjoint equations:

δJ 0 =

Z (^) t 1

t 0

∂H 0

∂u

· ω(t) + 

∂H 0 

∂x

· ξ(t) − 

∂H 0 

∂x

· ξ(t)

dt =

Z (^) t 1

t 0

∂H 0

∂u

· ω(t)

dt (72)

δJ 1 =

Z (^) t 1

t 0

∂H 1

∂u

· ω(t) + 

∂H 1 

∂x

· ξ(t) − 

∂H 1 

∂x

· ξ(t)

dt =

Z (^) t 1

t 0

∂H 1

∂u

· ω(t)

dt (73)

Since H = L + λT^ f , the derivative wrt u becomes:

∂H ∂u

∂L

∂u

  • λT^

∂f |{z}^ ∂u =B

So:

δJ 0 =

Z (^) t 1

t 0

∂L

∂u

  • λT 0 B

ω(t)

dt δJ 1 =

Z (^) t 1

t 0

λT 1 B

ω(t) dt (75)

  1. Finally, the variation of the Total Cost is:

δJC =

Z (^) t 1

t 0

∂HC

∂u

· ω(t)

dt =

Z (^) t 1

t 0

∂L

∂u

  • λT 0 B + μλT 1 B

ω(t)

dt (76)

Remember: The first variation of the augmented cost functional must be zero for every perturbation

δJC =

Z (^) t 1

t 0

∂HC

∂u

· ω(t)

dt = 0 (77)

Respect to the previous case (no constraints), we have to find a NEW EQUATION for the new multiplier μ.

GOAL: find an eq. that defines μ → see in δJC equation where μ appears.

  • In δJ 1 : δJ 1 =

Z (^) t 1

t 0

∂H 1

∂u · ω(t)

dt (78)

Since, in general, ω(t) is a small perturbation on the control input u(t) we rewrite it through an infinitesimal scale factor ϵ:

ω(t) = ϵ ·

∂HC

∂u

T (79)

We obtain:

δJ 1 =

Z (^) t 1

t 0

∂H 1

∂u

· ϵ ·

∂HC

∂u

T

dt (80)

Coupling it with:

  

 

Z (^) t 1

t 0

∂H 1

∂u

· ω(t)

dt =

Z (^) t 1

t 0

λT 1 · [B]ω(t) dt

Z (^) t 1

t 0

∂HC

∂u

· ω(t)

dt =

Z (^) t 1

t 0

∂L

∂u

  • λT 0 [B] + μλT 1 [B]

ω(t)

dt

We obtain:

δJ 1 = ϵ

Z (^) t 1

t 0

(λT 1 [B])

∂L

∂u

  • λT 0 [B] + μλT 1 [B]

T

dt (82)

Carrying out the calculations:

δJ 1 = ϵ

Z (^) t 1

t 0

λT 1 [B]

∂L

∂u

  • λT 0 · [B]

T

dt | {z } a

+μϵ

Z (^) t 1

t 0

λT 1 [B][B]T^ λ 1 dt | {z } b

Thus: δJ 1 = ϵ(a + μb)

Along the optimal trajectory x∗(t) the 1st^ variation of cost functional is = 0 =⇒ μ = −

a b b must be ̸= 0 → True when system is controllable. =⇒ this is the additional optimality condition when final state has to be reached without errors.

  1. know μ
  2. re-couple the problem (Jc = J 0 + μJ 1 ) and solve it
  3. find x∗, u∗, λ∗

1.12 Equality constraints on control and state (OC)

Problem Formulation: equality constraints c are a function of state, control and time

min u(t)∈C^0 ([t 0 ,t 1 ])

J[u] = ϕ(x(t 1 ), t 1 ) +

Z (^) t 1

t 0

L(x(t), u(t), t) dt

s.t. x˙(t) = f (x(t), u(t), t) x(t 0 ) = x 0 c(x(t), u(t), t) = 0 (equality constraint is a r-dimensional equation)

The cost functional is augmented with Lagrangian multipliers associated with the system dynamics (λ) and with the equality constraints (μ):

J = ϕ(x(t 1 ), t 1 ) +

Z (^) t 1

t 0

L + λT^ (f − x˙) + μT^ · c

dt (85)

  1. inactive constraint: optimal trajectory is far from the boundary of the constraint (region cj < 0 )

Trajectory observation:

Trajectory and constraints

  • Trajectory xF 1 sees only c 1 constraint.
  • Trajectory xF 2 is subjected to c 1 and c 2.
  • Constraint c 3 is never active (since c 1 and c 2 are already limiting its working area).

Separating active and inactive constraints, it’s possible to adopt an equality-constraint-like writing:

H = L + λT^ · f + μTEF F · cEF F (93) ( μEF F = 0 if cEF F < 0 μEF F ≥ 0 if cEF F = 0

These conditions above expressed are another way of representing the KKT conditions → it’s a way to implement them in optimal control. In fact, it’s required that the product μEF F · cEF F = 0 with μEF F ≥ 0. Adjoint Equation Results:

λ^ ˙ =

∂LT

∂x

− AT^ · λ cef f < 0

∂LT

∂x

− AT^ · λ −

∂cTef f ∂x

· μEF F cef f = 0

Adjoint equation assumes different values depending on whenever cEF F is active or inactive.

Final condition on the adjoint vector equal to: λ(t 1 ) = ∂ϕ(x ∂x(t ),t) t 1 The optimality condition results in:

∂L

∂u

  • λT^ · B cEF F < 0

∂L

∂u

  • λT^ · B + μEF F ·

∂cEF F ∂x

cEF F = 0

When switching from an active set to another one, it holds:

λ(t− i ) = λ(t+ i ) H(t− i ) = H(t+ i )

NOTICE: function by parts introduce discontinuities. Inequality constraints considered up to now are called hard constraints. To avoid discontinuities, one can decide to accept constraint violations weighting these violations: in this case inequality constraints are removed and a weighting function is introduced =⇒ we talk about soft constraints.

  • Soft Constraints: these are incorporated into the cost function via penalty terms. This method is useful when strict feasibility is too restrictive. They improve numerical tractability and avoid disconti- nuities. Violations are allowed but penalized by a weighting function k:

L(u) =

k(u − umax)^2 if u ≥ umax 0 if umin < u < umax k(u − umin)^2 if u ≤ umin

  • Slack Variable Methods: Inequality constraints can be converted into equality constraints by intro- ducing slack variables s, where s ≥ 0. For example, if the original constraint is:

g(x, u) ≤ 0 , (98)

it can be reformulated as:

g(x, u) + s = 0, s ≥ 0. (99)

The slack variable s represents the "buffer" or the extent to which the inequality is not tight. When g(x, u) = 0 , s = 0; if g(x, u) < 0 , s > 0 ensures the equality holds. In optimization, s is often included in the objective function with a penalty term to minimize its value, encouraging the solution to approach the boundary of the original inequality constraint. Slack variables strictly enforce the constraint by restructuring it, while soft constraints permit violations and penalize them.

In this case, the first step can be either up (10) or down (11). If we consider the travel time from x, one can go up and down (16) or can go down and up (18); from principle of optimality, up-down is the best way to get B for any path passes from x. Repeat the process for all other points until you get to the inital point.

  • Step 3 - Apply DP and backward integration: instead of evaluating all possible routes in a forward brute-force manner, one can work backwards from the end, defining the cost-to-go (or value function) V and its terminal boundary condition as:

V (^) k∗ (xik) = min uijk

L(xik, uijk , tk)∆t | {z } backward-step immediate cost

  • V (^) k∗+1(xjk+1) | {z } future cost till the end

V (^) N∗ (xiN ) = ϕ(xiN , tN ) (terminal B.C.)

In the brute force approach, the number of possible routes grows exponentially with the number of segments n (∼ (2(nn!))! 2 ). In the DP method they scale polynomially (∼ (n + 1)^2 − 1 ) because it reuses solutions to the subproblems (segments not involved in optimal route are discarded), increasing efficiency. In our example we have n = 3, hence 20 routes possible and 15 DP computations.

Also the number of computations are reduced. Assume that the states are discretized in a finite set of X elements, the control space is discretized in U elements and the time steps are N. For the brute force approach there are XU N^ computations, while for the DP approach there are XU N computations.

A drawback feature of this problem is the "curse of dimensionality" meaning that for large X, the search space grows exponentially (since at each step you have X = pd, where p is the number of state variables and d the number of dimensions); hence, exhaustive methods become impractical.

2.2 The Curse of Dimensionality

The curse of dimensionality is the problem that affects Dynamic Programming. Trade-off Analysis: While Dynamic Programming (DP) successfully reduces the temporal complexity from exponential O(U N^ ) to linear O(N ) relative to the time horizon, it remains sensitive to the state-space dimensionality. The memory requirement (spatial complexity) grows exponentially as X = O(pd), where d is the number of state variables, p is the number of points that describes your discrete model and X is the total number of states to compute. Thus, DP optimizes time at the expense of memory. To overcome the Curse of Dimensionality, several techniques can be employed to approximate or simplify the state-space search:

  • State Aggregation: Grouping similar states together to reduce the total number of elements in X, effectively lowering the resolution p where high precision is not required.
  • Function Approximation (Approximate Dynamic Programming - ADP): Instead of storing the value function V in a grid (look-up table), it is approximated using continuous functions, such as polynomials or Neural Networks (Deep RL). This avoids the need to discretize the entire domain.
  • Dimensionality Reduction: Identifying and removing redundant state variables that do not signifi- cantly contribute to the system dynamics, thereby reducing d.
  • Horizon Limiting / Model Predictive Control (MPC): Reducing N by optimizing over a shorter, "receding" time horizon rather than the entire global duration.

2.3 DP in classical OC - computation of u in particular cases

Starting from classical OC problem formulation:

min u(t)∈C^0 ([t 0 ,t 1 ])

J[u] = ϕ(x(t 1 ), t 1 ) +

Z (^) t 1

t 0

L(x(t), u(t), t)dt

subject to x˙(t) = f (x(t), u(t), t) x(t 0 ) = x 0

In order to apply the Dynamic Programming algorithm (as just done for the traveller’s problem), it is necessary to discretize the problem both in time and in space (i.e. state variables):

min U

J^ ˜ = ϕ(xN , tN ) +

NX − 1

k=

L(xk, uk, tk)∆t

subject to xk+1 = xk + f (xk, uk, tk)∆t x 0 = x 0

States are discretized in a finite set of X elements, control space in U elements and time steps are N. When the optimal cost is evaluated backward it’s called residual cost J* or value function or cost-to-go. Iteratively, the value function is built as a function of both time step "k" and state "i" at each step:

V (^) k∗ (xik) (103)

The algorithm is initialized at the final time step as:

V (^) N∗ (xiN ) = ϕ(xiN , tN ) (104)

The cost increment at each step is computed as:

∆Jkij =

Z (^) tk+

tk

L(x(t), u(t), t)dt ≈ L(xik, uijk , tk)∆t (105)

To determine the value of uijk , the system can be discretized using Euler integration method:

xjk+1 ≈ xik + f (xik, uijk , tk)∆t =⇒ f (xik, uijk , tk) ≈

xjk+1 − xik ∆t

Then, proceeding backwards from N-1 to 0, the following minimization search is done:

V (^) k∗ (xik) = min uijk

{L(xik, uijk , tk)∆t + V (^) k∗+1(xjk+1)} (107)

At each time step, the value function is computed for each possible state together with the optimal control input uij k ∗that brings the system from state "i" to "j" as a result of the minimization.

Non-Affine Systems: A system is said to have dynamics that are affine in its control inputs when the control u(t) influences the system in a linear way, while other parts of the system (like the state x(t)) might still behave nonlinearly.

x ˙(t) = g(x(t), t) | {z } non-linear portion of the system dynamics

  • q(x(t), t)u(t) | {z } control u enters linearly by means of q

The discretized dynamics is: xjk− 1 = xik + g(xik, tk)∆t + q(xik, tk)uijk ∆t (109)

Thus, the control input to pass from state xik at tk to xjk+1 at tk+1 is:

uijk = q(xik, tk)−^1 [

xjk+1 − xik ∆t

− g(xik, tk)] (110)