Skip to content

Show simulation progress #103

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

Closed
Enchufa2 opened this issue Jun 1, 2017 · 4 comments
Closed

Show simulation progress #103

Enchufa2 opened this issue Jun 1, 2017 · 4 comments

Comments

@Enchufa2
Copy link
Member

Enchufa2 commented Jun 1, 2017

With a helper verb such as the following:

run_with_progress <- function(.env, until=1000, steps=10) {
  for (i in seq(until/steps, until, until/steps)) {
    run(.env, until=i)
    message(paste0(100*i/until, "%"))
  }
  .env
}
@Enchufa2
Copy link
Member Author

Enchufa2 commented Jun 5, 2017

Finally, implemented in run() as an option. Example using the progress package:

library(simmer)
library(progress)

mm1 <- trajectory() %>%
  seize("server", 1) %>%
  timeout(function() rexp(1, 66)) %>%
  release("server", 1)

simmer() %>%
  add_resource("server", 1) %>%
  add_generator("customer", mm1, function() rexp(100, 60)) %>%
  run(3000, progress=progress_bar$new()$update, steps=10)

@spgarbet
Copy link

spgarbet commented Jun 5, 2017

Excellent!

@mfhaln
Copy link

mfhaln commented Sep 4, 2019

Briliant! this example really need to be added to run() documentation, took me a couple of hours of digging before I found this and only through the ChangeLog.

@Enchufa2
Copy link
Member Author

Enchufa2 commented Sep 4, 2019

Thanks for the feedback! That manual page definitely needs some examples.

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

3 participants