0
$\begingroup$

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?

$\endgroup$
6
  • $\begingroup$ Why don't you use one of the existing optimal control software packages, rather than building on lower-level interfaces of general optimization libraries? $\endgroup$ Commented Jul 19, 2022 at 18:56
  • $\begingroup$ @WolfgangBangerth The problem is part of a set of problems that has to be solved in sequence, effective interfacing between these is thus very important. The problem also resembles typical problems but differs in some ways, like discretizing over space, why more general methods are preferred. I have also not been able to find any optimal control software that interfaces with java, since it is connected with a larger system this is also important. However, if you have any tips about software I would happily investigate these. $\endgroup$ Commented Jul 20, 2022 at 6:47
  • $\begingroup$ I would start by looking at the book by Betts on optimal control. He discusses software extensively. $\endgroup$ Commented Jul 20, 2022 at 15:04
  • $\begingroup$ As for programming language: Surely it will take far longer to connect to an unsuitable tool with a Java interface than to call a suitable tool written in C or C++, and then design a small interface to your Java system. $\endgroup$ Commented Jul 20, 2022 at 15:05
  • $\begingroup$ @WolfgangBangerth Thank you! Regarding the language part, yes interfacing to another language is an option. That is partly why I ask the question, if autodiff is the reason why I get so much better speeds then that is the probable way to go. However if the realistic speed increase with autodiff is not that big, then I need to reconsider my code and keep looking into existing tools for java. $\endgroup$ Commented Jul 21, 2022 at 7:55

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.