Idea

Gui Vaccaro avatar image
0 Likes"
Gui Vaccaro suggested Gui Vaccaro commented

Add "OnPrepareScenario" / "OnScenarioStart" trigger to Experimenter

Hello,

The Experimenter does not have an OnScenarioStart (or "OnPrepareScenario") event. The suggestion is to create it.

Why this would be relevant?

  • The experimenter creates copies of the current model to independent threads and then run each copy. At the current moment, if changes are made on a scenario that would require a manual reset (e.g. modifying the layout, adding 3d objects via code, etc.), this does not work in experiments.
  • Other users already looked for similar features, as it is a common element on other simulators in the market (Anylogic, Simio, etc.).

How this would help customers?

  • The added trigger would run before the threads for a certain scenario are created, thus allowing layout automation before a "reset" event happens. Then the adapted version of the model for that scenario configuration would be copied to the independent threads to run.
  • This would add flexibility to model creation, since FlexSim does not allow multiple "model" layers as other simulators in the market allow.
experimenterscenario creationlayout automation
· 2
5 |100000

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

Jason Lightfoot avatar image Jason Lightfoot ♦♦ commented ·
The parameter OnSet triggers can be used to set up the model as needed and they run before the reset of the model, allowing for switching layouts based on parameters. Adding/removing objects is supported in this way for example when selecting the number of task executers in the model. Switching between defined, stored Model Layouts requires a little bit of code right now, but could be added as a pick option in the future.
0 Likes 0 ·
Gui Vaccaro avatar image Gui Vaccaro Jason Lightfoot ♦♦ commented ·
Thank you, @Jason Lightfoot ,

This is great! However, currently it seems that the onSet is triggered before the changes happen when one uses the "Option" configuration (already reported). Until that is sorted out, using the onSet did not produce a positive outcome (that was actually my first attempt to perform layout changes).


0 Likes 0 ·

1 Comment

Jordan Johnson avatar image
0 Likes"
Jordan Johnson commented

I think you may be looking for the On Model Reset trigger. It is found in the toolbox under Modelling Logic -> Model Triggers. This code fires whenever the model is reset. The Experimenter resets the model on every replication.

· 8
5 |100000

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

Jason Lightfoot avatar image Jason Lightfoot ♦♦ commented ·
I'd avoid using the onReset trigger to configure the model for a scenario since this seems to happen for objects after their instanced process flows initialize any listeners. If those listeners are based on labels that get set using OnReset then they will be incorrect.
0 Likes 0 ·
Jordan Johnson avatar image Jordan Johnson ♦♦ Jason Lightfoot ♦♦ commented ·
The model's reset trigger is fired before any individual object's OnReset trigger is fired. This includes Process Flow activities that create listeners.
1 Like 1 ·
Jason Lightfoot avatar image Jason Lightfoot ♦♦ Jordan Johnson ♦♦ commented ·

Good to know - thanks Jordan.

0 Likes 0 ·
Gui Vaccaro avatar image Gui Vaccaro commented ·

Hi, @Jordan Johnson ,

no, unfortunately that does not work as per this thread:
https://answers.flexsim.com/questions/175320/how-to-use-layout-automation-with-the-experimenter.html
Please see the comments from Joerg and then the solution provided by @Jason Lightfoot


0 Likes 0 ·
Jordan Johnson avatar image Jordan Johnson ♦♦ Gui Vaccaro commented ·

I think there is lots of confusion. Let me try to clear it up. Here are my thoughts on that original thread. I'll try to respond to your quotes:

The example I sent uses the "onStartOfReplication"

You should not need to use this trigger in the Experimenter. This trigger is present for people who are initializing their own randomness based on the replication number, which is only necessary if you are doing development work as opposed to standard model building.

The Experimenter sets parameter values, calling their OnSet triggers with the isReset flag set to true. It also calls the Model's OnReset trigger. The design is such that the experimenter naturally does what the model does interactively.

The only difference is that the Experimenter sets the random seeds differently for each replication. But you can do this interactively, too. On the Advanced tab, you can change the "Repeat Streams of Replication" value. This way you can re-create results you see in the Experimenter interactively.


On a different attempt, I tried to call the layout configuration function during the onReset, but it also does not work.

I tried this with the model Jason posted and it seems to work just fine. The performance measures show the difference. I also saved state files after each replication, and the layout adjusted as expected.

experimentlayoutscenario_reset.fsm

You can also use the Paramet OnSet trigger, as @Jason Lightfoot demonstrated. I would add one thing to his demo: all the code that adjusts layout should be within an if (isReset) block. I know one of your other complaints was that the table sets the value while you're typing a new value. I agree that this is a bug. However, parameters that have OnSet code should always put that code within the if (isReset) block, which avoids the UI issue. There may be some fringe case where the OnSet should fire while the model is running, but I haven't seen that occur yet. In any case, here's my example:

experimentlayoutscenario_paramonset.fsm

So setting the layout can be done either by the OnReset trigger in the model or by the OnSet of a parameter. You can achieve what you need without a special/new trigger in the Experimenter. In fact, a trigger changes the model configuration, but only does so when the Experimenter runs, makes it really difficult to repeat those results interactively.

1 Like 1 ·
Gui Vaccaro avatar image Gui Vaccaro Jordan Johnson ♦♦ commented ·

Hello, @Jordan Johnson ,

I agree that there is a "lot of confusion" about this. Let me explain:

I believe the misunderstanding is related to what is meant by a "layout".

In FlexSim, a layout is a very limited option that "saves" locations of 3D objects. It has a strong assumption that all objects exist in all versions (https://answers.flexsim.com/questions/175434/use-different-preferred-paths-in-different-layouts.html), and leaves the burden of handling such differences to the user.

In many applications, when a layout is used as a parameter, it has a very different background: the assumption is that one would not have the same number of objects, locations, and even rules. That burden is acceptable and makes sense as different things are being compared and it is the responsibility of the modeler to take care of it anyways. Please see the pictures below, they are for a very simplistic layout comparison, on purpose, to illustrate the concept behind the meaning of a layout.

A. 1738849551790.png

B.

1738849499083.png

In this example, the number of positions serviced by the operator is changed from 3 to 6 per location, from "layout A" to "layout B". This is useful for capacity studies, for instance. Please keep in mind this is a simplistic example: one might want to add other factors and levels, such as back to back chutes, multiple operators, additional obstacles, specific preferred paths, ...), making the manual creation of all possible configurations not economically viable.

In the example above, the usual approach in other simulators would be data driven: you build your model automatically, based on tables/databases/automation, including the layout, and you test the alternatives via an experimenter tool. Direct competitors allow the user to do it very easily (e.g. Anylogic, Simio, Plant Simulation, ...). To be clear, automating the layout configuration is not that difficult in FlexSim, despite it requires greater effort from the user. However:

  • Using the automation with the current experimenter does not seem to work (the experimenter issues an error on every "dropuserlibraryobject" call, does not matter if the changes are triggered by a parameter's "onSet" or the model's "onReset")
  • The alternative is to (manually ?!?) create different files and tie them all to the same experimenter, so data can be consolidated in a single report, which brings back the impact of economical viability

If there is an alternative to do what I mentioned above already, please let me know where I can find it in the help or provide a related example. That will be very helpful.

In addition:

1. To your point about what the user should or should not do with a given feature, the only place to start is the manual/help, and the picture below is what the manual/help says about the "onStartOfReplication". If the intention is to use it as you describe, I believe this should be in the manual/help. In addition, I wonder how your intended purpose for the trigger would conflict with the "Repeat Streams of Replication" property, as this is not clear in the manual as well.

1738848832181.png

2. In regards to your affirmation about my "other complaint" (https://answers.flexsim.com/questions/175178/bug-parameters-on-set-event-is-triggered-before-va.html) I believe the reporting was very polite and highlighted a problem, without terms that could be characterized as a "complaint". If your interpretation is different, please apologize.

Thank you.


P.S. I am still in need of a solution that allows me to configure different layouts automatically (via dropuserlibraryobject or any other similar command), and run them in the experimenter. This was the original focus of the suggestion and customer help request.

0 Likes 0 ·
1738848832181.png (29.2 KiB)
Show more comments

Your Opinion Counts

Share your great idea, or help out by voting for other people's ideas.