question

mark zhen avatar image
0 Likes"
mark zhen asked Jordan Johnson commented

Reinforcement Learning's versioning problem

When I was running the new py environment, I found that the training could not be executed smoothly. I don’t know which link is the problem. I bought a new computer and built a new vscode, but it couldn’t be executed smoothly.

PS C:\Users\R2504_111\Documents\FlexSim 2022 Projects\RL> & C:/Users/R2504_111/AppData/Local/Programs/Python/Python311/python.exe "c:/Users/R2504_111/Documents/FlexSim 2022 Projects/RL/flexsim_training.py"

Initializing FlexSim environment...

Traceback (most recent call last):

File "C:\Users\R2504_111\AppData\Local\Programs\Python\Python311\Lib\site-packages\stable_baselines3\common\env_checker.py", line 402, in check_env

env.reset(seed=0)

TypeError: FlexSimEnv.reset() got an unexpected keyword argument 'seed'


The above exception was the direct cause of the following exception:


Traceback (most recent call last):

File "c:\Users\R2504_111\Documents\FlexSim 2022 Projects\RL\flexsim_training.py", line 53, in <module>

main()

File "c:\Users\R2504_111\Documents\FlexSim 2022 Projects\RL\flexsim_training.py", line 19, in main

check_env(env) # Check that an environment follows Gym API.

^^^^^^^^^^^^^^

File "C:\Users\R2504_111\AppData\Local\Programs\Python\Python311\Lib\site-packages\stable_baselines3\common\env_checker.py", line 404, in check_env

raise TypeError("The reset() method must accept a `seed` parameter") from e

TypeError: The reset() method must accept a `seed` parameter

FlexSim 22.0.16
reinforcement learningpython
· 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.

Phil BoBo avatar image
3 Likes"
Phil BoBo answered

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).

It looks like the version of stable_baselines you are using requires a "seed" parameter on the environment's reset() function. In flexsim_env.py, try adding a seed parameter to that function. Something like this:

  1. def reset(self, seed=None):
  2. self.seedNum = seed
  3. self._reset_flexsim()
  4. state, reward, done = self._get_observation()
  5. return state

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

5 |100000

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

Jordan Johnson avatar image
0 Likes"
Jordan Johnson answered Jordan Johnson commented

Is the issue resolved by commenting out the check_env() line? I think I have seen that come up before.

· 5
5 |100000

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