Multiple Shooting - IPOPT

814 views
Skip to first unread message

Andrea Zanelli

unread,
Nov 5, 2014, 5:54:21 AM11/5/14
to casadi...@googlegroups.com
Hi,

I'm using casADi to solve optimal control problems discretized with the multiple shooting approach and I'm basically following the example from the summer school on Numerical Optimal control offered at IMTEK (see attachment). My question is the following: how are sensitivities of the initial value problems computed by casADi? As an implicit Runge-Kutta integration scheme is exploited computation of sensitivities is not straightforward and can be carried out in several ways. Is the Implicit Function Theorem approach exploited? How can second order derivatives be integrated in the formulation? 

Thanks for your help.
nmpc_ipopt.py

Andrea Zanelli

unread,
Nov 5, 2014, 6:05:51 AM11/5/14
to casadi...@googlegroups.com
Actually the example I posted has an explicit RK integrator...but this https://github.com/casadi/casadi/blob/master/docs/examples/python/vdp_multiple_shooting.py exploits a collocation scheme. How is sensitivities computation handled here? Thanks.

Joel Andersson

unread,
Nov 5, 2014, 6:22:14 AM11/5/14
to casadi...@googlegroups.com
Hello Andrea!

In the first example you sent, an explicit Runge-Kutta scheme is indeed used, or more precisely, the RK4 scheme. If you want to use an implicit Runge-Kutta scheme such as collocation instead, there are basically two possible approaches:

1. You can embed an "implicit function" in the expression graph. CasADi will then indeed calculate the derivatives using rules derived via the implicit function theorem. Since CasADi uses the source-code-transformation approach to AD, a new expression graph for the directional derivatives will be generated. This expression graph will contain calls to functions for calculating forward and reverse mode directional derivatives of the root-finding problem as well as calls for calculating the Jacobian as well as solving the resulting linear system (transposed for reverse mode AD). The linear solver and Jacobian functions used to calculate the directional derivatives are typically the same as what is being used internally to evaluate the implicit function (i.e. solve the root-finding problem). Higher order derivatives can be calculated by applying AD on the resulting graph, which in turn will exploit the derivative propagation rules for linear system solves. An implementation of this approach can be found in the example https://github.com/casadi/casadi/blob/master/docs/examples/python/implicit_runge-kutta.py. Note that this approach will calculate the exact derivative of the approximate solution to the initial-value problem.

2. A second approach, which will calculate an approximate derivative to the exact solution to the initial-value problem is possible if you use the "Integrator" class in CasADi. Here, CasADi will differentiate the DAE function and then generate a new integrator for integrating the augmented DAE system (original DAE + sensitivity equations). Since CasADi is using a special integrator formulation that can solve an initial-value problem in DAE _coupled_to_ a terminal value problem in DAE, this approach is possible for both forward and reverse mode derivatives to arbitrary order. You will find more details about this in my PhD thesis: https://lirias.kuleuven.be/bitstream/123456789/418048/1/thesis_final2.pdf. An implementation of this approach can be found in https://github.com/casadi/casadi/blob/master/docs/examples/python/sensitivity_analysis.py.

Best regards,
Joel






Reply all
Reply to author
Forward
0 new messages