<?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: custom observation space for RL in FlexSim Forum</title>
    <link>https://forums.autodesk.com/t5/flexsim-forum/custom-observation-space-for-rl/m-p/13539853#M46883</link>
    <description>&lt;DIV class="fr-view clearfix"&gt;
 &lt;P&gt;Thank you for your helpful answer, and sorry for my late comment (I was waiting to activate my licence). &lt;/P&gt;
 &lt;P&gt;I'm not sure I understood the use of MyCustomParameter since then you say :&lt;/P&gt;
 &lt;OL&gt;&lt;LI style="line-height: 20px; list-style-type: decimal; background: rgb(238, 238, 238);"&gt;&lt;SPAN style="color: rgb(136, 0, 0);"&gt;// Assuming all your observations are in a table called "Observations"&lt;/SPAN&gt;&lt;/LI&gt;&lt;/OL&gt;
 &lt;P&gt;&lt;BR /&gt;So I have to put my observations in a table or in my custom parameter or both of them? &lt;BR /&gt;knowing that my state representation is a (J × 6) matrix, containing, for every row (i.e. every job) 6 attributes. &lt;BR /&gt;&lt;BR /&gt;I hope my question is clear!&lt;/P&gt;
&lt;/DIV&gt;</description>
    <pubDate>Tue, 28 Feb 2023 15:55:59 GMT</pubDate>
    <dc:creator>BaraaM</dc:creator>
    <dc:date>2023-02-28T15:55:59Z</dc:date>
    <item>
      <title>custom observation space for RL</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/custom-observation-space-for-rl/m-p/13539847#M46877</link>
      <description>&lt;P&gt;&lt;I&gt;[ FlexSim 22.0.10 ]&lt;/I&gt;&lt;/P&gt;&lt;DIV class="fr-view clearfix"&gt;
 &lt;P&gt;Hello,&lt;BR /&gt;I'm trying to figure out how to use RL with Flexsim. I'm able to run the changeover example with no problem. I'm working with a scheduling problem so my observations cannot fit in a simple parameters table. I just need to have an example of "custom observation space" to have an idea how I can do that to define my observation space.&lt;/P&gt;
 &lt;P&gt;Thank you,&lt;/P&gt;
