Plotting simmer trajectories

Iñaki Ucar, Bart Smeets

2016-12-28

This package provides an S3 method for the plot generic to visualise diagrams of trajectory objects (see ?plot.trajectory for more details) using the DiagrammeR package as backend.

library(simmer.plot)

t0 <- trajectory() %>%
  seize("resource", 1) %>%
  timeout(function() rnorm(1, 15)) %>%
  release("resource", 1) %>%
  branch(function() 1, c(TRUE, FALSE),
         trajectory() %>%
           clone(2,
                 trajectory() %>%
                   seize("resource", 1) %>%
                   timeout(1) %>%
                   release("resource", 1),
                 trajectory() %>%
                   trap("signal",
                        handler=trajectory() %>%
                          timeout(1)) %>%
                   timeout(1)),
         trajectory() %>%
           set_attribute("dummy", 1) %>%
           set_attribute("dummy", function() 1) %>%
           seize("resource", function() 1) %>%
           timeout(function() rnorm(1, 20)) %>%
           release("resource", function() 1) %>%
           rollback(9)) %>%
  timeout(1) %>%
  rollback(2)

plot(t0)
cat(plot(t0, output="DOT"))
#> digraph {
#> 
#>   '0x55f4651ebfb0' [label = 'Seize', shape = 'box', tooltip = 'amount: 1'] 
#>   '0x55f4612847f0' [label = 'Timeout', shape = 'box', tooltip = 'delay: 0x55f46476d118'] 
#>   '0x55f4649feb40' [label = 'Release', shape = 'box', tooltip = 'amount: 1'] 
#>   '0x55f463e6afc0' [label = 'Branch', shape = 'diamond', tooltip = 'option: 0x55f463c41478'] 
#>   '0x55f46417a1e0' [label = 'Clone', shape = 'diamond', tooltip = 'n: 2'] 
#>   '0x55f4626b4500' [label = 'Seize', shape = 'box', tooltip = 'amount: 1'] 
#>   '0x55f4631a44f0' [label = 'Timeout', shape = 'box', tooltip = 'delay: 1'] 
#>   '0x55f4642e09a0' [label = 'Release', shape = 'box', tooltip = 'amount: 1'] 
#>   '0x55f464a5ec70' [label = 'Trap', shape = 'diamond', tooltip = 'signals: [signal, ]'] 
#>   '0x55f4653d7670' [label = 'Timeout', shape = 'box', tooltip = 'delay: 1'] 
#>   '0x55f463144e80' [label = 'Timeout', shape = 'box', tooltip = 'delay: 1'] 
#>   '0x55f464ac8b00' [label = 'SetAttribute', shape = 'box', tooltip = 'key: dummy, value: 1, global: 0'] 
#>   '0x55f463f50860' [label = 'SetAttribute', shape = 'box', tooltip = 'key: dummy, value: 0x55f463f43518, global: 0'] 
#>   '0x55f46550aea0' [label = 'Seize', shape = 'box', tooltip = 'amount: 0x55f463ed0908'] 
#>   '0x55f4629ac970' [label = 'Timeout', shape = 'box', tooltip = 'delay: 0x55f463ea7b28'] 
#>   '0x55f463fc1110' [label = 'Release', shape = 'box', tooltip = 'amount: 0x55f463e986e0'] 
#>   '0x55f463dec5e0' [label = 'Rollback', shape = 'diamond', tooltip = 'times: 1'] 
#>   '0x55f4633d7f40' [label = 'Timeout', shape = 'box', tooltip = 'delay: 1'] 
#>   '0x55f463d458a0' [label = 'Rollback', shape = 'diamond', tooltip = 'times: 1'] 
#> '0x55f4651ebfb0'->'0x55f4612847f0' [color = 'black', style = 'solid'] 
#> '0x55f4612847f0'->'0x55f4649feb40' [color = 'black', style = 'solid'] 
#> '0x55f4649feb40'->'0x55f463e6afc0' [color = 'black', style = 'solid'] 
#> '0x55f463e6afc0'->'0x55f4633d7f40' [color = 'gray', style = 'dashed'] 
#> '0x55f46417a1e0'->'0x55f4633d7f40' [color = 'gray', style = 'dashed'] 
#> '0x55f4626b4500'->'0x55f4631a44f0' [color = 'black', style = 'solid'] 
#> '0x55f4631a44f0'->'0x55f4642e09a0' [color = 'black', style = 'solid'] 
#> '0x55f4642e09a0'->'0x55f4633d7f40' [color = 'black', style = 'solid'] 
#> '0x55f464a5ec70'->'0x55f463144e80' [color = 'gray', style = 'dashed'] 
#> '0x55f463144e80'->'0x55f4633d7f40' [color = 'black', style = 'solid'] 
#> '0x55f464ac8b00'->'0x55f463f50860' [color = 'black', style = 'solid'] 
#> '0x55f463f50860'->'0x55f46550aea0' [color = 'black', style = 'solid'] 
#> '0x55f46550aea0'->'0x55f4629ac970' [color = 'black', style = 'solid'] 
#> '0x55f4629ac970'->'0x55f463fc1110' [color = 'black', style = 'solid'] 
#> '0x55f463fc1110'->'0x55f463dec5e0' [color = 'black', style = 'solid'] 
#> '0x55f4633d7f40'->'0x55f463d458a0' [color = 'black', style = 'solid'] 
#> '0x55f463e6afc0'->'0x55f46417a1e0' [color = 'black', style = 'solid'] 
#> '0x55f46417a1e0'->'0x55f4626b4500' [color = 'black', style = 'solid'] 
#> '0x55f46417a1e0'->'0x55f464a5ec70' [color = 'black', style = 'solid'] 
#> '0x55f464a5ec70'->'0x55f4653d7670' [color = 'black', style = 'solid'] 
#> '0x55f463e6afc0'->'0x55f464ac8b00' [color = 'black', style = 'solid'] 
#> '0x55f463dec5e0'->'0x55f4651ebfb0' [color = 'black', style = 'solid'] 
#> '0x55f463d458a0'->'0x55f463e6afc0' [color = 'black', style = 'solid'] 
#> }