the-anylogic-company / AnyLogic-Pypeline

A custom AnyLogic library for running Python inside an AnyLogic model (Java)
https://github.com/the-anylogic-company/AnyLogic-Pypeline/wiki
MIT License
107 stars 27 forks source link

how can you start the simulator and initialize the data using a python file? #7

Closed worldsoft closed 3 years ago

worldsoft commented 3 years ago

I need to receive data from the simulation and pass it to python and this should all happen recursively. Is this possible with this library? Thanks.

t-wolfeadam commented 3 years ago

Can you clarify on what you're trying to do and which part is "recursive"?

If it helps: when you start a simulation model with the Communicator object, you can import data from Python to initialize your model with (just import and call from the necessary Python libraries/scripts). In the 'On destroy' field of Main/at the end of your sim model, you can dump data to Python as well (e.g., using the Communicator's toJson function).

worldsoft commented 3 years ago

I want to make a reinforcement learning model. But to do this, you need to reload the simulation and update the data every time. How can this be done?

t-wolfeadam commented 3 years ago

In short, you cannot use Pypeline for RL training (without many cumbersome workarounds). If you want the long answer, I talked about it in the Pypeline webinar (@ 52:50 / direct link to section) and explained it more thoroughly in the last two questions of the writeup (link to that).

For now, you can either use one of the available automated platforms (Bonsai, Pathmind) or do the training manually in Java (e.g., RL4J). I'm currently working on another Python library which will let you control an exported AL model, subject to come out hopefully in Q1 of next year. It's release will be on the AnyLogic blog and I'll provide a link to it from this repo too.

t-wolfeadam commented 3 years ago

Closing for now. Feel free to re-open if you have related follow-up Qs.