question

IT Asset avatar image
2 Likes"
IT Asset asked Logan Gold commented

How can I capture the TOTAL staytime of all the tokens for a process flow resource?

FlexSim 16.0.1
process flowstatisticsresourcestaytime
· 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.

Jordan Johnson avatar image
3 Likes"
Jordan Johnson answered Jordan Johnson commented

Another way to get this statistic uses Process Flow. The model shown here gets the total staytime for all tokens that used the resource.

Every time you release that resource, have the token go to a Create activity. The Create activity should place an independent token on the start of the sub flow shown in the picture. You don't have to use a Create activity, but if there are multiple release activities, you only have to copy the Create activity, rather than all the activities on the side.

When you create the token, use the pick options to give it a label value. In the example above, I named the label staytime. For the value of the label, I used the pick options to get the current staytime of the Resource activity. The current staytime is the time the most recent token spent using the resource, which is the value we want to total.

The new token should enter a Zone. The Zone should be configured to have a Subset that includes all tokens. In addition, the Subset should have a Calculation that totals the staytime label, as shown in the following figure:

This way, the Zone will keep a custom statistic. Whenever a token enters the Zone, the Zone will increment that statistic (called Total Staytime) by the amount on the staytime label.

Then we set the staytime label to 0, and exit the Zone. Because the the Evaluate Calculations On Exit box is checked, the Zone decrements the Total Staytime statistic by 0, effectively leaving it unchanged. If the box were not checked, the Zone would remember the value of the staytime label, and decrement the statistic by that amount when the token left.

Once configured this way, the Total Staytime statistic on the Zone will sum the staytimes of each token. You can get that statistic by making a Process Flow chart, which I did in the attached model.

totalresourcestaytime.fsm


· 4
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
1 Like"
Regan Blackett answered Regan Blackett commented

If I'm understanding what you want to do correctly, I think you could approach it like this (and if there's an easier way to get this stat @jordan.johnson let me know)

The total staytime is something that isn't part of the standard min/max/average set of values that the resource knows how to give you, but we can get there using a command called getdatastat() during a Custom Code activity. This command lets us look at a set of data stored somewhere in FlexSim and find different stats about it, like the Sum or the Mean.

So we want to tell getdatastat() to look at all the staytimes for all the tokens that ever acquired a Resource and sum all those staytimes.

Luckily, the resource knows all of the staytimes for each token that acquires it and stores it here:

This 'history' node is a fine target for the getdatastat() command. So in a Custom Code activity you can type this:

The first line makes it easier to navigate to our 'history' node from before and gives an easy to work with reference to where all our staytime data is stored. The next line is setting a label on the ProcessFlow (rather than an individual token in ProcessFlow) that will hold the value given by getdatastat(). This lets me see the Summed calculation somewhere easily

Next is the call ot getdatastat() itself where it wants to know:

  • The calculation to perform on the data set, in the case a Sum
  • The number of values in the calculation, in this case I used gettablerows() so that it includes all the staytimes for all the tokens at all times
  • This one is a little tricky to underdtand; this expression is essentially where the data in the history table is stored or which column of data to include in the calculation. So I say I want the 'count' row and the 2nd column of data because column 1 is when the data was recorded in the 'history' table. Hopefully one of the Developers can give a better explanation of this parameter

In the attached model file you can see this applied to a simple Process Flow, and a Dashboard that displays the label value.total-staytime.fsm


history-node.png (53.3 KiB)
total-staytime.fsm (18.5 KiB)
· 4
5 |100000

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