The model represents a community, i.e. a set of interacting objects called agents.
Their location is described by a pattern
that evolve
s along a timeline
.
pattern
The pattern which describes the location of agents.
type
The type of individuals. Informational only.
timeline
A numeric vector.
last_time
The last time (in the time line) the model has been run.
run_patterns
The past patterns of the model, obtained by run
and saved.
new()
Create a new instance of this R6 class.
community_model$new(pattern = NULL, timeline = 0, type = "Species")
plot()
Default plot method: plots the pattern. To be overridden.
community_model$plot(
time = NULL,
sleep = animation::ani.options("interval"),
...
)
autoplot()
Make a ggplot2::ggplot of the pattern. To be overridden.
run()
Run the model.
community_model$run(
animate = FALSE,
sleep = animation::ani.options("interval"),
save = FALSE,
more_time = NULL
)
animate
if TRUE
, the evolution of the model is shown in an animation.
sleep
The time (in ms) to sleep between each step of the evolution of the model.
save
if TRUE
, the evolution of the model is saved.
if FALSE
, only the final step is saved.
more_time
A numeric vector that extends the timeline.
along_time()
Apply the function FUN
to the saved patterns along time and return
a dataframe with columns x
for time and y
for the results of FUN
.
FUN
must return a single value.
myModel <- community_matrixmodel$new()
myModel$autoplot()