Accurate Simulation for Numerical Optimal Control


  • Viktor Leek
  • Lars Eriksson



simulation, optimal control, direct multiple shooting, direct collocation


Accurate simulation of the numerical optimal control in software environments where call to simulation routines is explicit, for instance Matlab and SciPy. A discussion on the simulation aspects of numerical optimal control, how it may fail, and how such erroneous results can be detected using accurate simulation. The key contribution is how to accurately include a piecewise constant control input in the simulations, which is discussed in detail, including code examples. The technique is demonstrated on an example problem which show how simulation can be used to analyze optimal control problems with uncertainty, but also demonstrates how erroneous simulation may lead to erroneous conclusions.


Christian Andersson, Claus Führer, and Johan Åkesson. Assimulo: A unified framework for ode solvers. Mathematics and Computers in Simulation, 116:26–43, 2015.

Joel Andersson. A general-purpose software framework for dynamic optimization. PhD thesis, PhD thesis, Arenberg Doctoral School, KU Leuven, Department of Electrical . . . , 2013.

Joel AE Andersson, Joris Gillis, Greg Horn, James B Rawlings, and Moritz Diehl. Casadi: a software framework for non-linear optimization and optimal control. Mathematical Programming Computation, 11(1):1–36, 2019.

Uri M Ascher and Linda R Petzold. Computer methods for ordinary differential equations and differential-algebraic equations, volume 61. Siam, 1998.

John T Betts. Practical methods for optimal control and estimation using nonlinear programming. SIAM, 2010.

Lorenz T Biegler. Nonlinear programming: concepts, algorithms, and applications to chemical processes. SIAM, 2010.

Hans Georg Bock and Karl-Josef Plitt. A multiple shooting algorithm for direct solution of optimal control problems. IFAC Proceedings Volumes, 17(2):1603–1608, 1984.

John Charles Butcher. A history of runge-kutta methods. Applied numerical mathematics, 20(3):247–260, 1996.

M. Diehl, H. G. Bock, H. Diedam, and P. B. Wieber. Fast direct multiple shooting algorithms for optimal robot control. Lecture Notes in Control and Information Sciences, 340:65–93, 2006. ISSN 01708643. doi:10.1007/978-3-540-36119-0_4.

Moritz Diehl. Numerical optimal control. Technical report, KU Leuven, 2011.

John R Dormand and Peter J Prince. A family of embedded runge-kutta formulae. Journal of computational and applied mathematics, 6(1):19–26, 1980.

Charles William Gear and O Osterby. Solving ordinary differential equations with discontinuities. ACM Transactions on Mathematical Software (TOMS), 10(1):23–44, 1984.

Kjell Gustafsson. Traps and pitfalls in simulation. Technical report, Ericsson Mobile Communications AB.

Charles R Hargraves and Stephen W Paris. Direct trajectory optimization using nonlinear programming and collocation. Journal of guidance, control, and dynamics, 10(4):338–342, 1987.

Håkan Lundvall, Peter Fritzson, and Bernhard Bachmann. Event

handling in the openmodelica compiler and runtime system.

Linköping University Electronic Press, 2005.

C Majer, W Marquardt, and Ernst Dieter Gilles. Reinitialization of dae’s after discontinuities. Computers & chemical engineering, 19:507–512, 1995.

Guiyou Mao and Linda R Petzold. Efficient integration over discontinuities for differential-algebraic systems. Computers & Mathematics with Applications, 43(1-2):65–79, 2002.

H Maurer. Numerical solution of singular control problems using multiple shooting techniques. Journal of Optimization Theory and Applications, 18(2):235–257, 1976.

Anil V Rao. A survey of numerical methods for optimal control. Advances in the Astronautical Sciences, 135(1):497–528, 2009.

James Blake Rawlings, David Q Mayne, and Moritz Diehl. Model predictive control: theory, computation, and design, volume 2. Nob Hill Publishing Madison, WI, 2017.

Per E Rutquist and Marcus M Edvall. Propt-matlab optimal control software. Tomlab Optimization Inc, 260(1):12, 2010.

Lawrence F Shampine and Mark W Reichelt. The matlab ode suite. SIAM journal on scientific computing, 18(1):1–22, 1997.

LF Shampine, HA Watts, and SM Davenport. Solving nonstiff ordinary differential equations—the state of the art. Siam Review, 18(3):376–411, 1976.

Pauli Virtanen, Ralf Gommers, Travis E. Oliphant, Matt Haberland, Tyler Reddy, David Cournapeau, Evgeni Burovski, Pearu Peterson, Warren Weckesser, Jonathan Bright, Stéfan J. van der Walt, Matthew Brett, Joshua Wilson, K. Jarrod Millman, Nikolay Mayorov, Andrew R. J. Nelson, Eric Jones, Robert Kern, Eric Larson, C J Carey, ˙Ilhan Polat, Yu Feng, Eric W. Moore, Jake VanderPlas, Denis Laxalde, Josef Perktold, Robert Cimrman, Ian Henriksen, E. A. Quintero, Charles R. Harris, Anne M. Archibald, Antônio H. Ribeiro, Fabian Pedregosa, Paul van Mulbregt, and SciPy 1.0 Contributors. SciPy 1.0: Fundamental Algorithms for Scientific Computing in Python. Nature Methods, 17:261–272, 2020. doi:10.1038/s41592-019-0686-2.

O. von Stryk and R. Bulirsch. Direct and indirect methods for trajectory optimization. Annals of Operations Research, 37(1):357–373, 1992. ISSN 02545330. doi:10.1007/BF02071065.