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 #8

Closed
Enchufa2 opened this issue Aug 4, 2018 · 1 comment
Closed

On-demand arrivals #8

Enchufa2 opened this issue Aug 4, 2018 · 1 comment

Comments

@Enchufa2
Copy link
Member

Enchufa2 commented Aug 4, 2018

Example:

library(simmer)

env <- simmer()

trigger_arrivals <- function(.trj, source, n=1) {
  .trj %>%
    set_source(source, at(rep(0, n))) %>%
    activate(source)
}

add_idle_source <- function(.env, name_prefix, trajectory, ...) {
  .env %>%
    add_generator(name_prefix, trajectory, at(-1), ...)
}

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

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

env %>%
  add_generator("Customer", serve, at(1, 2, 3)) %>%
  add_idle_source("Restock", restock) %>%
  run()
@Enchufa2
Copy link
Member Author

Enchufa2 commented Aug 4, 2018

Superseded by r-simmer/simmer#160.

@Enchufa2 Enchufa2 closed this as completed Aug 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant