New feature: monitoring offloading to disk

53 views
Skip to first unread message

Iñaki Úcar

unread,
Apr 22, 2018, 8:32:07 AM4/22/18
to simmer-devel
Hi all,

I've just merged this new feature into the master branch. Monitoring
has always been performed in-memory, which is convenient and fast, but
may lead to memory issues for very long simulations. Now, it is
possible to offload this to disk:

library(simmer)
to_csv <- monitor_csv()
env <- simmer(mon=to_csv)
env
#> simmer environment: anonymous | now: 0 | next:
#> { Monitor: to disk (delimited files) }
#> { arrivals: /tmp/RtmpEew5ES/file29758c1c246_arrivals.csv }
#> { releases: /tmp/RtmpEew5ES/file29758c1c246_releases.csv }
#> { attributes: /tmp/RtmpEew5ES/file29758c1c246_attributes.csv }
#> { resources: /tmp/RtmpEew5ES/file29758c1c246_resources.csv }

As you can see, data tables are saved into the R tempdir by default,
although it is possible to specify any valid location (see
"?monitor_csv()"). Functions get_mon_arrivals() and the like will work
as usual to load these files into data frames. However, if you want to
process the data in a separate workflow, then you can obtain the file
names from the monitor object:

to_csv$handlers
#> arrivals
#> "/tmp/RtmpEew5ES/file29758c1c246_arrivals.csv"
#> releases
#> "/tmp/RtmpEew5ES/file29758c1c246_releases.csv"
#> attributes
#> "/tmp/RtmpEew5ES/file29758c1c246_attributes.csv"
#> resources
#> "/tmp/RtmpEew5ES/file29758c1c246_resources.csv"

I'd appreciate if you can test this feature and provide your feedback
before the next release, which will be in two weeks.

Regards,
Iñaki

Ian Bowns

unread,
May 30, 2018, 10:52:44 AM5/30/18
to simmer-devel
Hi.

I've been trying to create a user-defined function to run a simulation and then save the get_mon data to disk. This works, but some of the monitoring parameters seem missing (e.g. "waiting_time", "flow_time"). Can this method be used within a user-defined function to save and then retrieve ALL monitoring data?

Thanks, great package.

Ian

Iñaki Úcar

unread,
May 30, 2018, 11:55:04 AM5/30/18
to simmer-devel
Hi Ian,

El mié., 30 may. 2018 a las 16:52, Ian Bowns (<ianb...@gmail.com>)
escribió:

> Hi.

> I've been trying to create a user-defined function to run a simulation
and then save the get_mon data to disk. This works, but some of the
monitoring parameters seem missing (e.g. "waiting_time", "flow_time"). Can
this method be used within a user-defined function to save and then
retrieve ALL monitoring data?

The measured parameters are start_time, end_time and activity_time, and
from them you can compute the others:

flow_time = end_time - start_time
waiting_time = flow_time - activity_time

So there is no missing data.


> Thanks, great package.

> Ian

Iñaki

Ian Bowns

unread,
May 30, 2018, 2:10:11 PM5/30/18
to simmer-devel
Sorry Iñaki,

I had already worked that out and used it. I suppose the issues was with how to use that within simmer.plot?

I'll work something out.

Ian

Iñaki Úcar

unread,
May 31, 2018, 3:29:26 AM5/31/18
to simmer-devel
El mié., 30 may. 2018 a las 20:10, Ian Bowns (<ianb...@gmail.com>) escribió:
>
> Sorry Iñaki,
>
> I had already worked that out and used it. I suppose the issues was with how to use that within simmer.plot?

simmer.plot expects the output from the get_mon_*() methods, which add
some columns: the 'replication' column for all data frames and the
resource limits in the resources data frame. You can add them manually
if you want to use simmer.plot methods with CSV files.

Iñaki

Ian Bowns

unread,
May 31, 2018, 4:46:44 AM5/31/18
to simmer-devel
Good morning.

Have largely abandoned simmer.plot in favour of using ggplot2, plotly and, possibly dygraphs and prophet.

Basing much of the analysis on a data frame merging arrivals and attributes, using name.

Also trying to create my own functions to use simmer for a complex care pathway.

Ian

david.j...@gmail.com

unread,
Jun 18, 2018, 5:55:38 PM6/18/18
to simmer-devel
Trying to monitor on file returns error


```{r}
library(simmer)
mon <- monitor_delim()

``` 
Error: monitor_delim: 'args' is not a valid list


Running 
R version 3.4.4
simmer_3.8.0

Iñaki Úcar

unread,
Jun 18, 2018, 6:06:44 PM6/18/18
to simmer-devel
El lun., 18 jun. 2018 a las 23:55, <david.j...@gmail.com> escribió:
>
> Trying to monitor on file returns error
>
> library(simmer)
> mon <- monitor_delim()
> Error: monitor_delim: 'args' is not a valid list

Thanks for the report. Is this a clean session? I can't reproduce it.

Iñaki

David Rios

unread,
Jun 18, 2018, 6:10:24 PM6/18/18
to simmer...@googlegroups.com
Not a clean session, works after restarting R. Will try and search for a reproducible example.

--
You received this message because you are subscribed to the Google Groups "simmer-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to simmer-devel+unsubscribe@googlegroups.com.
To post to this group, send email to simmer...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/simmer-devel/CALEXWq2AwynXuf7LLrEg-UjDkji55KNnCdUg6Wtj4FXs-YRnNQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

david.j...@gmail.com

unread,
Jun 18, 2018, 6:22:21 PM6/18/18
to simmer-devel
I was able to reproduce. It has something to do with loading the 'purrr' package earlier in the session. Running purr 0.2.4

library(purrr)      
library(simmer)     
                    
                    
mon <- monitor_csv()
#> Error: monitor_delim: 'args' is not a valid list

Fixed by detatching 'purrr' before calling monitor_csv()

library(purrr)                      
library(simmer)                     
detach("package:purrr", unload=TRUE)
                                    
mon <- monitor_csv()   

Iñaki Úcar

unread,
Jun 18, 2018, 7:28:21 PM6/18/18
to simmer-devel
El mar., 19 jun. 2018 a las 0:22, <david.j...@gmail.com> escribió:
>
> I was able to reproduce. It has something to do with loading the 'purrr' package earlier in the session. Running purr 0.2.4
>
> library(purrr)
> library(simmer)
>
>
> mon <- monitor_csv()
> #> Error: monitor_delim: 'args' is not a valid list
>
>
> Fixed by detatching 'purrr' before calling monitor_csv()
>
> library(purrr)
> library(simmer)
> detach("package:purrr", unload=TRUE)
>
> mon <- monitor_csv()
>

Thanks, fixed now on GitHub.

Iñaki
Reply all
Reply to author
Forward
0 new messages