9.2 Free DynProg with EPCs
EPCs: End Point Constraints
The problem can be interpreted to convert the system from its initial state to a given terminal state and minise the performance index at the same time.
The terminal contribution to the performance index could be omitted, since it has not effect on the solution (except a constant additive term to the performance index). (Poulsen 2012)
For a given free dynamic programming with end point constraints: minJ=ϕ(xN)+N−1∑i=0Li(xi,ui)s.t.xi+1=fi(xi,ui)x0=x_0xN=x_N where xi=[xi,1,xi,2,...,xi,M]T. Its i-th Hamiltonian function is: Hi(xi,ui,λi+1)=Li(xi,ui)+M∑jλTi+1fi(xi,j,yi,j)
The necessary condition for ˆu0,ˆu1,...,ˆuN−1 being critical points is given by the Euler-Lagrange equations: xi+1,j=fi(xi,j,ui,j)for j=1,2,...,M and i=0,1,2,...,N(state equations)λi,j=∂Hi∂xi,jfor j=1,2,...,M and i=0,1,2,...,N(costate equations)0=∂Hi∂ui,jfor j=1,2,...,M and i=0,1,2,...,N(stationarity conditions) where the boundary conditions are: x0=x_0xN=x_NλN,j=ν+∂ϕ(xN)∂xN,jfor j=1,2,...,M
Formulation of Exm 9.2
The equations to describe the dynamics of the chain are simplified to one dimensional unconstrained equation, and the angels are described in the Radian system. That is, For i=0,1,…N−1, we have: [zy]i+1=f([zy]i,[uv]i)=[zy]i+[uv]i=f([zy]i,θi)=[zy]i+l[cos(θi)sin(θi)]
where two end points of the chain are: [zy]0=[00][zy]N=[h0]
So the constraint u2i+v2i=l2 is no longer needed. Notice that the angels are not constrained, but they can be estimated to be between −0.5π and 0.5π.
With the new one dimensional unconstrained equation, the (steady state) potential energy can be used as the cost function: J=N−1∑i=012mg(yi+yi+1)=N−1∑i=0[mgyi+12mglsin(θi)] where the scalar ϕ, L in the standard form of the cost function can be expressed by the following equations with N fixed: ϕ([zy]N)=0L([zy]i,θi)=mgyi+12mglsin(θi)
The deterministic dynamic programming can be summarised as: minθ0,θ1,...,θN−1J=N−1∑i=0[mgyi+12mglsin(θi)]s.t.[zy]i+1=[zy]i+l[cos(θi)sin(θi)]for i=0,1,...,N−1[zy]0=[00][zy]N=[h0] where z1,z2,...,zN−1 and y1,y2,...,yN−1 are decision variables as well, but they are determined once θ0,θ1,...,θN−1 are chosen.
Solution of Exm 9.2
The i-th Hamiltonian function of can be expressed as:
Hi(zi,yi,θi,λzi+1,λyi+1)=mgyi+12mglsin(θi)+λzi+1[zi+lcos(θi)]+λyi+1[yi+lsin(θi)]
Hence the set of Euler-Lagrange equations can be expressed by the following five equations:
zi+1=zi+lcos(θi)yi+1=yi+lsin(θi)λzi=λzi+1λyi=mg+λyi+10=[12mg+λyi+1]cos(θi)−λzi+1sin(θi)
where the boundary conditions are:
[zy]0=[00][zy]N=[h0][λzλyθ]N=[νzνy1]
Numerical method can be used to find the optimal values. The calculate procedure for iterations can be expressed by the following five equations:
λzi+1=λziλyi+1=λyi−mgθi=arctan[(λyi+1+12mg)/λzi+1]zi+1=zi+lcos(θi)yi+1=yi+lsin(θi)
When h=6,L=10,M=14,N=6, the value of the costate vector at 0, [λzi,λyi]T0, is [−22.3645,68.6700].
When h=6,L=10,M=14,N=100, the value of the costate vector at 0, [λzi,λyi]T0, is [−22.4092,68.6700].
The two results can be visualised by the figure 1:

Figure 9.1: Result.
Vertical Force and Costate Vector
Determine the vertical force in the origin (i = 0). Compare this with the costate at the origin. Discuss your observations. Give a qualified guess on the sign of horizontal force in the origin.
The vertical forces at the left end and the right end are equal, and their sum equals the weight of the chain. So The vertical forces at the left end is 68.67, which is the same value as λyi.
The horizontal forces at different joints are the same. We can get the force at the end of the 2nd f3 sections by analyzing the balance of 3rd and 4th sections of the chain:
2f3sin(θ2)=2mg
So we can get f3=50.2457, so the value of horizontal force is 44.7289, which is two times of the value of λz0. When N=100, f50=44.8394, and the value of horizontal force is 44.8183. So we can say that the vertical force at the left end equals λy0, the horizontal force at the left end is two times of λz0.
9.2.1 Free DynProg with Partial End Point Constraints
Variant of Exm 9.2: Two Symmetric Half Chains
For i=0,1,…N−1, we have:
[zy]i+1=f([zy]i,[uv]i)=[zy]i+[uv]i=f([zy]i,θi)=[zy]i+l[cos(θi)sin(θi)]
where the boundary conditions are:
[zy]0=[00]zN/2=h/2
Numerical method is almost the same as that in the above section. The calculate procedure for iterations can be expressed by the following five equations:
λzi+1=λziλyi+1=λyi−mgθi=arctan[(λyi+1+12mg)/λzi+1]zi+1=zi+lcos(θi)yi+1=yi+lsin(θi)
The two results when N=6 and N=100 respectively can be visualized by the figure 2, which is the same as figure 1:

Figure 9.2: Result.
9.2.2 Continuous Free-DynProg-EPCs
Exm 9.2
Let s the distance along the wire. The positions along the wire obey
dds[zsys]=f(θs)=[cos(θs)sin(θs)]
where the boundary conditions are:
[zy]0=[00][zy]L=[h0]
So the potential energy in steady state can be expressed by:
J=∫S0ρgy/Sds
where
ϕ(θS)=0L(ys)=ρgy/S
The Hamiltonian function is:
Hs=ρgy/S+λzcos(θ)+λysin(θ)
Euler-Lagrange equations are:
˙z=cos(θ)˙y=sin(θ)−˙λz=0−˙λy=ρg/S0=−λzsin(θ)+λycos(θ)
The equations in ode45
can be expressed as:
θ=arctan(λy/λz)˙z=cos(θ)˙y=sin(θ)˙λz=0˙λy=−ρg/S
The results are compared with results when the number of sections of a chain is 6:

Figure 9.3: Result.
References
Poulsen, Niels Kjølstad. 2012. Dynamic Optimization. Technical University of Denmark.