I am currently trying to write the gradient projection algorythm for an optimal control problem with Maple.
This involves calculation of the gradient of the objective function at every new iteration, which would be not a problem per se. However, in optimal control problem this last depends on state and costate variables which, in turn, are given by the system of ODEs. This system is solved numerically only. As far as I understood Maple is recalculating the values of functions which are given by ODE solutions with every call and so when I calculate the gradient of an objective function it takes very long, as Maple is recalculating values of dependent variables for every t. In an effect I cannot move further then two steps with this algorythm.
My question is: are their any ways to force Maple to remember the numerical solution to the ODE system not as a procedure, but as already calculated function after it computes it once?
Another related question is: may be I am dumb and there are examples of implementation of gradient projection method for optimal cotrol systems in maple already. If so, please point me the way.
Hoping for any help,