MatthewPeterKelly / OptimTraj

A trajectory optimization library for Matlab
MIT License
598 stars 207 forks source link

Bug (?) in OptimTraj wrapper for GPOPS? #19

Open stumarcus314 opened 7 years ago

stumarcus314 commented 7 years ago

I'm having some trouble getting the OptimTraj gpops method to work on my problem in certain cases. Do you know what might be causing the error below? I think this error may be related to how OptimTraj wraps GPOPS-II, because whenever I use GPOPS-II independently from OptimTraj on my optimal control problem, I never get this error.

| | | Finding Solution on Mesh 2 | |___| Computing Radau Points, Integration Weights, and Integration Matrix Creating Bounds For Nonlinear Program Creating Guess For Nonlinear Program Error using griddedInterpolant Interpolation requires at least two sample points in each dimension.

Error in interp1 (line 161) F = griddedInterpolant(X,V,method);

Error in gpopsGuessRPMI

Error in gpopsSolveRPMI

Error in gpopsMeshShell

Error in gpops2

Error in gpopsWrapper (line 84) output = gpops2(setup);

Error in optimTraj (line 190) soln(iter) = gpopsWrapper(P);

Error in invoke_OptimTraj (line 176) soln = optimTraj(problem);

MatthewPeterKelly commented 7 years ago

If it works natively in GPOPS, but not when called from OptimTraj, then it is probably a bug. One thing to check is that you've properly converted the problem into OptimTraj, since it uses the opposite matrix transpose orientation when compared to GPOPS. Have you checked to make sure that the other methods in OptimTraj are able to solve the problem correctly?

stumarcus314 commented 7 years ago

Yes, all the other OptimTraj methods (trapezoidal, Hermite-Simpose, Runge-Kutta, and Chebyshev) correctly solve the problem.

MatthewPeterKelly commented 7 years ago

Hmm... Sounds like a bug!

Unfortunately, I no longer have a license for GPOPS-II, so I can't do the debugging myself. It would be great if you or someone else with a license would be able to play around and see if you can find the bug.

I have a few ideas that might be helpful:

mhuzaif2 commented 5 years ago

I faced a similar issue and fixed it by carefully going through matrix transpose orientations.

MatthewPeterKelly commented 5 years ago

@mhuzaif2 - did you find a bug in the OptimTraj implementation while you were investigating this issue, or was it something in your code? If you did find a bug in OptimTraj, it would be great if you could make a pull request that fixed it (or just add enough detail for someone else to implement the fix). Thanks!

mhuzaif2 commented 5 years ago

@MatthewPeterKelly - This one was a bug in my code. I just wanted to confirm that the difference of convention might have been overlooked.

MatthewPeterKelly commented 5 years ago

@mhuzaif2 - Thanks for the update! You're responses provide good context here.