matt-weinstein / adigator

Matlab Algorithmic Differentiation Toolbox
22 stars 5 forks source link

Unable to use griddedInterpolant #7

Open WJWest opened 4 years ago

WJWest commented 4 years ago

Hi ADiGator creators,

Thank you so much for the work that you put into this tool!

I am currently busy with my Masters degree where we are solving the minimum lap time optimal control problem for a Formula 1 car. We are using GPOPS as the optimal control solver and want to use ADiGator as the derivatives supplier.

As part of the problem we need to provide the track geometry so that the car does not exceed track limits. This is mostly a lookup-table type of exercise (seeing that the track geometry will not change but the number of points at which we need to evaluate the track changes with each iteration).

I have investigated various ways in which we can retrieve the track geometry, and have narrowed it down to the following methods:

In some of the larger simulations it can take up to 15 hours to compute a solution so any means of optimising the code will help a lot.

ADiGator works well when we use spline or interp1, but gives the following error when we switch to the griddedInterpolant method:

Error using griddedInterpolant/subsref Invalid arguments specified in evaluating the interpolant.

Can you please help us to address this issue?

Kind regards

matt-weinstein commented 4 years ago

The trouble with the operator overloading under the hood is that you are limited to operations which are overloaded - griddedInterpolant is not currently overloaded.

In order to use it, it would need to be overloaded. (See: https://github.com/matt-weinstein/adigator/blob/master/lib/%40cada/cada.m#L567 / https://github.com/matt-weinstein/adigator/blob/master/lib/%40cada/interp1.m )

The derivative rules for these operations tend to be pretty straightforward - the difficult part in implementing is trying to figure out what matlab actually does given a particular set of inputs.