Simulation trajectories may grow considerably, and they are notalways easy to inspect to ensure their compliance with the model that weare trying to build. For instance, let us consider this pretty complexone:
library(simmer)t0<-trajectory()%>%seize("res0",1)%>%branch(function()1,c(TRUE,FALSE),trajectory()%>%clone(2,trajectory()%>%seize("res1",1)%>%timeout(1)%>%release("res1",1),trajectory()%>%trap("signal",handler=trajectory()%>%timeout(1))%>%timeout(1)),trajectory()%>%set_attribute("dummy",1)%>%seize("res2",function()1)%>%timeout(function()rnorm(1,20))%>%release("res2",function()1)%>%release("res0",1)%>%rollback(11))%>%synchronize()%>%rollback(2)%>%release("res0",1)We must ensure that:
For this task, thesimmer.plot package provides anS3 method for theplot generic to visualise diagrams oftrajectory objects (see?plot.trajectory for more details)using theDiagrammeR package as the backend, whichfacilitates trajectory checking and debugging.
Note that colors are assigned to seizes and releases as a function ofthe resource that these are applied to. By default, resources are mappedto a qualitative Color Brewer palette, but you can override this usingthe optional parameterfill.
library(simmer.plot)get_palette<- scales::brewer_pal(type ="qual",palette =1)plot(t0,fill = get_palette)