Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GPOPS-II Interpolation Function Handle returned by OptimTraj #20

Open
stumarcus314 opened this issue Sep 9, 2016 · 4 comments
Open

Comments

@stumarcus314
Copy link

stumarcus314 commented Sep 9, 2016

In gpopsWrapper.m, OptimTraj provides an interpolation function handle for the GPOPS-II solution using pchip, as per the code below. Is pchip the most accurate way to interpolate the GPOPS-II solution?

soln.interp.state = @(t)( interp1(tSoln',xSoln',t','pchip',nan)' );
soln.interp.control = @(t)( interp1(tSoln',uSoln',t','pchip',nan)' );

The formula for the GPOPS-II state is given in equation (25) of the GPOPS-II paper:

Patterson, Michael A., and Anil V. Rao. "GPOPS-II: A MATLAB software for solving multiple-phase optimal control problems using hp-adaptive Gaussian quadrature collocation methods and sparse nonlinear programming." ACM Transactions on Mathematical Software (TOMS) 41.1 (2014): 1.

http://dl.acm.org/citation.cfm?id=2558904

@stumarcus314 stumarcus314 changed the title GPOPS Interpolation Function Handle returned by OptimTraj GPOPS-II Interpolation Function Handle returned by OptimTraj Sep 9, 2016
@MatthewPeterKelly
Copy link
Owner

Excellent Question!

You're totally correct - the implementation for the OptimTraj interpolation of GPOPS-II solutions is not the correct way to perform this interpolation, but it does work quite well, because of how the tSoln, xSoln, and uSoln grids are constructed by GPOPS.

There would be two good ways to improve this interpolation:

  1. If GPOPS-II updates their code to provide a function handle for interpolation, then we could just call that.
  2. The correct interpolation formulas are already implemented in the ChebFun toolbox, which OptimTraj already has as a dependency (for the Chebyshev method). The tricky part is extracting the correct segment bounds when performing the interpolation.

Why was the code written this way? Like most short-comings in this toolbox, because I just didn't have enough time. I originally implemented the wrapper for GPOPS-II to verify that my solutions were correct. At the time, I was just using the interp() method for making nice plots. It was never worth the day or two of programming time that it would take to make the interpolation use the correct formulas.

How large are the errors? Let's say that GPOPS has a single 5th-order segment. Here, I would interpolating it using six 3rd-order segments. This should be a pretty good approximation, provided that the 5th-order segment is well behaved, which it will be for the vast majority of segments. If anyone has time to work out the specific math, let me know! This would be a great numerical methods extra credit problem.

@areusiriuses
Copy link

May i ask a question that how to get pneumatic parameter using interpolation? I have alredy got the oringinal data ponits of pneumatic parameter but i want to get the pneumatic parameter with specific Mach number and Angle of attack...thankyou

@MatthewPeterKelly
Copy link
Owner

MatthewPeterKelly commented May 3, 2019 via email

@areusiriuses
Copy link

THANK YOU~I have solved this problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants