question

Lorenzo_pio G avatar image
0 Likes"
Lorenzo_pio G asked Felix Möhlmann commented

Error in initializing the environment using the flexsim_env.py file

Hi. I have developed a model in flexsim in which I need to optimize the idle rate of a processor by applying RL to a robot. It has to pick up the boxes from the right queue and decide on which combiner to leave it, based on the number of boxes present on the pallet placed on the top combiner (Combiner1). I used a process flow to manage the movement of the robots and defined all the parameters of the RLToolbox. However, initializing the environment via the flexsim_env.py file I get the following messages on the terminal:

1665915821188.png

The model in flexsim opens correctly; however, it appears that parameters regarding observations and actions are not being read correctly. At the end of loading, in fact, the terminal should return me the message "Waiting for input to close flexsim". Can you tell me what this may be due to? Is there some error in the initialization of the parameters?

progettoTesi.fsm

FlexSim 22.2.2
robotreinforcement learningflexsim_env.py
1665915821188.png (46.0 KiB)
progettotesi.fsm (439.1 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.

Felix Möhlmann avatar image
0 Likes"
Felix Möhlmann answered Felix Möhlmann commented

It seems using the "OnEntry" event of a process flow activity as the decision trigger doesn't work properly. If you use the "OnLoad" event of the robot instead it works. (Sorry, that I didn't check this before saying you could use the PF activity. I didn't expect there to be a (likely) bug)

You should also adjust the code that sets the observation parameters. You are currently not dividing the idle time by the model time, so the observation wouldn't be the rate but the total time in the state. Also, since you are using an integer parameter, the calculated value should be rounded before applying it to the parameter.

if(Model.time == 0)
{
    Model.parameters["IdleRate"].value = 0;
}
else
{
    Model.parameters["IdleRate"].value = Math.round(Model.find("Sigillatura").as(Object).stats.state().getTotalTimeAt("idle")/Model.time*100, 0)/;
}
· 12
5 |100000

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

Lorenzo_pio G avatar image Lorenzo_pio G commented ·

So do I need to change the Decision Events of the RL Tool? Should I delete the Event1 event and sample the Robot to which I need to add the OnLoad trigger?

0 Likes 0 ·
Lorenzo_pio G avatar image Lorenzo_pio G Lorenzo_pio G commented ·

What is the purpose of the "/" character in line 7? Because it gives me an error the moment I enter the ";".

0 Likes 0 ·
Felix Möhlmann avatar image Felix Möhlmann Lorenzo_pio G commented ·
Yes, use the sampling tool to select the new event from the robot.

I don't know how the "/" at the end of the line got there. There shouldn't be one.

0 Likes 0 ·
Show more comments
Kavika F avatar image
0 Likes"
Kavika F answered Kavika F converted comment to answer

Hey @Lorenzo_pio G, when I opened your model, it said that it couldn't set your parameters to 0. I checked them and they had a lower bound of 1. If you change their lower bounds to 0, the program should be able to set them to 0 and allow you to run the simulation. Let me know if that helps.

1666303863815.png


1666303863815.png (8.5 KiB)
· 1
5 |100000

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

Lorenzo_pio G avatar image Lorenzo_pio G commented ·

Yes, I have already changed those parameters, but it still doesn't work.

0 Likes 0 ·