The optimal control problem for the cart system 1 is provided below. z1 and z2 are the position and velocity of the cart and they comprise the states. f is the force applied and there is a drag force which is proportional to the velocity of the cart. The system starts from rest and additional boundary condition is placed at the end of the trajectory. Along the trajectory the control effort is minimized from time 0 to 2.
The system admits the following analytical solution, which can be later used to verify the numerical solution and its accuracy.
Direct methods 2 are used to solve optimal control problem for a cart system. The optimal control problem is discretized and transformed to a nonlinear optimization problem and solved using the state of the art solver IPOPT. The numerical methods used for discretization are
- single shooting with piecewise constant control (RK45)
- multiple shooting with piecewise constant control (RK45)
- trapezoidal with piecewise linear/constant control
- hermite simpson with piecewise linear control
- LGL pseudospectral (The quadrature and diff matrices are taken from 3)
To run the programs the following are required
Footnotes
-
Conway, B. A. and K. Larson (1998). Collocation versus differential inclusion in direct optimization. Journal of Guidance, Control, and Dynamics, 21(5), 780–785 ↩
-
Diehl, Moritz, and Sébastien Gros. "Numerical optimal control." Optimization in Engineering Center (OPTEC) (2011). ↩
-
Shen, Jie, Tao Tang, and Li-Lian Wang. Spectral methods: algorithms, analysis and applications. Vol. 41. Springer Science & Business Media, 2011. ↩