Skip to content

Get/set multiple attributes at once #122

Description

@Enchufa2

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions