question

Marc R5 avatar image
0 Likes"
Marc R5 asked Jason Lightfoot commented

on model reset import + onset parameter afterwards

Hello,

I have set up the import of my data "on model reset", but then I also have code in "on set" parameter, which involves changes in this data (f.e : the order of production).

If the import involves the load of an excel sheet, how the "on set" reacts. Which acts first? is the "on set" change data properly after excel data is imported or is there a clash?

Thanks

FlexSim 22.1.1
excel importonmodelreseton set
· 5
5 |100000

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

Regan Blackett avatar image Regan Blackett ♦ commented ·

I just did a simple test with the print() command and it appears the OnSet triggers of the parameters executes before the model reset trigger, in the order that the parameters appear in the table. Not sure how you would go about making the data import happen first, maybe by writing your import code in the first parameter in the paameter table's OnSet trigger instead of model reset?


0 Likes 0 ·
Marc R5 avatar image Marc R5 Regan Blackett ♦ commented ·
It will be confusing that everything that needs to happen before the model executes, must be inside an "on set" code of a parameter...

Not what I expected... and so confusing right now

0 Likes 0 ·
Jason Lightfoot avatar image Jason Lightfoot ♦ Marc R5 commented ·
Please post an example of what you're trying to achieve and we can see if there's an elegant solution for you.
0 Likes 0 ·
Jason Lightfoot avatar image Jason Lightfoot ♦ commented ·

Hi @Marc R5,

We haven't heard back from you. Were you able to solve your problem? If so, please add and accept an answer to let others know the solution. Or please respond to the previous comment so that we can continue to help you.

If we don't hear back in the next 3 business days, we'll assume you were able to solve your problem and we'll close this case in our tracker. You can always comment back at any time to reopen your question, or you can contact your local FlexSim distributor for phone or email help.

0 Likes 0 ·
Marc R5 avatar image Marc R5 commented ·

Layout v3.1_36.fsm

Here it is the model. You can see that there is code "on model reset" and on order parameter "on set".

I need both, and the on set code needs to "play" with the data of a global table that is created/updated using the on model reset code.

0 Likes 0 ·
layout-v31-36.fsm (551.1 KiB)

1 Answer

·
Jordan Johnson avatar image
0 Likes"
Jordan Johnson answered Jason Lightfoot commented

When you click the reset button, the very first thing that happens is the parameter OnSet triggers are fired. The "isReset" parameter is true (1) in this case. The model's OnReset trigger fires after this.

The OnSet trigger is also fired when you change the value of the parameter. In this case, the "isReset" flag is false (0).

In general, we advise against always importing data on reset. First, it usually isn't necessary. If the data hasn't changed since the last reset, then there's no reason to import it again. Consider running replications in the Experimenter or Optimizer; all of the replications will call the On Reset trigger, and they don't need to re-import the data.

Second, if you always import excel data on reset, then you'll be unable to use the Experimenter or Optimizer with more than one CPU. The current Excel import doesn't allow multiple processes to access a given sheet at exactly the same time, so the import will work for some replications, but not for others.

It is much better to add a custom button to your dashboard that says "import data", or something like that. You can then click that button when you want to refresh the data, and then reset the model. This avoids the timing issue you are seeing. If you plan to use this model operationally, you could add your import code to the On Model Open trigger as well. This would also avoid the conflict you have.

· 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.

Marc R5 avatar image Marc R5 commented ·
Hello Jordan,

I don't import every time I reset the model. I have a parameter to enable the import and when the input changes I change it to update the data. But when this is the case, I need to do all the other stuff after the import, the same when not importing.

That's why I needed to understand this, and I still don't know which would be the solution so far.

Thanks

0 Likes 0 ·
Jason Lightfoot avatar image Jason Lightfoot ♦ Marc R5 commented ·

I suggest you request a trigger for OnScenarioChange to be added to the experimenter to allow you to load new data when parameters change. It should fire before applying the parameter table.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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