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

Get/set multiple attributes at once #122

Closed
Enchufa2 opened this Issue Nov 21, 2017 · 0 comments

Comments

Projects
None yet
1 participant
@Enchufa2
Member

Enchufa2 commented Nov 21, 2017

Example:

library(simmer)

t0 <- trajectory() %>%
  set_attribute(
    c("att1", "att2"),
    c(1, 2)
  ) %>%
  timeout(1) %>%
  set_global(
    function() c("glb1", "glb2"),
    c(1, 2)
  ) %>%
  timeout(1) %>%
  set_attribute(
    c("att3", "att4"),
    function() get_attribute(env, c("att1", "att2")) + 2
  ) %>%
  timeout(1) %>%
  set_global(
    function() c("glb3", "glb4"),
    function() get_global(env, c("glb1", "glb2")) + 2
  )

env <- simmer() %>%
  add_generator("entity", t0, at(0), mon=2)
env %>%
  run() %>%
  get_mon_attributes()
#>   time    name  key value replication
#> 1    0 entity0 att1     1           1
#> 2    0 entity0 att2     2           1
#> 3    1         glb1     1           1
#> 4    1         glb2     2           1
#> 5    2 entity0 att3     3           1
#> 6    2 entity0 att4     4           1
#> 7    3         glb3     3           1
#> 8    3         glb4     4           1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment