<?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: Setting a parameter when resetting the environment in Reinforcement Learning in FlexSim Forum</title>
    <link>https://forums.autodesk.com/t5/flexsim-forum/setting-a-parameter-when-resetting-the-environment-in/m-p/13572298#M72259</link>
    <description>&lt;DIV class="fr-view clearfix"&gt;&lt;P&gt;Hey &lt;A rel="user" href="https://answers.flexsim.com/users/40392/arthurml.html" nodeid="40392"&gt;@Arthur Ml&lt;/A&gt;, one way you can set the parameter's value on model reset is using the "OnModelReset" trigger found in the Toolbox:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="1679003018177.png"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1516079iCF1E85C38AD958A6/image-size/large?v=v2&amp;amp;px=999" role="button" title="1679003018177.png" alt="1679003018177.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;This gives you a code editor that will execute when the model is about to Reset. Here you can grab a reference to the Parameter's value cell and set it with the task for the next run. In my example I simply set it with the output count of a Processor.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="change-param-on-reset.gif"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1516080iD67BF488C8A0ADC2/image-size/large?v=v2&amp;amp;px=999" role="button" title="change-param-on-reset.gif" alt="change-param-on-reset.gif" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;A rel="noopener noreferrer" href="https://answers.flexsim.com/storage/attachments/65829-set-param-on-reset.fsm" target="_blank"&gt;set-param-on-reset.fsm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Hope this helps!&lt;/P&gt;&lt;/DIV&gt;</description>
    <pubDate>Thu, 16 Mar 2023 21:48:57 GMT</pubDate>
    <dc:creator>kavika_faleumu</dc:creator>
    <dc:date>2023-03-16T21:48:57Z</dc:date>
    <item>
      <title>Setting a parameter when resetting the environment in Reinforcement Learning</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/setting-a-parameter-when-resetting-the-environment-in/m-p/13572297#M72258</link>
      <description>&lt;P&gt;&lt;I&gt;[ FlexSim 22.2.1 ]&lt;/I&gt;&lt;/P&gt;&lt;DIV class="fr-view clearfix"&gt;
 &lt;P&gt;Hi everyone,&lt;/P&gt;
 &lt;P&gt;I am doing Meta Reinforcement Learning for production scheduling. Therefore, I predefined several job lists (n=50) that should be scheduled optimally with RL. In MetaRL, the algorithm regards each list as "task" and the algorithm should be able to select a specific task (i.e. 1 list of the 50 lists) when resetting the environment. I want realize that, by changing the value of a global parameter, which then leads to the usage of the specific list. I.e.: episode is finished -&amp;gt; MetaRL selects. e.g. task=14 for the next episode -&amp;gt; parameter is set to 14 -&amp;gt; flexsim is resetted and job list 14 is used in the model now.&lt;/P&gt;
 &lt;P&gt;Currently, my code for resetting flexsim looks like this:&lt;/P&gt;
 &lt;PRE style="background-color:#ffffff;color:#080808;font-family:'JetBrains Mono',monospace;font-size:9,8pt;"&gt;&lt;SPAN style="color:#0033b3;"&gt;def &lt;/SPAN&gt;&lt;SPAN style="color:#00627a;"&gt;_reset_flexsim&lt;/SPAN&gt;(&lt;SPAN style="color:#94558d;"&gt;self&lt;/SPAN&gt;):
    &lt;SPAN style="color:#0033b3;"&gt;if &lt;/SPAN&gt;&lt;SPAN style="color:#94558d;"&gt;self&lt;/SPAN&gt;.verbose:
        &lt;SPAN style="color:#000080;"&gt;print&lt;/SPAN&gt;(&lt;SPAN style="color:#067d17;"&gt;"Sending Reset message"&lt;/SPAN&gt;)
    resetString = &lt;SPAN style="color:#067d17;"&gt;"Reset?"
&lt;/SPAN&gt;&lt;SPAN style="color:#067d17;"&gt;    &lt;/SPAN&gt;&lt;SPAN style="color:#0033b3;"&gt;if &lt;/SPAN&gt;&lt;SPAN style="color:#000080;"&gt;hasattr&lt;/SPAN&gt;(&lt;SPAN style="color:#94558d;"&gt;self&lt;/SPAN&gt;, &lt;SPAN style="color:#067d17;"&gt;"seedNum"&lt;/SPAN&gt;):
        resetString = &lt;SPAN style="color:#067d17;"&gt;"Reset:" &lt;/SPAN&gt;+ &lt;SPAN style="color:#000080;"&gt;str&lt;/SPAN&gt;(&lt;SPAN style="color:#94558d;"&gt;self&lt;/SPAN&gt;.seedNum) + &lt;SPAN style="color:#067d17;"&gt;"?"
&lt;/SPAN&gt;&lt;SPAN style="color:#067d17;"&gt;    &lt;/SPAN&gt;&lt;SPAN style="color:#94558d;"&gt;self&lt;/SPAN&gt;._socket_send(resetString.encode())&lt;/PRE&gt;
 &lt;P&gt;Can anyone help me please how I can set the parameter value when resetting flexsim?&lt;/P&gt;
 &lt;P&gt;Thanks in advance!&lt;/P&gt;
&lt;/DIV&gt;</description>
      <pubDate>Thu, 16 Mar 2023 08:25:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/setting-a-parameter-when-resetting-the-environment-in/m-p/13572297#M72258</guid>
      <dc:creator>arthur_ml</dc:creator>
      <dc:date>2023-03-16T08:25:54Z</dc:date>
    </item>
    <item>
      <title>Re: Setting a parameter when resetting the environment in Reinforcement Learning</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/setting-a-parameter-when-resetting-the-environment-in/m-p/13572298#M72259</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;&lt;P&gt;Hey &lt;A rel="user" href="https://answers.flexsim.com/users/40392/arthurml.html" nodeid="40392"&gt;@Arthur Ml&lt;/A&gt;, one way you can set the parameter's value on model reset is using the "OnModelReset" trigger found in the Toolbox:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="1679003018177.png"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1516079iCF1E85C38AD958A6/image-size/large?v=v2&amp;amp;px=999" role="button" title="1679003018177.png" alt="1679003018177.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;This gives you a code editor that will execute when the model is about to Reset. Here you can grab a reference to the Parameter's value cell and set it with the task for the next run. In my example I simply set it with the output count of a Processor.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="change-param-on-reset.gif"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1516080iD67BF488C8A0ADC2/image-size/large?v=v2&amp;amp;px=999" role="button" title="change-param-on-reset.gif" alt="change-param-on-reset.gif" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;A rel="noopener noreferrer" href="https://answers.flexsim.com/storage/attachments/65829-set-param-on-reset.fsm" target="_blank"&gt;set-param-on-reset.fsm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Hope this helps!&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 16 Mar 2023 21:48:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/setting-a-parameter-when-resetting-the-environment-in/m-p/13572298#M72259</guid>
      <dc:creator>kavika_faleumu</dc:creator>
      <dc:date>2023-03-16T21:48:57Z</dc:date>
    </item>
    <item>
      <title>Re: Setting a parameter when resetting the environment in Reinforcement Learning</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/setting-a-parameter-when-resetting-the-environment-in/m-p/13572299#M72260</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;
 &lt;P&gt;Dear &lt;A rel="user" href="https://answers.flexsim.com/users/35833/kavikaf.html" nodeid="35833"&gt;@Kavika F&lt;/A&gt; ,&lt;/P&gt;
 &lt;P&gt;thanks for the quick response.&lt;/P&gt;
 &lt;P&gt;Sorry, my question was not specific enough. How can I set a parameter value from Python, when resetting the model/ RL environment? I use a socket connection for connecting Python with Flexsim as presented in the documentation (&lt;A rel="nofollow" href="https://docs.flexsim.com/en/22.1/ModelLogic/ReinforcementLearning/KeyConcepts/KeyConcepts.html"&gt;https://docs.flexsim.com/en/22.1/ModelLogic/ReinforcementLearning/KeyConcepts/KeyConcepts.html&lt;/A&gt;). So far, with this socket connection, I can launch, reset, and close Flexsim, and I can send actions and receive observation from the model. But how can I set a specific parameter value when resetting the model?&lt;/P&gt;
 &lt;P&gt;Thanks and best regards,&lt;BR /&gt;Arthur&lt;/P&gt;
 &lt;P&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;/DIV&gt;</description>
      <pubDate>Fri, 17 Mar 2023 07:29:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/setting-a-parameter-when-resetting-the-environment-in/m-p/13572299#M72260</guid>
      <dc:creator>arthur_ml</dc:creator>
      <dc:date>2023-03-17T07:29:15Z</dc:date>
    </item>
    <item>
      <title>Re: Setting a parameter when resetting the environment in Reinforcement Learning</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/setting-a-parameter-when-resetting-the-environment-in/m-p/13572300#M72261</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;&lt;P&gt;Oh okay. Once you reset your model, you can use the following command to set a parameter:&lt;/P&gt;&lt;PRE&gt;controller.setParameter("ParameterName", value)&lt;/PRE&gt;&lt;P&gt;If you look at the FlexSimPy.cpp, you can see a list of commands you can use from the controller (and within the FlexSim):&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="1679097754270.png"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1516082i0065EF1D027B59F2/image-size/large?v=v2&amp;amp;px=999" role="button" title="1679097754270.png" alt="1679097754270.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Sat, 18 Mar 2023 00:02:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/setting-a-parameter-when-resetting-the-environment-in/m-p/13572300#M72261</guid>
      <dc:creator>kavika_faleumu</dc:creator>
      <dc:date>2023-03-18T00:02:45Z</dc:date>
    </item>
    <item>
      <title>Re: Setting a parameter when resetting the environment in Reinforcement Learning</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/setting-a-parameter-when-resetting-the-environment-in/m-p/13572301#M72262</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;
 &lt;P&gt;Is there a way to set a Parameter in Flexsim with the help of the "flexsim_env.py" script you provided in the documentation (&lt;A rel="nofollow" id="isPasted" href="https://docs.flexsim.com/en/22.1/ModelLogic/ReinforcementLearning/KeyConcepts/KeyConcepts.html"&gt;https://docs.flexsim.com/en/22.1/ModelLogic/ReinforcementLearning/KeyConcepts/KeyConcepts.html&lt;/A&gt;)? Because I am using the scripts from the documentation to connect to Flexsim and do the training. &lt;/P&gt;
&lt;/DIV&gt;</description>
      <pubDate>Mon, 20 Mar 2023 06:48:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/setting-a-parameter-when-resetting-the-environment-in/m-p/13572301#M72262</guid>
      <dc:creator>arthur_ml</dc:creator>
      <dc:date>2023-03-20T06:48:04Z</dc:date>
    </item>
    <item>
      <title>Re: Setting a parameter when resetting the environment in Reinforcement Learning</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/setting-a-parameter-when-resetting-the-environment-in/m-p/13572302#M72263</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;Sorry I thought you were using the code from the &lt;A rel="noopener noreferrer" href="https://github.com/flexsim/FlexSimPy" target="_blank"&gt;FlexSimPy module on github&lt;/A&gt; used to &lt;A rel="noopener noreferrer" href="https://docs.flexsim.com/en/22.1/Reference/DeveloperAdvancedUser/ConnectingToExternalCode/ConnectingToExternalCode.html#python" target="_blank"&gt;connect to FlexSim externally&lt;/A&gt;. That is where I got my code from and reference the FlexSimPy.cpp. I don't know if there's a way to use the flexsim_env.py to change a model parameter; I think the socket connections it deals with are specific to the RL Tool in FlexSim. However, if you use the FlexSimPy module (linked above) to control FlexSim externally, it gives you the capability to set the parameter.&lt;/DIV&gt;</description>
      <pubDate>Mon, 20 Mar 2023 17:27:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/setting-a-parameter-when-resetting-the-environment-in/m-p/13572302#M72263</guid>
      <dc:creator>kavika_faleumu</dc:creator>
      <dc:date>2023-03-20T17:27:28Z</dc:date>
    </item>
    <item>
      <title>Re: Setting a parameter when resetting the environment in Reinforcement Learning</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/setting-a-parameter-when-resetting-the-environment-in/m-p/13572303#M72264</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;
 Alright, thank you:-)
&lt;/DIV&gt;</description>
      <pubDate>Tue, 21 Mar 2023 07:00:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/setting-a-parameter-when-resetting-the-environment-in/m-p/13572303#M72264</guid>
      <dc:creator>arthur_ml</dc:creator>
      <dc:date>2023-03-21T07:00:10Z</dc:date>
    </item>
    <item>
      <title>Re: Setting a parameter when resetting the environment in Reinforcement Learning</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/setting-a-parameter-when-resetting-the-environment-in/m-p/13572304#M72265</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;&lt;P&gt;Hi &lt;A rel="user" href="https://answers.flexsim.com/users/40392/arthurml.html" nodeid="40392"&gt;@Arthur Ml&lt;/A&gt;, was Kavika F's answer helpful? If so, please click the "Accept" button at the bottom of their answer. Or if you still have questions, add a comment and we'll continue the conversation.&lt;/P&gt;&lt;P&gt;If we haven't heard back from you within 3 business days we'll auto-accept an answer, but you can always unaccept and comment back to reopen your question.&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Sat, 25 Mar 2023 05:28:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/setting-a-parameter-when-resetting-the-environment-in/m-p/13572304#M72265</guid>
      <dc:creator>Jeanette_Fullmer</dc:creator>
      <dc:date>2023-03-25T05:28:34Z</dc:date>
    </item>
  </channel>
</rss>

