Is there a way to retrieve each agent’s velocity in the Agents.jl flocking model per time step of the abmvideo command? For reference, the abmvideo command goes
abmvideo(
"flocking.mp4", model;
agent_marker = bird_marker,
framerate = 20, frames = 300,
title = "Flocking"
)
Hi There,
yes, you can retrieve any agent data you wish for, including the velocity, if you use the run!
function. see the main tutorial of Agents.jl for how to use the run!
function.
I am not sure I understand what you mean to “retrieve the data during the video”? The function that creates the video does just that: makes a video. It does not return any data. Even if you did record data during the model evolution you wouldn’t access it via the video function. You would need to call run!
. If you want to make a video as well, then call abmvideo
independentl.
Or, you could use the abmexploration
(also in the main tutorial) to make a video where in the left side of the figure you see the birds moving, and in the right side you see a timeseries of the agent velocity you have collected. (Explained in the visualizations tutorial how to achieve this)
Thanks for the help! I figured out how to use abmexploration
but I couldn’t retrieve the velocities of all birds in the model. I plan on plotting ϕ, which is defined on the bird_marker
function on the flocking model using all the velocities.
I am assuming you want to plot the average angle from all birds ?
Then it is just
using Statistics: mean
angle(b) = atan(b.vel[2], b.vel[1])
adata = [(angle, mean), ]
fig, abmobs = abmexploration(model;
adata, alabels = ["mean angle", ],
# any other kw...
)
I don’t understand what you mean by “I can’t retrieve the velocities of all birds in the model”.