NASA-AMMOS / aerie

A software framework for modeling spacecraft.
https://nasa-ammos.github.io/aerie-docs/
MIT License
73 stars 19 forks source link

Laguerre solver can enter an infinite loop #1305

Open bradNASA opened 10 months ago

bradNASA commented 10 months ago
          The Laguerre solver can enter an infinite loop with polynomial coefficients [Double.MAX_VALUE, -1.0].  This is currently a problem for the SRL cruise model.  Inside the solver, the variables inside the `while(true)` loop are mostly (if not all) NaNs at some point, disallowing it to find and return a root.

A bandaid for this case could be to solve linear Polynomials in this function directly and only use Laguerre for higher order polynomials.

We came across another case where a root-finding solver (maybe this one) took a long time to converge for coefficients close to 0.0. I don't know if David Legg did anything to fix or avoid it or if we avoided it in the mission model.

_Originally posted by @bradNASA in https://github.com/NASA-AMMOS/aerie/pull/1253#discussion_r1467891579_

bradNASA commented 6 months ago

This commit https://github.com/NASA-AMMOS/aerie/commit/762a534a51a5d5f90425c0bccf625f804acb88b2 addresses this problem for linear polynomials at least using the suggested bandaid. It's unclear to me if this is just as easy to run into for higher order polynomials. I thought about closing this, but if we don't fully resolve it, we should at least make sure warnings for this are documented in appropriate places, minimally in the javadoc for the function that uses the Laguerre solver and the resource approximation functions.