PSOPT / psopt

PSOPT Optimal Control Software
GNU Lesser General Public License v2.1
200 stars 76 forks source link

Invalid number in NLP function or derivative detected. #54

Closed TimKrause2 closed 2 months ago

TimKrause2 commented 4 months ago

I'm trying a thrust vector problem. I've modified launch.cxx for a single phase with constant force and constant mass. When I run psopt the IPOPT fails with the message: EXIT: Invalid number in NLP function or derivative detected. I've included a link to user.cxx on Google Drive.

user.cxx

vmbecerra commented 4 months ago

Hello Tim,

The error you are getting is being produced by IPOPT. I tried changing the derivatives to "numerical" but the same error occurs. As I note that IPOPT does not seem to be completing any iterations before exiting with an error. This indicates that one of your functions (either dae() or events()) is producing an invalid number at the initial guess, or their derivatives are invalid. I suggest you try printing to screen the values returned by the above functions (arrays 'derivatives' and 'path' in function dae(), and array 'e' in function events() ), so you can inspect them before the program exits. You may be able to see the anomalous number(s) then.

Best wishes,

Victor.

TimKrause2 commented 4 months ago

Thanks for taking a look at it. I'll try your advice.

TimKrause2 commented 4 months ago

I found the reason for the error. It was in my use of rv2oe. I used an orbit with an inclination of zero. rv2oe calculates the cross product of the z-axis with the angular momentum vector to find the direction of the ascending node. In my case those two vectors are parallel and the result is the zero vector. Further on in the function it divides by the length of this vector and produces a nan.