<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Issue with observation space in Reinforcement Learning in FlexSim Forum</title>
    <link>https://forums.autodesk.com/t5/flexsim-forum/issue-with-observation-space-in-reinforcement-learning/m-p/13579580#M77942</link>
    <description>&lt;DIV class="fr-view clearfix"&gt;No, sorry, the inference script worked without problems for me. My only guess would be that you maybe forgot to adjust the file path and are trying to run an agent that was trained on a different set of observations?&lt;/DIV&gt;</description>
    <pubDate>Sun, 14 May 2023 10:45:41 GMT</pubDate>
    <dc:creator>moehlmann_fe</dc:creator>
    <dc:date>2023-05-14T10:45:41Z</dc:date>
    <item>
      <title>Issue with observation space in Reinforcement Learning</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/issue-with-observation-space-in-reinforcement-learning/m-p/13579573#M77935</link>
      <description>&lt;P&gt;&lt;I&gt;[ FlexSim 23.1.1 ]&lt;/I&gt;&lt;/P&gt;&lt;DIV class="fr-view clearfix"&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;When I try to run the flexsim_training.py I get the following error when using MultiDiscrete as the observation space.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="capture1.png"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1516774i7E539BC4DC47248E/image-size/large?v=v2&amp;amp;px=999" role="button" title="capture1.png" alt="capture1.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;And similarly for a Box space&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="capture2.png"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1516775iCD7889D047BA9403/image-size/large?v=v2&amp;amp;px=999" role="button" title="capture2.png" alt="capture2.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="1682345360799.png"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1516776i922782DE104317AD/image-size/large?v=v2&amp;amp;px=999" role="button" title="1682345360799.png" alt="1682345360799.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;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 &lt;EM&gt;gym&lt;/EM&gt; and &lt;EM&gt;stable_baselines3&lt;/EM&gt; again. Since the Discrete space worked I assumed it was successful)&lt;/P&gt;&lt;P&gt;The python scripts are the unaltered (apart from the file paths) versions available from the link in the &lt;A rel="noopener noreferrer" id="isPasted" href="https://docs.flexsim.com/en/23.1/ModelLogic/ReinforcementLearning/WorkingWithGym/GettingStarted/GettingStarted.html" target="_blank"&gt;tutorial&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&lt;A rel="noopener noreferrer" href="https://answers.flexsim.com/storage/attachments/67431-rl-demo-2.fsm" target="_blank"&gt;RL_Demo_2.fsm&lt;/A&gt;&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 24 Apr 2023 14:15:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/issue-with-observation-space-in-reinforcement-learning/m-p/13579573#M77935</guid>
      <dc:creator>moehlmann_fe</dc:creator>
      <dc:date>2023-04-24T14:15:46Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with observation space in Reinforcement Learning</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/issue-with-observation-space-in-reinforcement-learning/m-p/13579574#M77936</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;&lt;P&gt;Hello &lt;A rel="user" href="https://answers.flexsim.com/users/19365/felixmh.html" nodeid="19365"&gt;@Felix Möhlmann&lt;/A&gt;,&lt;/P&gt;&lt;P&gt;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 &lt;A href="https://docs.flexsim.com/en/23.0/Reference/DeveloperAdvancedUser/ConnectingToExternalCode/ConnectingToExternalCode.html#python"&gt;manual&lt;/A&gt; as well.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="1682960820395.png"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1516767i94A7C0A84A24C718/image-size/large?v=v2&amp;amp;px=999" role="button" title="1682960820395.png" alt="1682960820395.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 01 May 2023 17:26:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/issue-with-observation-space-in-reinforcement-learning/m-p/13579574#M77936</guid>
      <dc:creator>Jeanette_Fullmer</dc:creator>
      <dc:date>2023-05-01T17:26:42Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with observation space in Reinforcement Learning</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/issue-with-observation-space-in-reinforcement-learning/m-p/13579575#M77937</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;&lt;P&gt;Thank you for your answer. I did forget to set the version in the preferences and was not aware that Python 3.11 is not supported.&lt;/P&gt;&lt;P&gt;However I still get the same error message when using version 3.10. Do you have an idea what else I might try to get it working?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="1683008732957.png"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1516766i4AC961511C2D6740/image-size/large?v=v2&amp;amp;px=999" role="button" title="1683008732957.png" alt="1683008732957.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="1683008743386.png"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1516768iD1E12666CA4EC57A/image-size/large?v=v2&amp;amp;px=999" role="button" title="1683008743386.png" alt="1683008743386.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="1683008753530.png"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1516769i92BF045DBA29A4C8/image-size/large?v=v2&amp;amp;px=999" role="button" title="1683008753530.png" alt="1683008753530.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 02 May 2023 06:26:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/issue-with-observation-space-in-reinforcement-learning/m-p/13579575#M77937</guid>
      <dc:creator>moehlmann_fe</dc:creator>
      <dc:date>2023-05-02T06:26:15Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with observation space in Reinforcement Learning</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/issue-with-observation-space-in-reinforcement-learning/m-p/13579576#M77938</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;&lt;P&gt;The provided python scripts are &lt;EM&gt;example code&lt;/EM&gt; to &lt;EM&gt;demonstrate how to communicate with FlexSim from a reinforcement learning algorithm&lt;/EM&gt;. If they don't work perfectly with a particular version of python or &lt;EM&gt;another language, library, package, or implementation&lt;/EM&gt;, then you should &lt;EM&gt;customize&lt;/EM&gt; them &lt;EM&gt;according to the needs of your project&lt;/EM&gt;. As explained in the first paragraph of &lt;A href="https://docs.flexsim.com/en/23.1/ModelLogic/ReinforcementLearning/WorkingWithGym/GettingStarted/GettingStarted.html"&gt;Getting Started with OpenAI Gym (flexsim.com)&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;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. (&lt;A href="https://github.com/flexsim/FlexSimAI/blob/main/gym/flexsim_env.py"&gt;https://github.com/flexsim/FlexSimAI/blob/main/gym/flexsim_env.py&lt;/A&gt;)&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;Alter the example python script to work if it isn't working. That's why the script is provided.&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 02 May 2023 13:49:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/issue-with-observation-space-in-reinforcement-learning/m-p/13579576#M77938</guid>
      <dc:creator>philboboADSK</dc:creator>
      <dc:date>2023-05-02T13:49:58Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with observation space in Reinforcement Learning</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/issue-with-observation-space-in-reinforcement-learning/m-p/13579577#M77939</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;&lt;A rel="user" href="https://answers.flexsim.com/users/24344/jeanettef.html" nodeid="24344"&gt;@Jeanette F&lt;/A&gt; The Reinforcement Learning example scripts do not use FlexSim's external code feature. They communicate with FlexSim via sockets. FlexSim's internal support for particular python versions is irrelevant to this question.&lt;/DIV&gt;</description>
      <pubDate>Tue, 02 May 2023 13:53:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/issue-with-observation-space-in-reinforcement-learning/m-p/13579577#M77939</guid>
      <dc:creator>philboboADSK</dc:creator>
      <dc:date>2023-05-02T13:53:17Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with observation space in Reinforcement Learning</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/issue-with-observation-space-in-reinforcement-learning/m-p/13579578#M77940</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;&lt;P&gt;Thank you for the pointers.&lt;/P&gt;&lt;P&gt;In case it might be useful to anyone in the future: Specifying the datatype of the MultiDiscrete space in _convert_to_gym_space of flexsim_env worked for me.&lt;/P&gt;&lt;DIV id="isPasted" style="color: #d4d4d4;background-color: #1e1e1e;font-family: Consolas, 'Courier New', monospace;font-weight: normal;font-size: 14px;line-height: 19px;white-space: pre;"&gt;&lt;SPAN style="color: #c586c0;"&gt;return&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #4ec9b0;"&gt;gym&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;.spaces.MultiDiscrete(&lt;/SPAN&gt;&lt;SPAN style="color: #9cdcfe;"&gt;params&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;, &lt;/SPAN&gt;&lt;SPAN style="color: #9cdcfe;"&gt;dtype&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt; = &lt;/SPAN&gt;&lt;SPAN style="color: #4ec9b0;"&gt;np&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;.&lt;/SPAN&gt;&lt;SPAN style="color: #9cdcfe;"&gt;int32&lt;/SPAN&gt;&lt;SPAN style="color: #d4d4d4;"&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 02 May 2023 14:19:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/issue-with-observation-space-in-reinforcement-learning/m-p/13579578#M77940</guid>
      <dc:creator>moehlmann_fe</dc:creator>
      <dc:date>2023-05-02T14:19:06Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with observation space in Reinforcement Learning</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/issue-with-observation-space-in-reinforcement-learning/m-p/13579579#M77941</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;
 &lt;P&gt;Thanks a lot for posting this, that worked for training the model.&lt;BR /&gt;&lt;BR /&gt;Did you have issues using flexsim_inference.py as well ?&lt;BR /&gt;I am getting this error message when running flexsim_inference.py&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;ValueError: Error: Unexpected observation shape () for MultiDiscrete environment, please use (6,) or (n_env, 6) for the observation shape.&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;Please let me know if you ran into the same issue and how it could be fixed. I tried editing the python script flexsim_inference.py but couldn't get success and I'm not very familiar with coding in python. Basically the observation space has 6 entries which is the last type, followed by 5 discrete values showing how many items of each type are in the queue (same example problem from tutorial), thus making it a MultiDiscrete one. I'm wondering how the flexsim_inference.py needs to be modified to use that observation space to define action for the processor as to which type it should pull next (action)&lt;/P&gt;
