Hi! I created a system with modelingtoolkit, which I’m now trying to expose to python through PythonCall.jl in order to simulate the system and learn a controller using reinforcement learning.
For that to work as I imagined, I basically need periodic callbacks, but in a way that yields control back to the caller after every simulation step / callback.
I figured something like this works:
- Initialize the ODEProblem
And then for every step (called from python):
remake
the ODEProblem with states from previous step, tspan + dt, new control paramssolve
the problem, returns results
But this requires manual bookkeeping for states and parameters, which I’m having some trouble with:
How can I get the default initial state and parameter maps of the system, adjust some values, and transform them into the correctly ordered array?
Is there a better way to achieve this?
I wish I could just use periodic callbacks, but afaik there is no way to yield control to the caller using those.