question

michael.smith avatar image
3 Likes"
michael.smith asked Brandon Peterson edited

Average value of an object statistic

I'm trying to get the average value of an object's statistic. Can you help me with that?

FlexSim 16.0.1
process flowstatisticstracked variables
5 |100000

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

1 Answer

Jordan Johnson avatar image
5 Likes"
Jordan Johnson answered anthony.johnson edited

To get the average staytime of this object, use the getstat command, passing in the following parameters:

  1. The object you want the average staytime for. In this case, the RN object.
  2. The name of the statistic you want. In this case, you need the name "Staytime"
  3. A flag, specifying which value you want from that statistic. In this case, you want STAT_AVERAGE
  4. This parameter depends on the object and statistic you are requesting. If your Process Flow is a general flow (not a task executer or fixed resource or sub flow), then you don't need to supply this parameter. Otherwise, it should be the name of the object attached to this Process Flow.

The command should look something like this:

getstat(getactivity("Intake Process", "RN"), "Staytime", STAT_AVERAGE)

The average is accurate, even if the full history isn't present. In general, statistics don't keep a full history unless absolutely required.

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

jing.c avatar image jing.c commented ·

If you want to get the Stats from a general object (not Process Flow), you should keep in mind that the 2nd parameter would be like "Content" or "Staytime" (Capitalized and ignore the "stats_"). So if you want to get the average_content of Queue3, you can use:

getstat(node("Queue3", model()),"Content",STAT_AVERAGE);

To who know much about programming or data structure, it maybe useless, but to someone, like me(I have learn few programming before using FlexSim) it will be very helpful.

Hope it will help someone~

1 Like 1 ·
anthony.johnson avatar image anthony.johnson ♦♦ commented ·

Also, if you want a list of the available stats an object has, you can do one of the following:

  • Use a Process Flow Wait for Event activity to see the available stats. Add the activity, then in its properties click the button beside the Object (or Event) field, and hover the cursor over the target object. The available stats will take the form On <StatName> Change. For example, the fact that an object has an On Content Change event means that you can also call getstat(object, "Content", ...) to get data associated with the content stat on the object.
  • Use a Tracked Variable Chart in a dashboard. Add the chart, then in its properties, click the button and hover the cursor over the object. This will give a list of the available stats, the same as can be used in the getstat() command. (Although it looks like the tracked variable chart doesn't include categorical stats such as State).

Additionally, you can use the getstat() command if you have a direct reference to the node holding the statistics data, by just passing an empty string as the stat name. For example:

getstat(processor, "Content", STAT_AVERAGE)

will give the same result as

getstat(stats_content(processor), "", STAT_AVERAGE)

Although I'd suggest just using the "Content" option, accessing the node directly would most commonly be used for global tracked variables:

getstat(trackedvariable("MyGlobalTrackedVariable"), "", STAT_AVERAGE)

(BTW, by adding comments to the correct answer, I'm trying to "get a piece of the action". Too bad Jordan, I'm stealing your thunder :-)

1 Like 1 ·