Systems Optimization Winter Semester 2014/15 Part II: Dynamic … · 2015. 2. 3. · Winter...

52
Systems Optimization Winter Semester 2014/15 Part II: Dynamic Optimization 6. Optimal Control Problems Dr. Abebe Geletu Technische Universit¨ at Ilmenau Institute of Automation and Systems Engineering Department of Simulation and Optimal Processes (SOP) Systems Optimization Winter Semester 2014/15 Part II: Dynamic Optimization 6. Optimal Control Problems TU Ilmenau

Transcript of Systems Optimization Winter Semester 2014/15 Part II: Dynamic … · 2015. 2. 3. · Winter...

  • Systems OptimizationWinter Semester 2014/15

    Part II: Dynamic Optimization6. Optimal Control Problems

    Dr. Abebe Geletu

    Technische Universität IlmenauInstitute of Automation and Systems Engineering

    Department of Simulation and Optimal Processes (SOP)

    Systems Optimization Winter Semester 2014/15 Part II: Dynamic Optimization 6. Optimal Control Problems

    TU Ilmenau

  • 6.1 Definitions

    To control a system means to guide (force) the system so thatthe system displays a desired behavior.

    There might be several control strategies to force a systemdisplay a desired behavior.

    Objectives of optimal control: To find the best controlstrategy (among several alternatives) to force (guide) a systemattain certain behaviors in order to achieve a desired goal.

    A mathematical statement of an optimal control probleminvolves:

    I a performance criteriaI a model equation describing the dynamics of the systemI physical constraints

    Systems Optimization Winter Semester 2014/15 Part II: Dynamic Optimization 6. Optimal Control Problems

    TU Ilmenau

  • 6.1 Definitions ...Behaviors of a system are described through its state variables x .The degrees of freedom to manipulate the behavior of the system arecontrol variables u. Thus, the states (behaviors) that the systemattains are determined by the control; i.e., x(t) = x(u(t)).

    variables (unknonws):

    I control variables: u = (u1(t), u2(t), . . . , um)>.

    I state variables: x = (x1(t), x2(t), . . . , xn)> (In general, n ≥ m).

    Constraints:Control constraints: ui,min ≤ ui (t) ≤ ui,max , i = 1, . . . ,mState constraints: xj,min ≤ xj(t) ≤ xj,max , j = 1, . . . , n.Control time horizon: t0 ≤ t ≤ tf (given or free)Initial state: x(t0) = x0 (usually known)Final or terminal state: x(tf ) = xf (given or free)Model equation: ẋ = f (t, x , u), 0 = g(t, x , u) (ODE or DAE).

    Performance criteria: J - is an objective function that describes thecriteria according to which the best control strategy to be determined.

    Systems Optimization Winter Semester 2014/15 Part II: Dynamic Optimization 6. Optimal Control Problems

    TU Ilmenau

  • 6.1. Definitions ... an optimal control problemWe consider the following optimal control problem

    minu

    {E (x(tf ), tf ) +

    ∫ tft0

    f0(x(t), u(t), t)dt

    }(1)

    subject to: (2)

    ẋ = f (x , u, t), t0 ≤ t ≤ tf , (3)0 = g(x , u, t), t0 ≤ t ≤ tf , (4)x(t0) = x0, (5)

    umin ≤ u ≤ umax , (6)xmin ≤ x ≤ xmax . (7)

    Here, the performance criteria is

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

    ∫ tft0

    f0(x(t), u(t), t)dt.

    Systems Optimization Winter Semester 2014/15 Part II: Dynamic Optimization 6. Optimal Control Problems

    TU Ilmenau

  • 6.2. Optimal control problems - special forms ofthe performance criteria J• Mayer type optimal control if

    J[u] = E (x(tf ), tf )

    • Lagrange type optimal control if

    J[u] =

    ∫ tft0

    f0(u, x , t)dt.

    • Bolza type optimal control if

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

    ∫ tft0

    f0(u, x , t)dt.

    The Bolza type is more general than the other two.

    In general, any one type can be equivalently transformed to theother two forms.

    Systems Optimization Winter Semester 2014/15 Part II: Dynamic Optimization 6. Optimal Control Problems

    TU Ilmenau

  • 6.2. ... Linear quadratic optimal control problemsIf the performance function takes the from

    J[u] = x>Mx(tf ) +

    ∫ tft0

    [[x(t)]>Qx(t) + [u(t)]>Qu(t)

    ]dt

    with the model equation being linear

    ẋ = Ax(t) + Bu(t) (8)

    0 = Cx(t) + Du(t) (9)

    possibly with constraints on the control and state variables

    umin ≤ u ≤ umax , (10)xmin ≤ x ≤ xmax . (11)

    The resulting problem is known as linear quadratic optimal control(closely related with the linear quadratic regulator (LQR)) problem.

    Systems Optimization Winter Semester 2014/15 Part II: Dynamic Optimization 6. Optimal Control Problems

    TU Ilmenau

  • 6.3. Further classifications and optimality conditions6.3.1. Classifications and terminologiesI tf -terminal-time and x(tf ) - terminal-state.

    Depending on the type of application, either the terminal-time tf orthe terminal-state x(tf ) or both can be fixed or free.

    Accordingly, we have the following classes of optimal control problems:(I) Fixed terminal-time, fixed terminal-state(II) Fixed terminal-time, free terminal-state(III) Free terminal-time, fixed terminal-state(IV) Free terminal-time, free terminal-state

    In addition, any of the above can include a combination of thefollowing constraints:

    (i) constraints on the terminal-state(ii) constraints on the control variables(iii) constraints on the state variables.

    Systems Optimization Winter Semester 2014/15 Part II: Dynamic Optimization 6. Optimal Control Problems

    TU Ilmenau

  • 6.3.2 Optimality conditionsThe first order optimality conditions take a special formdepending on the type (class) of the optimal control problem.(I) Fixed terminal-time, fixed terminal-state optimal control.

    minu

    {∫ tft0

    f0(x(t), ẋ(t), t)dt

    }(12)

    subject to:

    x(t0) = x0, (13)

    x(t0) = xf . (14)

    Optimality condition:

    Euler-Lagrange Equations:

    ∂f0∂x− ∂∂t

    (∂f0∂ẋ

    )= 0.

    Systems Optimization Winter Semester 2014/15 Part II: Dynamic Optimization 6. Optimal Control Problems

    TU Ilmenau

  • 6.3.2. Optimality conditions...(I’) Fixed terminal-time, fixed terminal-state optimal control with aboundary condition.

    minu

    {∫ tft0

    f0(x(t), ẋ(t), t)dt

    }(15)

    subject to:

    g(x(t), ẋ(t), t) = 0, (16)

    x(t0) = x0, (17)

    x(t0) = xf . (18)

    Use the Lagrange function:

    L(x , u, λ, t) = f0(x(t), u(t), t) + λ(t)g(x(t), u(t), t)

    where λ(t) is known costate or adjoint variable, and

    Systems Optimization Winter Semester 2014/15 Part II: Dynamic Optimization 6. Optimal Control Problems

    TU Ilmenau

  • 6.3.2 Optimality conditions...transform the problem to the unconstrained problem

    minu

    {∫ tft0

    L(x(t), ẋ(t), λ(t), t)dt

    }(19)

    subject to:

    x(t0) = x0, (20)

    x(t0) = xf . (21)

    Optimality condition:

    Euler-Lagrange Equations:

    ∂L

    ∂x− ∂∂t

    (∂L

    ∂ẋ

    )= 0. (22)

    ∂L

    ∂λ− ∂∂t

    (∂L

    ∂λ̇

    )= 0 ≡ g(x(t), ẋ(t), t) = 0. (23)

    Systems Optimization Winter Semester 2014/15 Part II: Dynamic Optimization 6. Optimal Control Problems

    TU Ilmenau

  • 6.3.1 Optimality conditions...Set u = ẋ . Then, it follows that

    minu

    {∫ tft0

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

    }(24)

    subject to:

    x(t0) = x0, (25)

    x(t0) = xf . (26)

    The Euler-Lagrange equations in terms of u

    Euler-Lagrange Equations:

    ∂L

    ∂x− ∂∂t

    (∂L

    ∂u

    )= 0. (27)

    ∂L

    ∂λ− ∂∂t

    (∂L

    ∂λ̇

    )= 0. (28)

    Systems Optimization Winter Semester 2014/15 Part II: Dynamic Optimization 6. Optimal Control Problems

    TU Ilmenau

  • 6.3.1 Optimality conditions...

    (II) Fixed terminal-time, free terminal-state optimal control(II-i) without a constraint on the terminal-state

    minu

    {φ(x(tf )) +

    ∫ tft0

    f0(x(t), u(t), t)dt

    }(29)

    subject to:

    ẋ = f (x(t), u(t), t), (30)

    x(t0) = x0. (31)

    Use the Hamilton function:

    H(x , u, λ, t) = f0(x(t), u(t), t) + λ(t)f (x(t), u(t), t)

    with the costate or adjoint variable λ(t) so that

    Systems Optimization Winter Semester 2014/15 Part II: Dynamic Optimization 6. Optimal Control Problems

    TU Ilmenau

  • 6.3.1 Optimality conditions...

    minu

    {φ(x(tf )) +

    ∫ tft0

    {f0(x(t), u(t), t) + λ(t)

    > [f (x , u, t)− ẋ ]}dt

    }subject to: x(t0) = x0.

    Optimality conditions:

    Hamilton’s Method

    State equations: ẋ =∂H

    ∂λ= f (x , u, t)

    Adjoint equations: λ̇ = −∂H∂x

    Boundary conditions: x(t0) = x0, λ(tf ) =∂φ

    ∂x(tf )

    Minimum principle (optimality condition):∂H(x∗, u∗, λ∗, t)

    ∂u= 0

    i.e. H(x∗, u∗, λ∗, t) = minu

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

    Systems Optimization Winter Semester 2014/15 Part II: Dynamic Optimization 6. Optimal Control Problems

    TU Ilmenau

  • 6.3.1 Optimality conditions...(II) Fixed terminal-time, free terminal-state optimal control(II-ii) with a constraint on the terminal-state

    minu

    {φ(x(tf )) +

    ∫ tft0

    f0(x(t), u(t), t)dt

    }(32)

    subject to:

    ẋ = f (x(t), u(t), t), (33)

    g(x(tf ), tf ) = 0, (34)

    x(t0) = x0. (35)

    Use the Hamilton function:

    H(x , u, λ, t) = f0(x(t), u(t), t) + λ(t)f (x(t), u(t), t)

    with the costate or adjoint variable λ(t) so that

    Systems Optimization Winter Semester 2014/15 Part II: Dynamic Optimization 6. Optimal Control Problems

    TU Ilmenau

  • 5.3.1 Optimality conditions...

    the problem can be transformed to the unconstrained optimal controlproblem

    minu

    {φ(x(tf )) + µ

    >g(x(tf ), tf )+∫ tft0

    {f0(x(t), u(t), t) + λ(t)

    > [f (x , u, t)− ẋ ]}dt

    }subject to:

    x(t0) = x0.

    I The scalar vector µ> = (µ1, µ2, . . . , µm) ∈ Rm representsLagrange multipliers corresponding to the equality constraintsg(x(tf ), tf ) = 0.

    Systems Optimization Winter Semester 2014/15 Part II: Dynamic Optimization 6. Optimal Control Problems

    TU Ilmenau

  • 6.3.1 Optimality conditions...

    Optimality conditions:

    Hamilton’s Method

    State equations: ẋ =∂H

    ∂λ= f (x , u, t)

    Adjoint equations: λ̇ = −∂H∂x

    Boundary conditions: x(t0) = x0,

    λ(tf ) =∂φ

    ∂x(tf )+

    ∂g>

    ∂x(tf )µ

    Minimum principle (optimality condition):∂H(x∗, u∗, λ∗, t)

    ∂u= 0

    i.e. H(x∗, u∗, λ∗, t) = maxu

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

    Systems Optimization Winter Semester 2014/15 Part II: Dynamic Optimization 6. Optimal Control Problems

    TU Ilmenau

  • 6.3.1 Optimality conditions...(IV) Free terminal-time, free terminal-state optimal control

    (Minimum time or time-optimal control problem)

    minu

    {φ(xtf ) +

    ∫ tft0

    f0(x(t), u(t), t)dt

    }(36)

    subject to:

    ẋ = f (x , u, t) (37)

    x(t0) = x0. (38)

    (39)

    Use the Hamilton function:

    H(x , u, λ, t) = f0(x(t), u(t), t) + λ(t)f (x(t), u(t), t)

    where λ(t) is known costate or adjoint variable, and

    Systems Optimization Winter Semester 2014/15 Part II: Dynamic Optimization 6. Optimal Control Problems

    TU Ilmenau

  • 6.3.1 Optimality conditions...Optimality conditions:

    Hamilton’s Method

    State equations: ẋ =∂H

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

    Adjoint equations: λ̇ = −∂H∂x

    Boundary conditions: x(t0) = x0,

    λ(tf ) =∂φ

    ∂x(tf ),

    Minimum principle (optimality condition):∂H(x∗, u∗, λ∗, t)

    ∂u= 0,

    i.e. H(x∗, u∗, λ∗, t) = maxu

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

    Terminal condition): H(x∗, u∗, λ∗, t) = −∂φ(x∗(tf ), t

    ∗f )

    ∂tf.

    Systems Optimization Winter Semester 2014/15 Part II: Dynamic Optimization 6. Optimal Control Problems

    TU Ilmenau

  • 6.3.1 Optimality conditions...(IV) Free terminal-time, free terminal-state(IV +(i)+(ii)) with constraints on the terminal-state and thecontrols

    minu

    {φ(x(tf )) +

    ∫ tft0

    f0(x(t), u(t), t)dt

    }(40)

    subject to:

    ẋ = f (x(t), u(t), t), t0 ≤ t ≤ tf , (41)g(x(tf ), tf ) = 0, (42)

    x(t0) = x0, (43)

    umin ≤ u(t) ≤ umax , (44)where u>min = (umin,1, . . . , umin,m) and u

    >max = (umax ,1, . . . , umax ,m) are

    given vectors.Hamilton function:H(x , u, λ, t) = f0(x(t), u(t), t) + λ(t)f (x(t), u(t), t).

    Systems Optimization Winter Semester 2014/15 Part II: Dynamic Optimization 6. Optimal Control Problems

    TU Ilmenau

  • 6.3.1 Optimality conditions...

    Hamilton’s Method

    State equations: ẋ =∂H

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

    Adjoint equations: λ̇ = −∂H∂x

    Boundary conditions: x(t0) = x0,

    λ(tf ) =∂φ

    ∂x(tf )+

    [∂g

    ∂x(tf )

    ]>µ,

    Minimum principle (optimality condition):

    i.e. H(x∗, u∗, λ∗, t) = minumin≤u≤umax

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

    Terminal condition: H(x∗, u∗, λ∗, t) = −∂φ(x∗(tf ), t

    ∗f )

    ∂tfIf tf is fixed: H(x

    ∗(t), u∗(t), λ∗(t), t) = H(x∗(tf ), u∗(tf ), λ

    ∗(tf ), tf ) = constant.

    Systems Optimization Winter Semester 2014/15 Part II: Dynamic Optimization 6. Optimal Control Problems

    TU Ilmenau

  • 6.3.1 Optimality conditions... Example

    Example: Find a solution for the optimal control problem

    minu

    {1

    2

    ∫ 20

    u2(t)dt

    }subject to:

    ẋ1 = x2(t)

    ẋ2 = u(t)

    x(0) = [1, 2]>, x(2) = [1, 0]

    Systems Optimization Winter Semester 2014/15 Part II: Dynamic Optimization 6. Optimal Control Problems

    TU Ilmenau

  • 6.4. Numerical Methods ... Orthogonal CollocationConsider the optimal control problem (fixed terminal time)

    (OPtCtrl) minu

    {∫ tft0

    f0(x(t), u(t), t)dt

    }subject to:

    ẋ = f (x , u, t), t0 ≤ t ≤ tf , x(t0) = x0,0 = g(x , u, t), t0 ≤ t ≤ tf ,umin ≤ u ≤ umax ,xmin ≤ x ≤ xmax .

    Objective:• To approximate the states x(t) and the controls u(t) throughLagrange interpolating polynomials.• The Lagrange polynomials are defined using collocation points.• Then the problem is discretized (transcribed) into a nonlinearoptimization problem (NLP).

    Systems Optimization Winter Semester 2014/15 Part II: Dynamic Optimization 6. Optimal Control Problems

    TU Ilmenau

  • 5.4. ... Orthogonal Collocation...

    We assume that we have n state and m control variables so that

    x(t) =

    x1(t)x2(t)

    ...xn(t)

    , f (x(t), u(t), t) =f1(x(t), u(t), t)f2(x(t), u(t), t)

    ...fn(x(t), u(t), t)

    ,

    u(t) =

    u1(t)u2(t)

    ...um

    , g(x(t), u(t), t) =g1(x(t), u(t), t)g2(x(t), u(t), t)

    ...gm(x(t), u(t), t)

    .Two types of collocations:(A) Global orthogonal collocation on [t0, tf ](B) Orthogonal collocation on finite elements [t0, tf ].

    Systems Optimization Winter Semester 2014/15 Part II: Dynamic Optimization 6. Optimal Control Problems

    TU Ilmenau

  • 5.4.1. Global orthogonal collocation• Determine collocation points from the whole interval [t0, tf ].Since x(t0) = x0 is given and tf is given , t0 and tf should belong to the collocation

    points. Such collocation points are called Lobatto collocation points = generation of

    collocation points (quadrature nodes) fixing the end-points of the interval [t0, tf ].

    Figure: Collocation points t0, t1, . . . , tN = tf .

    • Corresponding to each state xi (t) and control variable uj(t), definethe interpolating polynomials:

    x̂i (t) =N∑

    k=0

    x(i)k Lk(t), i = 1, . . . , n; ûj(t) =

    N∑k=0

    u(j)k Lk(t), j = 1, . . . ,m

    whereSystems Optimization Winter Semester 2014/15 Part II: Dynamic Optimization 6. Optimal Control Problems

    TU Ilmenau

  • 5.4.1. Global orthogonal collocation...

    where Lk(t) represents the polynomial

    Lk(t) =N∏

    l = 0l 6= k

    [t − tltk − tl

    ]

    which is the N-th degree Lagrange polynomial. The polynomial have

    the property that Lk(tl) =

    {1, if l = k0, if l 6= k .

    • We would like to approximate xi (t) by x̂i (t) and uj(t) by ûj(t).

    Systems Optimization Winter Semester 2014/15 Part II: Dynamic Optimization 6. Optimal Control Problems

    TU Ilmenau

  • 5.4.1. Global orthogonal collocation...(I) Discretization of the model equationsFirst, let’s see how we can discretize the dynamic equationsẋ = f (x , u, t) by writing

    ˙̂x1(t) = f1 ((x̂1(t), x̂2(t), . . . , x̂n(t)), (û1(t), û2(t), . . . , ûm(t)), t) ,...

    ˙̂x2(t) = f2 ((x̂1(t), x̂2(t), . . . , x̂n(t)), (û1(t), û2(t), . . . , ûm(t)), t) ,

    ˙̂xn(t) = fn ((x̂1(t), x̂2(t), . . . , x̂n(t)), (û1(t), û2(t), . . . , ûm(t)), t) .

    Observer, for each k = 0, 1, . . . ,N, that

    x̂i (tk) =N∑

    k=0

    xikLk(tk) = xik , i = 1, . . . , n (45)

    ûj(tk) =N∑

    k=0

    ujkLk(tk) = ujk , j = 1, . . . ,m. (46)

    (47)Systems Optimization Winter Semester 2014/15 Part II: Dynamic Optimization 6. Optimal Control Problems

    TU Ilmenau

  • 5.4.1. Global orthogonal collocation...

    Hence, discretization of the dynamic system at the collocation pointst0, t1, . . . , tN leads to the system

    N∑k=0

    x1k L̇k(tl) = f1 ((x̂1(tl), . . . , x̂n(tl)), (û1(tl), . . . , ûm(tl)), tl) ,

    N∑k=0

    x2k L̇k(tl) = f2 ((x̂1(tl), . . . , x̂n(tl)), (û1(tl), . . . , ûm(tl)), tl) ,

    ...N∑

    k=0

    xnk L̇l(tl) = fn ((x̂1(tl), . . . , x̂n(tl)), (û1(tl), . . . , ûm(tl)), tl) ,

    l = 0, 1, . . . ,N.

    Systems Optimization Winter Semester 2014/15 Part II: Dynamic Optimization 6. Optimal Control Problems

    TU Ilmenau

  • 5.4.1. Global orthogonal collocation...Define

    Fi =

    fi ((x10, . . . , xn0), (u10, . . . , um0))fi ((x11, . . . , xn1), (u11, . . . , um1))

    ...fi ((x1N , . . . , xnN), (u1N , . . . , umN))

    ; xi =xi0xi1...

    xiN

    i = 1, . . . , n.

    and, sometimes, we can put all vectors xi into one matrix as rowvectors as

    X =

    x1,0 x1,1 . . . x1,Nx2,0 x2,1 . . . x2,N

    ...... . . .

    ...xn,0 xn,1 . . . xn,N

    .Systems Optimization Winter Semester 2014/15 Part II: Dynamic Optimization 6. Optimal Control Problems

    TU Ilmenau

  • 5.4.1. Global orthogonal collocation...Observe that the k-th column of the matrix X :• is vector of length n; and• corresponds to the value of the state vector x(t) attk , k = 0, 1, . . . ,N.Thus, in matlab notation we write X (:, k) to refer to column k .

    L =

    L̇0(t0) L̇1(t0) . . . L̇N(t0)

    L̇0(t1) L̇1(t1) . . . L̇N(t1)...

    ... . . ....

    L̇0(tN) L̇1(tN) . . . L̇N(tN)

    uj =xj0uj1...

    ujN

    , j = 1, . . . ,m.• We can also define an m × (N + 1) matrix U whose rows are theuj’s. And U(:, k) corresponds to the value of the control vectors u(t)at t = tk .

    Systems Optimization Winter Semester 2014/15 Part II: Dynamic Optimization 6. Optimal Control Problems

    TU Ilmenau

  • 5.4.1. Global orthogonal collocation...Using the above notations, we can now write the discretized modelequations as

    Lxi = Fi ((x1, . . . , xn), (u1, . . . ,um)), i = 1, . . . , n.

    Similarly, for the algebraic equation 0 = g(x , u, t) we can write

    0 = Gj((x1, . . . , xn), (u1, . . . ,um)), j = 1, . . . ,m.

    (II) Discretization of the performance functionThe performance criteria J[u] =

    ∫ tft0

    f0(x(t), u(t), t)dt can beapproximated by the sum

    Ĵ =N∑

    k=0

    f0(X (:, k),U(:, k), tk).

    Systems Optimization Winter Semester 2014/15 Part II: Dynamic Optimization 6. Optimal Control Problems

    TU Ilmenau

  • 5.4.1. Global orthogonal collocation...(III) Discretization of control and state constraints

    umin ≤ U(:, k) ≤ umax , k = 1, . . . ,Numin ≤ X (: k) ≤ umax , k = 1, . . . ,N.

    Finally we obtained the nonlinear optimization problem

    (NLP) minu0,u1,...,un

    N∑k=0

    f0(X (1 : k),U(1 : k), tk)

    subject to:

    Lxi = Fi ((x1, . . . , xn), (u1, . . . ,um)),

    i = 1, . . . , n., x0 given

    0 = Gj((x1, . . . , xn), (u1, . . . ,um)),

    j = 1, . . . ,m.

    umin ≤ uk ≤ umax , k = 0, 1, . . . ,Nxmin ≤ xk ≤ xmax , k = 0, 1, . . . ,N.

    Systems Optimization Winter Semester 2014/15 Part II: Dynamic Optimization 6. Optimal Control Problems

    TU Ilmenau

  • 5.4.1. Global orthogonal collocation...

    The problem NLP is a discretization of the optimal control problemOptCtrl at the collocation points.In the problem NLP:

    the vectors x1, . . . , xn and u0,u1, . . . ,um unknown (recall that x0is already given so it is known). Hence, there are nN + m(N + 1)unknown variables;

    and n(N + 1) + m(N + 1) equality constraints.

    Thus, depending on the number of collocation points and themodel equations in the original problem OptCtrl, the problemNLP can be very large.

    In general, such an optimization problem requires a large-scalenonlinear optimization solver.

    Systems Optimization Winter Semester 2014/15 Part II: Dynamic Optimization 6. Optimal Control Problems

    TU Ilmenau

  • 5.4.1. Global orthogonal collocation...Helpful hint on implementation:When implementing the problem NLP:

    put all the unknown vectors x1, . . . , xn into one long vector x aswell as the unknown vectors u1, . . . ,um into a vector u as

    x =

    x1. . ..... . .xn

    , u =

    u1. . ..... . .um

    .Now, the vector x has length n(N + 1) where as u of lengthm(N + 1) .

    To retrieve back the xk from x, use the matlab like assignment

    xi = x(i(N + 1) + 1 : (i + 1)(N + 1)) for each i = 0, . . . , n − 1.

    Systems Optimization Winter Semester 2014/15 Part II: Dynamic Optimization 6. Optimal Control Problems

    TU Ilmenau

  • 5.4.1. Global orthogonal collocation.. ExampleConsider the optimal control problem:

    minu(t)

    1

    2

    ∫ 20

    [u(t)]2 dt (48)

    subject to: (49)

    ẋ1(t) = x2(t)ẋ2(t) = u(t)

    0 ≤ t ≤ 2, (50)

    x1(0) = 2, x2(0) = 1 (51)

    x1(2) = 0, x2(2) = 0. (52)

    (53)

    Solution:(i) Generate collocation points from the interval [t0, tf ] = [0, 2].

    tk = t0 + τk(tf − t0), k = 0, 1, . . . ,N.= t0 + τk(2− 0), k = 0, 1, . . . ,N.

    Systems Optimization Winter Semester 2014/15 Part II: Dynamic Optimization 6. Optimal Control Problems

    TU Ilmenau

  • 5.4.1. Global orthogonal collocation.. Example...whereτk ∈ {0, 0.0582, 0.1713, 0.3249, 0.5, 0.6751, 0.8287, 0.9418, 1} areGauss-Legendre-Lobatto collocation points (since both t0 = 0 andtf = 2 are fixed we take the interior collocation points asGauss-Legendre-Lobatto). Thus, the collocation points from [0, 2] are

    {t0, t1, . . . , t7, t8} ={0.0000, 0.1165, 0.3426, 0.6498, 1, 1.3502, 1.6574, 1.8835, 2}.

    (ii) Define Lagrange polynomials

    Lk(τ) =8∏

    l = 0k 6= l

    [t − tltk − tl

    ], k = 0, 1, . . . , 8.

    Systems Optimization Winter Semester 2014/15 Part II: Dynamic Optimization 6. Optimal Control Problems

    TU Ilmenau

  • 5.4.1. Global orthogonal collocation.. Example...(iii) Define collocation polynomials for the states x1(t),x2(t) and thecontrol variable u(t).

    x̂1(t) =8∑

    k=0

    x1kLk(t), x̂2(t) =8∑

    k=0

    x2kLk(t), (54)

    û(t) =8∑

    k=0

    ukLk(t). (55)

    (iv) Discretization of the model equations using the collocationspoints:

    8∑k=0

    x1k L̇k(tl) = x2l , l = 0, 1, . . . ,N. (56)

    8∑k=0

    x2k L̇k(tl) = ul , l = 0, 1, . . . ,N. (57)

    Systems Optimization Winter Semester 2014/15 Part II: Dynamic Optimization 6. Optimal Control Problems

    TU Ilmenau

  • 5.4.1. Global orthogonal collocation.. Example...

    Now, define the matrix (8 + 1)× (8 + 1) matrix

    D =

    L̇0(t0) L̇1(t0) . . . L̇N(t0)

    L̇0(t1) L̇1(t1) . . . L̇N(t1)...

    . . ....

    L̇0(t8) L̇1(t8) . . . L̇N(t8)

    in short D = (L̇k(tl))0 ≤ k ≤ 80 ≤ l ≤ 8.

    Using this, equations (56) and (57) can be written compactly as

    Dx1 = x2 (58)

    Dx2 = u. (59)

    where x1> = (x10, x11, . . . , x18), x2

    > = (x20, x21, . . . , x28) andu> = (u0, u1, . . . , u8).

    Systems Optimization Winter Semester 2014/15 Part II: Dynamic Optimization 6. Optimal Control Problems

    TU Ilmenau

  • 5.4.1. Global orthogonal collocation.. Example...(v) Discretization of the performance criteria

    J(u) =1

    2

    8∑k=0

    u2k

    (vi) The discretization leads to the nonlinear optimization problem

    (NLP) minu

    1

    2

    8∑k=0

    u2k (60)

    subject to (61)

    Dx1 = x2 (62)

    Dx2 = u (63)

    x10 = 2, x18 = 0, (64)

    x20 = 1, x28 = 0. (65)

    This a quadratic optimization problem.Systems Optimization Winter Semester 2014/15 Part II: Dynamic Optimization 6. Optimal Control Problems

    TU Ilmenau

  • 5.4.1. Global orthogonal collocation.. Example...

    Matlab program

    Systems Optimization Winter Semester 2014/15 Part II: Dynamic Optimization 6. Optimal Control Problems

    TU Ilmenau

  • 5.4.1. Global Collocation...Advanateges/Disadvantages

    Advantages:

    The problem NLP can be solved using a nonlinear optimizationsolver.

    The collocation provides smooth polynomial approximation of thestate variables on the whole of [t0, tf ].

    Disadvantages:

    Optimal control problems with stiff DAEs may require a largenumber of collocation points; which may lead to a large NLP.

    Collocation of control variables provides smooth polynomialapproximations. But, it may not be necessary to have smoothcontrols on the whole of [t0, tf ].

    Systems Optimization Winter Semester 2014/15 Part II: Dynamic Optimization 6. Optimal Control Problems

    TU Ilmenau

  • 5.4.1. Global collocation ... ResourcesReferences:• Rao, A. V., etal : Algorithm 902: GPOPS, A MATLAB Software forSolving Multiple-Phase Optimal Control Problems Using The GaussPseudospectral Method. ACM Trans. Math. Soft., V. 37, No. 2,2010, No. 22, pp. 1-39.• Benson, D. A., Huntington, G. T., Thorvaldsen, T. P., and Rao, A.V.: Direct Trajectory Optimization and Costate Estimation via anOrthogonal Collocation Method. Journal of Guidance, Control, andDynamics, Vol. 29, No. 6, 2006, pp. 1435-1440.• Garg, D., Advances in Global Pseudospectral Methods for OptimalControl, Ph.D. Thesis, Department of Mechanical and AerospaceEngineering, University of Florida, August 2011.• Huntington, G.T.; Rao, A.V.:A Comparison between Global andLocal Orthogonal Collocation Methods for Solving Optimal ControlProblems. American Control Conference (2007).

    Systems Optimization Winter Semester 2014/15 Part II: Dynamic Optimization 6. Optimal Control Problems

    TU Ilmenau

  • 5.4.1. Global collocation ... Resources..

    Open source Software:GPOPS=General Pseudospectral OPtimal Control Software• This is a Matlab based toolbox.• It has an interface to the NLP solvers SNOPT and IpOpt.• Optimal control problems on a time interval [t0, tf ] are firsttransformed to stadard time interval [−1, 1] and then after collocated.• GPOPS also provides estimates for the costates of an optimalcontrol problem.

    Systems Optimization Winter Semester 2014/15 Part II: Dynamic Optimization 6. Optimal Control Problems

    TU Ilmenau

  • 5.4.2. Orthogonal collocation on finite elements(OCF) = local collocationOrthogonal collocation on finite elements (OCF) = local collocation.• Divide the interval [t0, tf ] into subintervals known as elementsusing t1, t2, . . . , tM = tf selected from [t0, tf ].

    In general, the length of all the elements ∆tl = tl+1 − tl ,l = 0, 1, . . . ,M, should not be necessarily equal.• Select collocation points 0 = τ0 < τ1 < τ2 < . . . τN ≤ 1 to definecollocation points:

    tlk = tl + τk(tl+1 − tl), k = 0, 1, . . . ,N, l = 0, 1, . . . ,M − 1.on the subintervals [tl , tl+1], l = 0, 1, . . . ,M − 1.

    Systems Optimization Winter Semester 2014/15 Part II: Dynamic Optimization 6. Optimal Control Problems

    TU Ilmenau

  • 5.4.2. Orthogonal collocation on finite elements...• Define a collocation polynomial for xi (t), i = 1, . . . , n, anduj(t), j = 1, . . . ,m, on [tk , tk+1] so that

    x(l)i (t) =

    N∑k=0

    x(l)ik Llk(t), i = 1, . . . , n; and (66)

    u(l)j (t) =

    N∑k=0

    u(l)jk Llk(t), j = 1, . . . ,m. (67)

    where

    Llk(t) =N∏

    ν = 0ν 6= kl

    [t − tνtlk − tν

    ]

    for l = 0, 1, . . . ,M − 1.Systems Optimization Winter Semester 2014/15 Part II: Dynamic Optimization 6. Optimal Control Problems

    TU Ilmenau

  • 5.4.2. Orthogonal collocation on finite elements...

    Requirements:

    The approximation of the state variables should becontinuous on [t0, tf ]. Hence

    x li (tl+1) = xl+1i (tl+1), l = 0, 1, . . . ,M − 2. (68)

    This implies that, the polynomial x li (t) on [tl , tl+1] and thepolynomial x l+1i (t) on [tl+1, tl+2] should have same value at thecommon boundary tl+1 of the intervals; i.e. these equalitiesshould hold at each of the interior points t1, t2, . . . , tM−1 of theinterval [t0, tf ].

    The control variables can be discontinuous at the boundariesof the subintervals.

    Systems Optimization Winter Semester 2014/15 Part II: Dynamic Optimization 6. Optimal Control Problems

    TU Ilmenau

  • 5.4.2. Orthogonal collocation on finite elements...

    Analogous to global collocation, for the collocation on the interval[tl , tl+1] we define

    Dl =

    L̇0l(t0l) L̇1l(t0l) . . . L̇Nl(t0l)

    L̇0l(t1l) L̇1l(t1l) . . . L̇Nl(t1l)...

    ... . . ....

    L̇0l(tNl) L̇1l(tNl) . . . L̇Nl(tNl)

    , l = 0, 1, . . . ,M;

    xli =

    x li0x li1...

    x liN

    , i = 1, . . . , n, l = 0, 1, . . . ,M.The vectors ulj, j = 1, . . . ,m, l = 0, 1, . . . ,M. are also defined in a likemanner.

    Systems Optimization Winter Semester 2014/15 Part II: Dynamic Optimization 6. Optimal Control Problems

    TU Ilmenau

  • 5.4.2. Orthogonal collocation on finite elements...

    Note that the discretization of ẋ = f (x , u, t)on the intervals [tl , tl+1] can be written as

    Dlxli = Fil

    ((xl1, x

    l2, . . . , x

    ln), (u

    l1,u

    l2, . . . ,u

    lm)), (69)

    i = 1, . . . , n; l = 0, 1, . . . ,N. (70)

    Similarly, the algebraic equations 0 = g(x , u, t) can be discretized as

    0 = Gjl

    ((xl1, x

    l2, . . . , x

    ln), (u

    l1,u

    l2, . . . ,u

    lm)), (71)

    j = 1, . . . ,m; l = 0, 1, . . . ,N. (72)

    Systems Optimization Winter Semester 2014/15 Part II: Dynamic Optimization 6. Optimal Control Problems

    TU Ilmenau

  • 5.4.2. Orthogonal collocation on finite elements...With these conventions, the orthogonal collocation of the problemOptCtrl on finite elements can be written as the nonlinearoptimization problem

    (NLP) minulj

    0 ≤ l ≤ M1 ≤ j ≤ m

    M∑l=0

    N∑k=0

    f0(

    (xl1, xl2, . . . , x

    ln), (u

    l1,u

    l2, . . . ,u

    lm), tlk

    )

    subject to

    Dlxli − Fil = 0, i = 1, . . . , n;

    Gjl = 0, j = 1, . . . ,m;

    umin,j ≤ uljk ≤ umax ,j , , j = 1, . . . ,m, k = 0, 1, 2 . . . ,N,xmin,i ≤ xlik ≤ xmax ,i , i = 1, . . . , n, k = 0, 1, 2 . . . ,N,l = 0, 1, . . . ,M − 1,

    Systems Optimization Winter Semester 2014/15 Part II: Dynamic Optimization 6. Optimal Control Problems

    TU Ilmenau

  • 5.4.2. Orthogonal collocation on finite elements...

    with the additional continuity constraints

    x liN − x l+1i0 = 0, i = 1, . . . , n, l = 0, 1, . . . ,M − 2.

    In the discussion above:

    the number M and the position of t1, t2, . . . , tM−1 in [t0, tf ] ispredetermined. It is also possible to take t1, t2, . . . , tM−1 asvariables in the optimization problem above. This leads to anadaptive orthogonal collocation on finite elements. However, theproblem becomes more complicated and computationallyexpensive.

    In general, it is advisable to use lower degree polynomials forthe collocations on each of the intervals [tl , tl+1]; i.e. use a fewnumber of collocation points on each [tl , tl+1].

    Systems Optimization Winter Semester 2014/15 Part II: Dynamic Optimization 6. Optimal Control Problems

    TU Ilmenau

  • 5.4.2....Advantages/DisadvantagesAdvantages:

    The problem NLP can be solved using state-of-the-art large-scalenonlinear optimization solvers.

    OCF is more accurate than the global collocation.

    Control problems with stiff DAEs are better approximated usingthe OCF approach.

    Allows to consider problems with discontinues controls.

    Disadvantages:

    Commonly, the OCF approach leads to a very large problem;therefore, computationally intensive.

    Fixing the number and position of the points t1, t2, . . . , tM−1 in[t0, tf ] may not provide accurate optimal controls.

    Guarantees only a piecewise smooth polynomial approximation forthe state variables on [t0, tf ]; while the global collocation providesa smooth polynomial approximation on the whole of [t0, tf ].

    Systems Optimization Winter Semester 2014/15 Part II: Dynamic Optimization 6. Optimal Control Problems

    TU Ilmenau

  • 5.4.2....Resources

    Literature:• J.E. Cuthrell, L.T. Biegler: On the optimization ofdifferential-algebraic process systems. AIChe Jounral, V. 33, 1257 –1270, 1987.• L.T. Biegler. Solution of dynamic optimization problems bysuccessive quadratic programming and orthogonal collocation.Computers and Chemical Engineering, V. 8, 243 – 248, 1984.• L.T. Biegler. An overview of simultaneous strategies for dynamicoptimization. Chemical Engineering and Processing, V. 46, 1043 –1053, 2007.• L. Biegler, A. Cervantes, A. Wächter, Advances in simultaneousstrategies for dynamic optimization, Chemical Engineering Science V.57, 575–593, 2002.

    Systems Optimization Winter Semester 2014/15 Part II: Dynamic Optimization 6. Optimal Control Problems

    TU Ilmenau

  • 5.4.2...Resources

    Software:• JModelica: http://www.jmodelica.org/• Dyopt: DYNAMIC OPTIMISATION CODE FOR MATLAB.http://www.kirp.chtf.stuba.sk/ fikar/research/dynopt/dynopt.htm.See M. Čižniar, D. Salhi, M. Fikar, and M.A. Latifi: A MATLABPackage for Orthogonal Collocations on Finite Elements in DynamicOptimisation. Proceedings of the 15th Int. Conference ProcessControl ’05, Štrbské Pleso, June 7-10, 2005, Slovakia.

    Systems Optimization Winter Semester 2014/15 Part II: Dynamic Optimization 6. Optimal Control Problems

    TU Ilmenau