Average value of an object statistic

michael_smith4
Not applicable
0 Views
3 Replies
Message 1 of 4

Average value of an object statistic

michael_smith4
Not applicable

[ FlexSim 16.0.1 ]

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

479-staytime.png

Accepted solutions (1)
1 View
3 Replies
Replies (3)
Message 2 of 4

jordan_johnsonPM57V
Autodesk
Autodesk
Accepted solution

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.

.


Jordan Johnson
Principal Software Engineer
>

Message 3 of 4

jing_chen
Not applicable

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);

515-qq截图20160608095449.png

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~

Message 4 of 4

anthony_johnsonT83CM
Autodesk
Autodesk

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 523-eyedropper.png button beside the Object (or Event) field, and hover the cursor over the target object. 533-waitforeventstats.gif 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 523-eyedropper.png 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).530-trackedvariablestats.gif

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 🙂