OptimTraj icon indicating copy to clipboard operation
OptimTraj copied to clipboard

Bug (?) in OptimTraj wrapper for GPOPS?

Open stumarcus314 opened this issue 8 years ago • 7 comments

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);

stumarcus314 avatar Sep 09 '16 15:09 stumarcus314

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?

MatthewPeterKelly avatar Sep 12 '16 19:09 MatthewPeterKelly

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

stumarcus314 avatar Sep 12 '16 20:09 stumarcus314

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:

  • See if there is a bug in the wrapper for the matrix transpose orientation: GPOPS-II and OptimTraj use opposite conventions.
  • Sometimes GPOPS-II goes crazy if any user-defined functions throw out a NaN. Make sure that none of your functions can return a NaN (for any possible input).
  • See if you can use a different initial guess (perhaps one generated by a different method) when you call GPOPS, and see if the problem persists.

MatthewPeterKelly avatar Sep 14 '16 15:09 MatthewPeterKelly

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

mhuzaif2 avatar Oct 05 '18 16:10 mhuzaif2

@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!

MatthewPeterKelly avatar Oct 06 '18 11:10 MatthewPeterKelly

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

mhuzaif2 avatar Oct 06 '18 21:10 mhuzaif2

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

MatthewPeterKelly avatar Oct 25 '18 01:10 MatthewPeterKelly