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

On-demand arrivals #160

Closed
Enchufa2 opened this issue Aug 4, 2018 · 0 comments
Closed

On-demand arrivals #160

Enchufa2 opened this issue Aug 4, 2018 · 0 comments

Comments

@Enchufa2
Copy link
Member

Enchufa2 commented Aug 4, 2018

The following convenience function (see here):

when_activated <- function(n=1) {
  first <- TRUE
  function() {
    if (first) {
      first <<- FALSE
      return(-1)
    }
    c(rep(0, n), -1)
  }
}

would let us do:

library(simmer)

env <- simmer()

restock <- trajectory() %>%
  log_("restock")

serve <- trajectory() %>%
  log_("serve") %>%
  activate("Restock")

env %>%
  add_generator("Customer", serve, at(1, 2, 3)) %>%
  add_generator("Restock", restock, when_activated()) %>%
  run()
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

1 participant