Extension:
Variable end‐point conditions
Some applications involve the case when one of the end points, or both, are variable (not fixed).
How to solve the problem of Lagrange minJ(x)tb f(x,x,t)dt
t a
when ta , tb , x ta and x tb are NOT fixed.
4/20/2020 @2020 New York University Tandon 376 School of Engineering
Classical Example
Context: A boatman wants to find the optimal path leading to the shortest time when crossing a river
from a fixed initial point on one bank to an unspecified terminal point on the other bank.
4/20/2020 @2020 New York University Tandon 377 School of Engineering
4/20/2020
@2020 New York University Tandon School of Engineering
378
Left bank
y
Right bank
0l
x
Water current
4/20/2020
@2020 New York University Tandon 379 School of Engineering
Standing Assumptions
H1: There is no cross current so that the current velocity is everywhere directed downstream along the y-direction.
H2: The downstream current speed w depends only on x :
ww(x), 0xl.
H3: The boat travels at a constant natural speed v0 .
x ( t ) v 0 c o s ( t ) ,
Modeling
If the path of the boat is represented by a curve : x t
yt for0tT
for suitable functions t , t , then the absolute
velocity of the boat satisfies
where (t) is the steering angle of the boat from the x-axis.
y ( t ) v 0 s i n ( t ) w t
4/20/2020 @2020 New York University Tandon 380 School of Engineering
0 0dx dt Then,
T T dx
0 v0 cos
Time of Transit
The time of transit T of the boat can be calculated as TTdtT dtdx, notingdx(t).
. note: cos 0
Now, we use x as the parameter(why possible?) for the curve :
: yY(x), 0xl. Indeed,Y(x) (x) .
1
4/20/2020 @2020 New York University Tandon 381 School of Engineering
Note that
Y(x) dy (t) sin e(x) ,
dx (t) cos where e(x)w(x).
v0 Then,
Ycosesine 1cos2 e(x)Y(x) 1e(x)2 Y(x)2
cos 1Y(x)2
.
4/20/2020 @2020 New York University Tandon School of Engineering
382
Problem Formulation
Summarizing the above, the minimum transit time problem becomes:
1 l 1Y(x)2 minTT(Y)v0 0 e(x)Y(x) 1e(x)2 Y(x)2 dx
where
Y C1[0,l] the class of continuously differentiable functions
over 0 x l.
4/20/2020 @2020 New York University Tandon 383 School of Engineering
Comment
Clearly, the above min problem is subject to one constraint at the starting point:
Y(x0)y0, inthepresentcase, x0,y0(0,0)
along with the terminal constraint C:(x,y)0, inthiscase,xl0.
No constraint on y ! Such a modified problem is often called:
James Bernoulli’s Brachistochrone Problem (1697).
4/20/2020 @2020 New York University Tandon 384 School of Engineering
Variable End‐point Conditions
It corresponds to the following situation: for the optimization problem
minJtb fx,x,tdt, t
a
thevaluesofta, tb, xta, xtbarenot
necessarily fixed.
Question: what are the end-point conditions
that the optimal variables must satisfy?
4/20/2020 @2020 New York University Tandon 385 School of Engineering
The Transversality Condition
(Necessary Condition)
4/20/2020
@2020 New York University Tandon 386 School of Engineering
Optimal values of ta , tb , xta , xtb must satisfy:
t
f xf tb f x(t)b 0.
t x ta x ta
4/20/2020
@2020 New York University Tandon 387 School of Engineering
Ideas of Proof
For simplicity, assume that one end point, say ta,xtaisfixed.Then,ta 0,xta0.
In this case, the transversality condition reduces to:
f x f t f x ( t ) 0 .
x tb x
tb
4/20/2020
@2020 New York University Tandon School of Engineering
388
ta
tb
t
x t xv (t )
xt
tb tb
t ta
Ideas of Proof (cont’d)
Consider the increment J :
J b f x x , x x , t f x , x , t d t
tbtb fxx,xx,tdt
vv
tb v v
tbfxfxdtfx,x,t| t taxv xv ttb b
where Taylor’s series expansion was used to ignore H.O.T. Via integration by parts,
tb t tbd
f x f x dt f x f f x dt
xv xvxvb xdtxv ta ta ta
4/20/2020 @2020 New York University Tandon School of Engineering
389
Ideas of Proof (cont’d)
tb t tbd
f x f x dt f x f f x dt
xv xvxvb xdtxv ta ta ta
f x 0, usingELequationwithx t 0. xvtb va
Therefore,
J f x x v t f x , x , t | t t t b
b fxft fx ,
b
x t t b x t t b
usingxv tb x xb x xb tb.
So, J 0 the transversality condition.
4/20/2020 @2020 New York University Tandon 390 School of Engineering
4/20/2020
@2020 New York University Tandon School of Engineering
Special Cases
Case 1: All variations are independent The transversality condition
t
fxftb fx(t)b 0
t x ta x ta
implies
f xf t f xf t
0,
391
x t t a x t t b fxx(t) fxx(t) 0.
tta ttb
Case 2:
x(ta ), x(tb ), ta fixed; tb variable. The transversality condition
4/20/2020
@2020 New York University Tandon School of Engineering
Special Cases
t
f xf tb f x(t)b 0
t x ta x ta
implies
f(x,x,t)x(t)f (x,x,t)
0.
392
x t t b
4/20/2020
@2020 New York University Tandon School of Engineering
393
Example: an electric circuit
vi (t) –
C
v0(t)
i(t) +
R
Problem of Optimization
Maximize the average value of the output voltage v0 (t ) : JT v0(t)dt
T KTi2RdtT RC2v2dt
0
subject to the limited energy constraint:
00
0
withfixedv0(ta)0atta 0, andvariablev0(T)V.
4/20/2020 @2020 New York University Tandon 394 School of Engineering
Problem of Optimization
The augmented functional is defined by: J 1Tv hRC2Tv2dt.
a T0 0 1 0
We are interested in finding the optimal value
V* ofVv(T)thatmaximizesJ. 0a
4/20/2020 @2020 New York University Tandon 395 School of Engineering
4/20/2020
@2020 New York University Tandon 396 School of Engineering
v0
10, v (0)0, v (T)V 00
Outline of Solution
Using the Euler-Lagrange equation, we have
with 1/2hRC2T. 1
It is easy to solve the above linear equation:
v (t)ct2 ct 021
and, in particular,
V v (T ) c T 2 c T . 021
To determine the values of c and c , let’s invoke 12
the transversality condition to this example:
f v (T)0 2hRC2v (T)v (T)0
a0 100 v
0 tT
becauseta 0,tb Tandv0(0)arefixed.
So, it holds:
v (T ) 2c T c 0 (1)
0 2 1
Applying the constraint equation to arrive at
KT 21
2ctcdt 4c2T36ccT23c2T (2)
RC2021 32 21 1
4/20/2020 @2020 New York University Tandon 397 School of Engineering
4/20/2020
@2020 New York University Tandon 398 School of Engineering
Outline of Solution
By eqs. (1) and (2), we obtain:
1/2 1/2
c2T 3K ,c 3K .
4RC2T3 Therefore, the optimal value of V is:
1 4RC2T3 2
1/2 V*3KT .
4RC2
Exercise
What is the shortest path between two points on a sphere?
4/20/2020 @2020 New York University Tandon 399 School of Engineering
Solution (Geodesics on a Sphere) Problem formulation
Introduce “spherical polar coordinates” r, , : xrsincos, r x2 y2 z2,
yrsinsin, tan1 y/x, zrcos, cos1 z/r.
4/20/2020 @2020 New York University Tandon 400 School of Engineering
Solution (Geodesics on a Sphere) Then the surface of a sphere S
of radius a centered at 0 is:
x a s i n c o s ,
y a s i n s i n ,
z a cos , for 0 , 0 2 .
Let be a curve on the surface S that connects
two points P , P which is parametrized as: 01
4/20/2020
@2020 New York University Tandon 401 School of Engineering
Solution (Geodesics on a Sphere) x a s i n c o s ,
: y a s i n s i n ,
zacos, for 01
where is a function relating , on , and
, correspond to P ,P, resp., i.e. 01 01
z x2y2z2cos,i0,1 iiiii
i 0, .
4/20/2020 @2020 New York University Tandon 402 School of Engineering
Solution (Geodesics on a Sphere) The length L of is thus given by:
L 0 dx/d dy/d dz/d d
which implies
0
1222
12
1 sin2d
La
1 f , d.
0
To sum up, the problem reduces to minimizing L w.r.t.
= , subject to the terminal constraints: taniyi /xi,i0,1.
4/20/2020 @2020 New York University Tandon 403 School of Engineering
Solution (Geodesics on a Sphere)
By EL equation, it holds for any extremum function : d / d f , f , 0
where the last equality holds because f does NOT depend on . Thus,
f , C.
Simple computation gives
A/sin sin2sin2 for some constants A, .
4/20/2020 @2020 New York University Tandon 404 School of Engineering
Solution (Geodesics on a Sphere) Letting tan1/u, itholds:
d/dutan/ 1u2 tan2
that, upon integration on both sides, yields
cos1utan, or,
(*) cos1tan/tan
where the constants , can be determined using
the end conditions.
Using the Cartesian coordinates, (*) can be rewritten as: (**) xcos ysin ztan, (a plane crossing the center).
So, any geodesic curve indeed is an arc of some circle.
La, with theangle
4/20/2020 @2020 NewYorkUniversityTandon betweenOP andO4P05. School of Engineering 0 1
Outline
Dynamic Programming
A method for Multi-Stage Decision Making
• Basics of dynamic programming • Application examples
4/20/2020
@2020 New York University Tandon School of Engineering
406
Richard Bellman
Bellman’s Principle of Optimality
PO: An optimal policy has the property that whatever the initial state and the initial decision are, the remaining decisions must constitute an optimal policy with regard to the state resulting from the first decision.
4/20/2020 @2020 New York University Tandon 407 School of Engineering
4/20/2020
@2020 New York University Tandon 408 School of Engineering
Illustrative Figure of PO
Optimal trajectory cost
x(tf )
x(t)
J*(t0,x(t0))
x(t0 )
Illustrative Example of A Routing Network
4/20/2020
School of Engineering
409
d
k h
8 4b26
9 11
3 g 16
9 5 e 10i
a
7c47
l 14f 6
12j 8 @2020 New York University Tandon
m
Illustrative Example of A Routing Network (cont’d)
Problem:
Find the minimum-cost path that starts at node a and ends at any of the nodes k, l, m
4/20/2020 @2020 New York University Tandon 410 School of Engineering
Illustrative Example of A Routing Network (cont’d)
We will find the optimal path by performing a backward pass through the network.
Let J * be the minimum cost from a generic node q
q to any one of three possible final nodes. Then, J* 16, J* 8, J* 7, J* 6.
ghij
The next stage yields
J* min 3J*, 11J* min 19, 19 19.
dgh
4/20/2020 @2020 New York University Tandon 411 School of Engineering
Illustrative Example of A Routing Network (cont’d)
Thus, we have two optimal paths from node d: dgk and dhk. Similarly,
J* min 6J*, 10J*
min 68, 107 14
ehi and
J* min 4J*, 12J*
min 47, 126 11.
fij
Therefore, the optimal path emanating from node e
is ehk, and the path from node f is fil.
4/20/2020 @2020 New York University Tandon 412 School of Engineering
Illustrative Example of A Routing Network (cont’d)
The next stage yields
J* min 9J*, 2J*
min 919, 214 16
bde and
J* min 5 J*, 14 J*
min 514, 1411 19.
cef
Therefore, the optimal path emanating from node b is behk, and the path from node c is cehk.
4/20/2020 @2020 New York University Tandon 413 School of Engineering
Illustrative Example of A Routing Network (cont’d)
Finally, the initial, and thus final, stage yields
J* min 4J*, 7J* min 416, 719 20.
abc
Hence, the optimal, minimum total cost route from node a to any one of the three nodes k, l, m is abehk, and the total cost of this path is 20.
4/20/2020 @2020 New York University Tandon 414 School of Engineering
Comment:
In a nutshell,
“Dynamic Programming” is a technique for solving a complex problem in such a way that the problem is broken into several simpler steps.
4/20/2020 @2020 New York University Tandon 415 School of Engineering
4/20/2020
4573
@2020 New York University Tandon
416
1
43266 10
2751
413 343
9
4
Exercise
Find the shortest path from node 1 to node 10 in the following network. Also, find the shortest path from node 3 to node 10.
264 3383
School of Engineering
Solution to the “Blood Diamond” Problem
(97, 0, 1, 2, 0) or (97, 0, 1, 0, 2)
Do you know why?
4/20/2020 @2020 New York University Tandon 417 School of Engineering
Detailed Analysis based on PO
• IfNos.1‐3die,itremainsonlyNo.4andNo.5.
Then, No. 5 will vote against whatever No.4 proposes
to earn all diamonds.
So, the only option for No. 4 is to vote for No.3.
• AssoonasNo.3knowsthispoint,hewillpropose (100, 0, 0) to earn all diamonds while No.4 has to vote “yes” in order to survive.
4/20/2020 @2020 New York University Tandon 418 School of Engineering
Detailed Analysis based on PO
• As soon as No.2 knows this point, he will propose (98, 0, 1, 1) to win the support from No.4 and No.5, while giving up on No.3
• When No. 1 is aware of the optimal strategy of No.2, he will give up on No.2 and then propose (97, 0, 1, 2, 0) or (97, 0, 1, 0, 2) to win 3 votes including his own vote, the majority votes!!
4/20/2020 @2020 New York University Tandon 419 School of Engineering
Application to a Control Problem
Find a sequence of control actions {u(k)} to minimize the performance index
N 1 kk0
J (N,x(N))
x(k1) f(k,x(k),u(k)), x(k0)x0.
F(k,x(k),u(k))
where x(k) is the solution of the discrete-time system:
4/20/2020 @2020 New York University Tandon 420 School of Engineering
4/20/2020
@2020 New York University Tandon 421 School of Engineering
A Control Problem (cont’d)
Let J * be the minimum cost of transferring the system from k
x(k)totheterminalstatex(N).Clearly,J* (N,x(N)). N
Using the PO, we obtain J* (x(N 1))
N1
min F(N1,x(N1),u(N1))J*(x(N))
N
minF(N1,x(N1),u(N1))(N,x(N))
u(N1) u(N1)
min{F(N1,x(N1),u(N1)) u(N1)
( N , f ( N 1, x ( N 1) , u ( N 1) ) ) } .
A Control Problem (cont’d)
A recursive expression of this backward pass is (k0 k N ): J*(x(k)) min F(k,x(k),u(k))J* (x(k1))
k u(k) k1
k1
min F(k,x(k),u(k))J* (f(k,x(k),u(k)) .
u(k)
The backward pass is completed when k k0 .
Sincex0 xk0isknown,wefinduu(k0)intermsofx0. Then, proceed with the forward pass:
x(k), u(k) x(k 1), u(k 1)
4/20/2020 @2020 New York University Tandon 422 School of Engineering
Consider a scalar discrete-time system x(k1)2x(k)3u(k), x(0)4,
and the performance index 211
An Exercise
J x(2)10 x2(k)u2(k) .
2 k0
Goal: findtheoptimalu*=(u(0), u(1))thatminimizesJ.
4/20/2020 @2020 New York University Tandon 423 School of Engineering
Solution
u(0) = 2.0153, u(1) = ‐1.9237.
4/20/2020 @2020 New York University Tandon 424 School of Engineering
Allocation Problem: the scalar case
4/20/2020
@2020 New York University Tandon 425 School of Engineering
We want to maximize a noninteracting performance index
subject to
K
g (x ) b, g (x ) 0, x . iiiii
K
P f (x )
ii i1
i1
Solution based on PO
Foreaseofnotation,introducetheresourcevariableK : K
g(x) b
iiK i1
and define
F ( ) max f (x ) f(x).
KK KK
x ,,x 1K
K1
ii
i1
Also, define the policy variable x ( ) which maximizes ˆK K
theaboveF ( )foragiven .Particularly,x (b)x* . KK K ˆKK
4/20/2020 @2020 New York University Tandon 426 School of Engineering
Solution based on PO (cont’d)
F ( )f (x ( )) max
K1
KK KˆKK K1
x ,,x
1 K1
f(x) ii
ˆ subjectto g(x) g x ( ).
i1 Therefore,
K1 F()f(x())F {g x()}
K K K ˆK K K1 K K ˆK K
or, equivalently,
F ( )max f (x )F g (x )
K K xK K K K1 K K K subjectto gK(xK)K.
4/20/2020 @2020 New York University Tandon 427 School of Engineering
i1
iiKKKK
F K1 K1
Solution based on PO (cont’d)
In brief, the K -stage problem reduces to a simpler (K 1)-stage problem:
K 1 F()max f(x)
K1 K1
ii 1 K1
subjectto
g(x) g (x ) . i i K K K K1
4/20/2020
@2020 New York University Tandon 428 School of Engineering
i1
x ,,x
i1 K 1
Solution based on PO (cont’d)
In general, the following recurrence relation holds:
F()maxf(x)F g(x)
k k xk k k k1 k k k subject to
g ( x ) , k 1, 2 , , K , F ( ) 0 . kkk 00
So, the original K-stage problem is replaced by K (easier) one-stage decision problems.
4/20/2020 @2020 New York University Tandon 429 School of Engineering