&lt;/DIV&gt;</description>
      <pubDate>Fri, 12 May 2023 22:56:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/issue-with-observation-space-in-reinforcement-learning/m-p/13579579#M77941</guid>
      <dc:creator>abhishek_k</dc:creator>
      <dc:date>2023-05-12T22:56:35Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with observation space in Reinforcement Learning</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/issue-with-observation-space-in-reinforcement-learning/m-p/13579580#M77942</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;No, sorry, the inference script worked without problems for me. My only guess would be that you maybe forgot to adjust the file path and are trying to run an agent that was trained on a different set of observations?&lt;/DIV&gt;</description>
      <pubDate>Sun, 14 May 2023 10:45:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/issue-with-observation-space-in-reinforcement-learning/m-p/13579580#M77942</guid>
      <dc:creator>moehlmann_fe</dc:creator>
      <dc:date>2023-05-14T10:45:41Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with observation space in Reinforcement Learning</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/issue-with-observation-space-in-reinforcement-learning/m-p/13579581#M77943</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;
 Thanks Felix, I checked the file paths and unfortunately it is still not working. I'll ask a question separately and elaborate more on the issue, and tag this post as well for reference.
&lt;/DIV&gt;</description>
      <pubDate>Wed, 17 May 2023 17:34:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/issue-with-observation-space-in-reinforcement-learning/m-p/13579581#M77943</guid>
      <dc:creator>abhishek_k</dc:creator>
      <dc:date>2023-05-17T17:34:14Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with observation space in Reinforcement Learning</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/issue-with-observation-space-in-reinforcement-learning/m-p/13579582#M77944</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;
 &lt;P&gt;Have you considered downgrading the stable baseline version&lt;/P&gt;
&lt;/DIV&gt;</description>
      <pubDate>Tue, 22 Aug 2023 17:17:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/issue-with-observation-space-in-reinforcement-learning/m-p/13579582#M77944</guid>
      <dc:creator>a9080109</dc:creator>
      <dc:date>2023-08-22T17:17:36Z</dc:date>
    </item>
  </channel>
</rss>