&lt;/DIV&gt;</description>
      <pubDate>Thu, 26 Jan 2023 21:46:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/custom-observation-space-for-rl/m-p/13539847#M46877</guid>
      <dc:creator>BaraaM</dc:creator>
      <dc:date>2023-01-26T21:46:46Z</dc:date>
    </item>
    <item>
      <title>Re: custom observation space for RL</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/custom-observation-space-for-rl/m-p/13539848#M46878</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;&lt;P&gt;&lt;A rel="user" href="https://answers.flexsim.com/users/42537/baraam.html" nodeid="42537"&gt;@BaraaM&lt;/A&gt; , I don’t know how long you observe this forum. The development of Reinforced Learning [RL] started about 2 years ago in the scope of FlexSim on a level where users could bind FlexSim easily to external sources.&lt;/P&gt;&lt;P&gt;I attach a setup of the search tool url to find filtered threads of this matter.&lt;/P&gt;&lt;P&gt;&lt;A href="https://answers.flexsim.com/search.html?c=7&amp;amp;includeChildren=false&amp;amp;f=author%3A%22phil.bobo%22&amp;amp;type=question+OR+idea+OR+kbentry+OR+answer+OR+topic+OR+user&amp;amp;redirect=search%2Fsearch&amp;amp;sort=relevance&amp;amp;q=Rl"&gt;https://answers.flexsim.com/search.html?c=7&amp;amp;includeChildren=false&amp;amp;f=author%3A%22phil.bobo%22&amp;amp;type=question+OR+idea+OR+kbentry+OR+answer+OR+topic+OR+user&amp;amp;redirect=search%2Fsearch&amp;amp;sort=relevance&amp;amp;q=Rl&lt;/A&gt;&lt;/P&gt;&lt;P&gt;There are about 70 threads of RL, if you search just for a keyword like “RL”. You will notice that there are some developers involved in discussions.&lt;/P&gt;&lt;P&gt;Edit: perhaps you look also into suggestions of section “RELATED QUESTIONS” on this site.&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 27 Jan 2023 06:42:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/custom-observation-space-for-rl/m-p/13539848#M46878</guid>
      <dc:creator>joerg_vogel_HsH</dc:creator>
      <dc:date>2023-01-27T06:42:33Z</dc:date>
    </item>
    <item>
      <title>Re: custom observation space for RL</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/custom-observation-space-for-rl/m-p/13539849#M46879</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;&lt;P&gt;You communicate with an AI by a reward value that correlates to a current set of input parameters in a FlexSim model. An Observation Space gets relevant if a set of parameters has got a strong impact on a reward value. This means that  variations of parameters must change the efficiency of a model and thus the reward value. If you want to find an optimized schedule you will iterate different schedule plan sets by a variation of parameters. The reward value should favor more a schedule set than the efficiency of your model parameters. But the model efficiency must still have a relevance in your reward. You must evaluate when you update rewards and you must estimate the relation of model efficiency parameters and schedule sets.&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 27 Jan 2023 07:17:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/custom-observation-space-for-rl/m-p/13539849#M46879</guid>
      <dc:creator>joerg_vogel_HsH</dc:creator>
      <dc:date>2023-01-27T07:17:29Z</dc:date>
    </item>
    <item>
      <title>Re: custom observation space for RL</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/custom-observation-space-for-rl/m-p/13539850#M46880</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;&lt;P&gt;A schedule can be a time table of process times and breaks or a sequence of product input.&lt;/P&gt;&lt;P&gt;A sequence of products results in a table of products order.&lt;/P&gt;&lt;P&gt;Set 1&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;1st product = Type 1&lt;/LI&gt;&lt;LI&gt;2nd product = Type 2&lt;/LI&gt;&lt;LI&gt;3rd product = Type 1&lt;/LI&gt;&lt;LI&gt;..&lt;/LI&gt;&lt;LI&gt;10345th product = Type 2&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;..&lt;/P&gt;&lt;P&gt;Set 2&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;1st product = Type 2&lt;/LI&gt;&lt;LI&gt;2nd product = Type 2&lt;/LI&gt;&lt;LI&gt;3rd product = Type 1&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;..&lt;/P&gt;&lt;P&gt;Set 3&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;1st product = Type 2&lt;/LI&gt;&lt;LI&gt;2nd product = Type 2&lt;/LI&gt;&lt;LI&gt;3rd product = Type 2&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;..&lt;/P&gt;&lt;P&gt;Set 1057&lt;/P&gt;&lt;P&gt;..&lt;/P&gt;&lt;P&gt;Set 13927&lt;/P&gt;&lt;P&gt;..&lt;/P&gt;&lt;P&gt;a reward should not be reported for every entering item in a sink rather than in interval of more entering items or fixed time intervals. The reward must have a correlation to the input sequence table. If your model creates a delay between input and output then the reward must be a result of the input you want to observe. &lt;/P&gt;&lt;P&gt;You can for example define an observation interval between two milestone products being processed in a model in a sequence of input products. &lt;BR /&gt;You look for two products of low and high priority. A reward value gets returned, when both have entered a sink. The input order between them and some products previous to first and some behind last product are defining your set of input variables additionally to parameters of processing times and queue capacities. I think, it won’t matter if observation intervals overlap for pairs of milestone products.&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 27 Jan 2023 08:05:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/custom-observation-space-for-rl/m-p/13539850#M46880</guid>
      <dc:creator>joerg_vogel_HsH</dc:creator>
      <dc:date>2023-01-27T08:05:08Z</dc:date>
    </item>
    <item>
      <title>Re: custom observation space for RL</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/custom-observation-space-for-rl/m-p/13539851#M46881</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;&lt;P&gt;You'll need to do a few things.&lt;/P&gt;&lt;P&gt;First, in FlexSim, you'll probably want to use a Custom parameter. In FlexScript, you can then set that parameter to some value such as:&lt;/P&gt;&lt;PRE&gt;Model.parameters.MyCustomParameter = [[1, 2], [3, 4], [5, 6]]&lt;/PRE&gt;&lt;P&gt;Next, set the RL tool to use a custom parameter space. Set the space string to whatever you want, including nothing. Use the Get Observation trigger to send whatever string you want, but I strongly recommend you use JSON. For example:&lt;/P&gt;&lt;PRE&gt;Object current = ownerobject(c);

Map observation;
// Assuming all your observations are in a table called "Observations"
Array names = Model.parameters.names("Observations");
for (int i = 1; i &amp;lt;= names.length; i++) {
    observation[names&lt;I&gt;] = Model.parameters[names&lt;I&gt;].value;
}

