How to connect simulink real-time(or step-by-step) control with python for RL
Ältere Kommentare anzeigen
I'm trying to connect simulink model with python to control the model with Reinforcement learning
For this, I need to simulate a few timesteps (for example, 0.01hr)
then python reads current states and sets the control value by using policy / also learning and optimizing policy
I am currently using the pause method with matlab engine API:
By using clock and assertion block, if simulation time reaches that specific interval(0.01hr), simulation pauses
python checks the simulation status constantly, and if simulation is paused, it reads state values, set control, learns
and then resume simulation.
This works quite well, but repeatedly pausing simulation spends too much time.
Doing 5hr simulation 6000 times takes 3 whole days.
Is there any way better/faster?
I tried TCP-IP connecting but I don't have lincense for corresponding toolbox and I think control action cannot be applied for every fixed timestep for its real-timedness.
Thanks in advance.
2 Kommentare
Sijin
am 30 Nov. 2022
Hi,
Did you find a solution for this? I am having a similar usecase, and currently using the pause to update the control action from Python. As you mentioned, it takes a lot of time for a meaningful number of training steps.
Please share if you have found some better solution.
Best Regards,
Sijin
Enzo Yacometti
am 13 Dez. 2022
Hello, if anyone has a solution to this I would be very interested. I'm currently also pausing and resuming constantly the simulation. Thank you.
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Call MATLAB from Python finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!