question

Felix Möhlmann avatar image
0 Likes"
Felix Möhlmann asked mark zhen commented

Issue with observation space in Reinforcement Learning

I recently installed a new python version. When I tested a modified version of the Reinforcement Learning demo model I encountered a problem when trying to use MultiDiscrete or Box observation/action spaces.

When I try to run the flexsim_training.py I get the following error when using MultiDiscrete as the observation space.

capture1.png

And similarly for a Box space

capture2.png

Something seems to be going wrong with the value conversion. When I set Visual Studio Code to use the old inpreter (3.7.8 instead of 3.11.3) everything works.

1682345360799.png

Does anyone have an idea what I might have forgotten/done wrong when setting up the new version that could lead to this. (I just installed gym and stable_baselines3 again. Since the Discrete space worked I assumed it was successful)

The python scripts are the unaltered (apart from the file paths) versions available from the link in the tutorial.

RL_Demo_2.fsm

FlexSim 23.1.1
reinforcement learningpythonobservation space
capture1.png (32.4 KiB)
capture2.png (1.5 KiB)
1682345360799.png (8.5 KiB)
rl-demo-2.fsm (67.8 KiB)
5 |100000

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

Phil BoBo avatar image
3 Likes"
Phil BoBo answered Abhishek K commented

The provided python scripts are example code to demonstrate how to communicate with FlexSim from a reinforcement learning algorithm. If they don't work perfectly with a particular version of python or another language, library, package, or implementation, then you should customize them according to the needs of your project. As explained in the first paragraph of Getting Started with OpenAI Gym (flexsim.com).

The observation space and the observation value are both set within the example code. If there's a mismatch, then change the code so that it isn't mismatched.

The function _convert_to_gym_space defined on line 178 creates the observation space. The function _convert_to_observation defined on line 196 returns the observation. (https://github.com/flexsim/FlexSimAI/blob/main/gym/flexsim_env.py)

Based on your error message, in the version of python and gym that you are using, you are creating an int64 observation space and recording an int32 observation. Adjust one or the other so that the observed value's type matches what the specified observation space expects.

Alter the example python script to work if it isn't working. That's why the script is provided.

· 4
5 |100000

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

Jeanette F avatar image
0 Likes"
Jeanette F answered mark zhen commented

Hello @Felix Möhlmann,

FlexSim does not support python version 3.11. You can try and build for a different python version as directed below. You can find this information in the manual as well.

1682960820395.png


1682960820395.png (90.3 KiB)
· 3
5 |100000

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