return JSON.stringify(observation);&lt;/I&gt;&lt;/I&gt;&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Finally, you'll need to update flexsim_env.py. You'll need to modify the _get_observation_space() function and the  _convert_to_observation() functions. The first function must return a valid space for whatever RL tool you are using. The second function must parse the text FlexSim sent back for the observation (which is easy if you use JSON) and the set the values in the observation space to whatever the model reports.&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 27 Jan 2023 16:48:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/custom-observation-space-for-rl/m-p/13539851#M46881</guid>
      <dc:creator>JordanLJohnson</dc:creator>
      <dc:date>2023-01-27T16:48:17Z</dc:date>
    </item>
    <item>
      <title>Re: custom observation space for RL</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/custom-observation-space-for-rl/m-p/13539852#M46882</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;&lt;P&gt;Hi &lt;A rel="user" href="https://answers.flexsim.com/users/42537/baraam.html" nodeid="42537"&gt;@baraam&lt;/A&gt;, was one of Jordan Johnson's or Joerg Vogel's answers helpful? If so, please click the "Accept" button at the bottom of the one that best answers your question. 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>Wed, 01 Feb 2023 17:26:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/custom-observation-space-for-rl/m-p/13539852#M46882</guid>
      <dc:creator>Jeanette_Fullmer</dc:creator>
      <dc:date>2023-02-01T17:26:14Z</dc:date>
    </item>
    <item>
      <title>Re: custom observation space for RL</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/custom-observation-space-for-rl/m-p/13539853#M46883</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;
 &lt;P&gt;Thank you for your helpful answer, and sorry for my late comment (I was waiting to activate my licence). &lt;/P&gt;
 &lt;P&gt;I'm not sure I understood the use of MyCustomParameter since then you say :&lt;/P&gt;
 &lt;OL&gt;&lt;LI style="line-height: 20px; list-style-type: decimal; background: rgb(238, 238, 238);"&gt;&lt;SPAN style="color: rgb(136, 0, 0);"&gt;// Assuming all your observations are in a table called "Observations"&lt;/SPAN&gt;&lt;/LI&gt;&lt;/OL&gt;
 &lt;P&gt;&lt;BR /&gt;So I have to put my observations in a table or in my custom parameter or both of them? &lt;BR /&gt;knowing that my state representation is a (J × 6) matrix, containing, for every row (i.e. every job) 6 attributes. &lt;BR /&gt;&lt;BR /&gt;I hope my question is clear!&lt;/P&gt;
&lt;/DIV&gt;</description>
      <pubDate>Tue, 28 Feb 2023 15:55:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/custom-observation-space-for-rl/m-p/13539853#M46883</guid>
      <dc:creator>BaraaM</dc:creator>
      <dc:date>2023-02-28T15:55:59Z</dc:date>
    </item>
    <item>
      <title>Re: custom observation space for RL</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/custom-observation-space-for-rl/m-p/13539854#M46884</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;&lt;P&gt;Since you are doing a custom observation, you can keep the values anywhere you want. You can use Parameters if you want, or you can use a global table. It's up to you. The code I wrote as an example shows you how to get all the of the values from a parameter table called "Observations". But if you are keeping your observations somewhere else, you can modify the code to return whatever you want.&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 28 Feb 2023 20:45:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/custom-observation-space-for-rl/m-p/13539854#M46884</guid>
      <dc:creator>JordanLJohnson</dc:creator>
      <dc:date>2023-02-28T20:45:39Z</dc:date>
    </item>
    <item>
      <title>Re: custom observation space for RL</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/custom-observation-space-for-rl/m-p/13539855#M46885</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;
 &lt;P&gt;Hello,&lt;/P&gt;
 &lt;P&gt;So I was able to get all the needed information that I need to send to my RL model. &lt;/P&gt;
 &lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="capture-decran-2023-03-10-095027.png"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1515019i877A55E232254722/image-size/large?v=v2&amp;amp;px=999" role="button" title="capture-decran-2023-03-10-095027.png" alt="capture-decran-2023-03-10-095027.png" /&gt;&lt;/span&gt;&lt;/P&gt;
 &lt;P&gt;But when I use Custom Observation I'm unable to get these information in my "python" model. In my model I get the name of my observation space (which I put in space definition) but without the parameters. &lt;BR /&gt;&lt;BR /&gt;Like That: &lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="capture-decran-2023-03-10-095705.png"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1515020iDF7A1BB2C5C72F32/image-size/large?v=v2&amp;amp;px=999" role="button" title="capture-decran-2023-03-10-095705.png" alt="capture-decran-2023-03-10-095705.png" /&gt;&lt;/span&gt;&lt;BR /&gt;you can see that my "SpaceBytes" has only the name of the observation space, so I have error cause I don't have parameters ...&lt;BR /&gt;&lt;BR /&gt;How I can do to solve that please ? &lt;/P&gt;
 &lt;P&gt;&lt;BR /&gt;&lt;/P&gt;
 &lt;P&gt;Thank you &lt;/P&gt;
 &lt;P&gt;Baraa&lt;/P&gt;
&lt;/DIV&gt;</description>
      <pubDate>Fri, 10 Mar 2023 09:02:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/custom-observation-space-for-rl/m-p/13539855#M46885</guid>
      <dc:creator>BaraaM</dc:creator>
      <dc:date>2023-03-10T09:02:05Z</dc:date>
    </item>
    <item>
      <title>Re: custom observation space for RL</title>
      <link>https://forums.autodesk.com/t5/flexsim-forum/custom-observation-space-for-rl/m-p/13539856#M46886</link>
      <description>&lt;DIV class="fr-view clearfix"&gt;&lt;P&gt;If you use a Custom parameter space, you need to adjust the Python code. The Python script should interpret the bytes sent from FlexSim and create the proper gym space.&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 19 Apr 2023 21:24:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/flexsim-forum/custom-observation-space-for-rl/m-p/13539856#M46886</guid>
      <dc:creator>JordanLJohnson</dc:creator>
      <dc:date>2023-04-19T21:24:41Z</dc:date>
    </item>
  </channel>
</rss>

