Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

monitoring of unfinished activities #73

Closed
bart6114 opened this issue Aug 17, 2016 · 5 comments
Closed

monitoring of unfinished activities #73

bart6114 opened this issue Aug 17, 2016 · 5 comments

Comments

@bart6114
Copy link
Member

I've ran into some results that are unintuitive for me. Consider the following

library(simmer)

a <- create_trajectory() %>%
  timeout(11)

b <- create_trajectory() %>%
  timeout(1) %>%
  rollback(1, times=Inf)

c <- create_trajectory() %>%
  timeout(5)

simmer() %>%
  add_generator("a", a, at(0)) %>%
  add_generator("b", b, at(0)) %>%
  add_generator("c", c, at(0)) %>%
  run(until=10) %>%
  get_mon_arrivals()

Which results in:

  name start_time end_time activity_time finished replication
1   c0          0        5             5     TRUE           1

I would expect the a and b arrival to also show up with an end_time equal to until and a finished status of FALSE.

Not looked into it too deep, but I think we can relatively easily implement this by making a terminate call on all the active arrivals after the Simulator::run function runs out.

What do you think @Enchufa2?

@Enchufa2
Copy link
Member

Enchufa2 commented Aug 17, 2016

For me, the nice thing is that you can continue the simulation. If you call terminate when the until condition is met, you cannot do that.

@bart6114
Copy link
Member Author

Hmz, you're completely right.
What do you think about a terminate(env) command?
This could be used stand alone, or could optionally be called by e.g. get_mon_arrivals().

Either way, this behaviour is something we should describe in more detail in #29

@Enchufa2
Copy link
Member

Enchufa2 commented Aug 20, 2016

I see no benefit from aborting trajectories. There is no need: we can simply report these ongoing processes without terminating them. It would be an extra option to get_mon_arrivals: ongoing=TRUE (FALSE by default), for instance. Then, these ongoing arrivals should be reported with the finished column, as well as the end_time and activity_time columns, equal to NA, to avoid messing around with the other data.

So following your example above,

library(simmer)

a <- create_trajectory() %>%
  timeout(11)

b <- create_trajectory() %>%
  timeout(1) %>%
  rollback(1, times=Inf)

c <- create_trajectory() %>%
  timeout(5)

env <- simmer() %>%
  add_generator("a", a, at(0)) %>%
  add_generator("b", b, at(0)) %>%
  add_generator("c", c, at(0)) %>%
  run(until=10)

get_mon_arrivals(env, ongoing = TRUE)
#>   name start_time end_time activity_time finished replication
#> 1   c0          0        5             5     TRUE           1
#> 2   a0          0       NA            NA       NA           1
#> 3   b0          0       NA            NA       NA           1

The advantage of not having terminated those two is that you can now do the following:

env %>% run(until=12)

get_mon_arrivals(env, ongoing = TRUE)
#>   name start_time end_time activity_time finished replication
#> 1   c0          0        5             5     TRUE           1
#> 2   a0          0       11            11     TRUE           1
#> 3   b0          0       NA            NA       NA           1

@Enchufa2
Copy link
Member

The activity_time column will be NA for those ongoing arrivals (edited above).

@bart6114
Copy link
Member Author

bart6114 commented Sep 1, 2016

great work 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants