question

Damini C avatar image
0 Likes"
Damini C asked Phil BoBo answered

can i configure flexsim model with tensorflow for reinforcement learning

Hi , I want to configure flexsim model with tensorflow. I want to train agent for flexsim model using reinforcement learning. How will i configure flexsim model in tensorflow?

thank you

FlexSim 21.0.8
reinforcement learningflexsim 21.0.8connect flexsim model in tensorflowtensorflow
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

Phil BoBo avatar image
2 Likes"
Phil BoBo answered

To train a TensorFlow agent using reinforcement learning currently, you will need to write a custom environment that communicates with FlexSim.

See Environments | TensorFlow Agents.

You'll want to spawn a FlexSim process from the __init__() method of your custom environment.

See Automatically Configure and Run a FlexSim Model - FlexSim Community.

Then you'll want to communicate with FlexSim in the reset() and step() methods of your custom environment. I suggest using sockets to communicate.

See Using FlexSim with Python/C api - FlexSim Community.

I would use the Module SDK or DLL Maker to write the socket code in C++ on the FlexSim side so that you have full control, but there are also FlexScript socket functions that may be good enough:

See how to use flexsim socket communication with server and client - FlexSim Community and Socket Examples - FlexSim Community Forum.

The FlexSim Development Team is currently working on making this integration easier by creating a custom OpenAI Gym Environment that communicates with FlexSim directly by loading and executing functions in the FlexSim.dll. If you want to make this work right now before that development is available, you can write the communication code yourself using the references above.

5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.