question

A Kamphaus avatar image
2 Likes"
A Kamphaus 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.

Logan Gold avatar image Logan Gold ♦♦ commented ·

Just wanted to let everybody know they can read this other post that Jordan made that's related to this question: How can I get resource utilization statistics from a Process Flow resource?

2 Likes 2 ·
A Kamphaus avatar image A Kamphaus commented ·

In other words: how much was that resource utilized during the run?

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

A Kamphaus avatar image A Kamphaus commented ·

This would be great if my model wasn't already built- but going back through and clipping apart then adding this in and trying to move everything and re size stuff to make it not look crazy for EVERY instance of release operator is very unappealing.

I'm just curious what the plan was for collecting resource utilization since "acquire" in process flow doesn't seem to change the operator state for the operator associated with the resource?

0 Likes 0 ·
Jordan Johnson avatar image Jordan Johnson ♦♦ A Kamphaus commented ·

I found a way to do it where you won't have to rearrange anything. You can use an event triggered source, and listen to the OnStaytimeChange event of the Resource, but still using the Zone. Here's a very similar model, but with those changes. You just need to add 6 activities and a Zone to your model.

Your second question deserves a good response, too. I'll make a separate question for it, and answer it (although you may see the question page before I can get a good answer for you)

totalresourcestaytimeeasy.fsm

0 Likes 0 ·
A Kamphaus avatar image A Kamphaus Jordan Johnson ♦♦ commented ·

Ok I've copied that into my model but I can't seem to figure out how you got the "Resource Staytime" to show up in the dashboard chart:

It seems like my zone settings are identical since i copied it in from your model, except the Groups tab in the chart. What am I missing?

0 Likes 0 ·
flexsimq.png (558.5 KiB)
Show more comments
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.

Jordan Johnson avatar image Jordan Johnson ♦♦ commented ·

To save memory, Process Flow statistics don't keep a history by default. The history in the example above exists because a dashboard chart required the history.

0 Likes 0 ·
A Kamphaus avatar image A Kamphaus commented ·

This is more what I'm looking for, I would prefer to handle all the stat collection stuff in as few places as possible. I will test it out when I have a chance and let you know how it works. Thanks.

0 Likes 0 ·
A Kamphaus avatar image A Kamphaus A Kamphaus commented ·

Ok this doesn't seem to be working for me. When I run, the dashboard doesnt seem to display anything. So I added:

double datastats = getdatastat(STAT_SUM, gettablerows(staytimedata), gettablenum(staytimedata, count, 2));

And stepping through the code datastats is always 0 for some reason.

0 Likes 0 ·
Regan Blackett avatar image Regan Blackett ♦ A Kamphaus commented ·

It's because of what Jordan said up above; my way was dependent on a standard staytime dashboard being created, which makes the history node store the individual staytimes for each token. my use of getdatastat() piggy backed on that so if you delete or lose the staytime dashboard, you lose the history node which makes getdatastat give a zero. I wasn't aware of this when I put my example together.

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.