I am investigating ways to solve an optimal control problem in an embedded way, preferably in Java. The system is modeled with triple integrator dynamics $u=\dddot{x}$ and solved with multiple shooting, with continuity constraints put on $x$, $\dot{x}$ and $\ddot{x}$ which are solved with Runge-Kutta-4 integration and optimized with an NLP solver. For $N$ shooting points I have $4N$ variables and about $3N$ equality constraints with the Runge-Kutta integration expressed within the constraints. Safe to say it quickly becomes computationally heavy, as I usually do $N=100$.
I've found it is quite difficult to express numerical integration within constraints to "normal" optimization libraries in a way that works (imsl and knitro). And when I do manage it becomes incredibly inefficient. I've been able to do it efficiently in python with CasADi, which handles integration well, but also performs automatic integration. The only other way I've been able to solve the problem is through AMPL which also supplies the solver (ipopt in this case) with automatic gradients. Other than AMPL the set of available auto-diff libraries for java is very small and none of them as far as I can tell would be viable to use with this kind of problem (here is a list https://www.autodiff.org/?module=Tools&language=Java ).
For instance, ipopt requires one to supply:
- objective function,
- gradient of the objective,
- constraint function values,
- Jacobian of the constraints,
- Hessian of the Lagrangian function,
which many of I think would not be easy enough to compute with those libraries listed to gain any speed. So having something that interfaces natively with such a solver would of course be the best.
Now could it be that this problem can be solved in a reasonable time without auto-diff, just that I've implemented it in a bad way in those "traditional" libraries? To my understanding, auto-diff should be faster for problems with a lot of variables and constraints. But how much is a lot of variables and constraints in reality? Would it be feasible to allow a solver to do finite differences instead, even if this problem has to be solved quickly? I don't have much experience working with optimal control so I don't really have any reference points here. Anyone with experience working with similar problems knows if you used auto-diff or not and what realistic difference in speed can one expect here?