question

Viktor K4 avatar image
1 Like"
Viktor K4 asked Viktor K4 edited

FloWorks - Statistic Collector (states, basic statistic)

Hello FlexSim Community!


I’ve faced several issues regarding the implementation of Statistic Collectors. Available tutorials are only about the standard usage of Flexsim, while I work with the FloWorks module. I’ve attached a sample of the model I am working on.


Firstly, I wanted to add a statistic collector that records the daily state (Empty, Full, Filling, Releasing, Not Empty) of my tanks in hours during a simulation run (one year) - see Daily-States. To do so, I found this tutorial: https://answers.flexsim.com/questions/103600/statistics-collector-for-a-daily-collection-of-sta.html. However, the statistic collector generates zeros in the data table and I have no idea why. Maybe, there is a more efficient and simpler way to create such a collector.


Then, I wanted to record daily statistics of my tanks: current, minimum, maximum, and average content, output, and input - see Daily_Statistics_A1. To get the idea of how to do so, I used this tutorial: https://docs.flexsim.com/en/21.2/Tutorials/AdditionalTools/Tutorial2StatsCollector/2-9OutputByHourByType/. But, it seems that the collector doesn’t reset some of the values for the next day (max and min) and accumulates them during a simulation run (a trigger?). Also, the collector avoids day(0), so you can see zeros in the first row. In addition, it might be interesting to see how many times tanks reach their max and min volumes during a day.


I hope that my post will help other FloWorks users as well.


PS


I haven't updated FlexSim to the latest version yet.


Example_For_SCs.fsm

FlexSim 21.2.4
FloWorksstatistic collectorstatistical analysis
example-for-scs.fsm (58.3 KiB)
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

·
Patrick Zweekhorst avatar image
1 Like"
Patrick Zweekhorst answered Viktor K4 edited

Hi @Viktor K4 ,

Thank you for asking such a nice question and doing all the research. The example model also helps us for answering your question. In the attached example model I have tried to answer the first part of your question. I will update the answer later for the second part.

I have made a really simple and small ProcessFlow to collect all the data that you need. This little flow just saves the total amount of time spend in a state. If you know that of till the start of the current day you can calculate how much time was spend in each state at the end of the current day. This creates a table like shown below:

1642774069960.png

Is this more or less what you are looking for? If not please let me know. Also let me know if you need a little more explanation on how this works.

Edit:
The second part of your question is a little bit more difficult. What I would do if I needed this information, is the following. I would create a tracked variable that exactly follows the content (or in/output) tracked variable of the tank. We can’t use the actual tracked variable because we will need to reset the tracked variable at the end of the day. To do this I again created a little ProcessFlow. The right part is just to follow the original tracked variable; the left part is to log everything at the end of the day. Please take a look at this flow and check if that makes sense. If not, we can always explain it a little more.
1642775821175.png

Patrick

example-for-scsTal.fsm

example-for-scsTal_1.fsm


· 18
5 |100000

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

Viktor K4 avatar image Viktor K4 commented ·

Hello Patrick (@Patrick Zweekhorst)! Thank you for your explicit answer. Firstly, I tried to “digest” the example model and check all used class references with the FlexSim Manual. The first answer is clear to me, only why did you use state(1) in the SaveTimeState? Why do we need 1?


The second answer was a bit challenging to “digest” (not the logic behind it but rather the setting process), as there is not much information on tracked variables as in comparison to the Statistic Collector. I would appreciate your deeper explanation. One thing, when the Statistic Collector calculates the minimum content of each tank, it gives zeros in the Data Table. How to solve it?

0 Likes 0 ·
Patrick Zweekhorst avatar image Patrick Zweekhorst Viktor K4 commented ·

Hi @Viktor K4 ,


To answer your first question. The 1 is needed since you want to log the FloWorks states. The default FlexSim states are logged on the default profile. FloWorks extends on FlexSim and uses its own state profile. This is the first custom profile of the objects. Using the FloWorks dashboard templates automatically set the number 1 for the state logging. Now that we make our own statistics collector we need to do this.

For the second part: Tracked variables can be very useful for collecting statistics. Maybe you have seen the tracked variables in the ToolBox. In this case, since you want to track statistics per Tank you don't want to create all those tracked variables in the ToolBox. If you would do that you would need to add extra tracked variables each time you add a tank. Also linking the tank to the correct tracked variable might be a bit more work. That is why I created some tracked variables on the tokens. They work the same as the global tracked variables from the ToolBox, but just stored on a label.

This also automatically creates extra tracked variables if you need more tanks. For setting the event correctly you will first need to sample any of the tracked variables out of the ToolBox. This makes sure you have the correct event to listen to. You can then change the Object reference to token.ContentTrackedVar. This right part is just to copy the contents tracked variable from the tank. When this content changes we save the current content and the current rate, if the content is changing. Of the left we log and reset the log tracked variable each day. This is also where the log of the minimum content goes wrong (I forgot to save the latest model....) We don't need to reset the tracked variable to value 0 and the beginning of the day, but to the current content of the tank. This can easily be changed in the "Reset tracked var" activity.

Where we had contentLog.reset() we need contentLog.reset( conterVar.value ). This resets the tracked variable to the current content instead of 0. You in fact don't need the next line anymore if you do this. There is no need to set the value of the tracked variable anymore because it is already set correctly.

1643049745263.png

I hope this helps you already some steps further. If not feel free to send me an email for some more help.

Patrick

1 Like 1 ·
1643049745263.png (156.8 KiB)
Viktor K4 avatar image Viktor K4 Patrick Zweekhorst commented ·
Hi @Patrick Zweekhorst,


Thank you for your explanation! I feel more knowledgeable in the topic now.


A minor question. Since my tanks have initial volumes, is there a way to make the statistic collector (Daily Content) gather the data starting from the first day? I played with the Delay activity and it didn't work out.

0 Likes 0 ·
Show more comments

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.