Derivative of a Summation in Optimal Control Problem

48 Views Asked by At

I am attempting to solve for the costate on an optimal control problem and am having difficulties solving the derivative $\frac{dL}{dx}$. Due to the fact that L contains a summation of x terms. x and u are both 2X8 matrices.

State Equation: $$ f(x,u)=\dot{x} = u $$ Cost Function: $$ J = \int_0^{t_f} L(x,u) dt $$ where N=6 $$ L(x,u)=\sum_{i=1}^{N+1} ||x_i-x_{i-1}||^2+\sum_{i=1}^{N}||u_i|| $$ In order to solve the costate, I am using a 1st order approximation: $$ p_{i-1}=p_{i}-\dot{p}*\Delta t $$ where $$ \dot{p}=-(\frac{df}{dx})^Tp-(\frac{dL}{dx})^T $$

How do I solve $\frac{dL}{dx}$? I am getting hung up on the summation. $$ \frac{d}{dx}(\sum_{i=1}^{N+1} ||x_i-x_{i-1}||^2+\sum_{i=1}^{N}||u_i||) $$

I read in another post that the derivative of a summation can be calculated as the summation of the derivatives, but when I look at L, it seems to me that it is not in terms of x at all because $||x_{i}-x_{i-1}||^2$ is a constant; however mathematically, $\frac{dL}{dx}$ can't equal zero, or else $\dot{p}=0$ which I know is incorrect.

Thank you for your time.

1

There are 1 best solutions below

0
On

Think of

$$ S = ||x_2-x_1||^2+||x_3-x_2||^2+||x_4-x_3||^2 $$

Here

$$ \frac{dS}{d x_1} = -2(x_2-x_1) = 2x_1-2x_2\\ \frac{dS}{d x_2} = 2(x_2-x_1)-2(x_3-x_2)=-2x_1+4x_2-2x_3\\ \frac{dS}{d x_3} = 2(x_3-x_2)-2(x_4-x_3)=-2x_2+4x_3-2x_4\\ \frac{dS}{d x_4} = 2(x_4-x_3)=-2x_3+2x_4 $$

and finally

$$ \frac{dS}{dx} = 2M x $$

where

$$ M = \left( \begin{array}{cccc} 1 & -1 & 0 & 0\\ -1 & 2 & -1 & 0\\ 0 & -1 & 2 & -1\\ 0 & 0 & -1 & 1 \end{array} \right) $$