# Agents.jl Question: collecting data in abm\_video

**URL:** https://discourse.julialang.org/t/agents-jl-question-collecting-data-in-abm-video/77826
**Category:** New to Julia
**Tags:** plotting, agents, glmakie
**Created:** [March 13, 2022, 4:56pm UTC](https://discourse.julialang.org/t/agents-jl-question-collecting-data-in-abm-video/77826 "2022-03-13T16:56:41Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![codekomali](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/codekomali/32/34483_2.png) [@codekomali](https://discourse.julialang.org/u/codekomali)
#### Post date: [March 13, 2022, 4:56pm UTC](https://discourse.julialang.org/t/agents-jl-question-collecting-data-in-abm-video/77826/1 "2022-03-13T16:56:41Z")

</div>

I am new to Julia. I am interested in Agent Based Modeling and planning to use Agents.jl as an alternative to NetLogo. I just finished the first tutorial: Schelling’s segregation.  
I need some help with the visualisation. Currently the options provided by Agents.jl are abm\_video and abm\_data\_exploration. For me, abm\_data\_exploration is an overkill. I will be running in headless mode and I need video for verification/debugging. While the abm\_data\_exploration returns the figure, agent-data and model-data, the abm\_video has no options for data collection and returns nothing.  
Currently, I ram going with an ugly hack: I create a deepcopy of the model and using the copy for abm\_video. There should be a better solution. I appreciate all help.

---

<div class="post-metadata">

### Author: ![fbanning](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fbanning/32/14972_2.png) [@fbanning](https://discourse.julialang.org/u/fbanning)
#### Post date: [March 14, 2022, 12:42pm UTC](https://discourse.julialang.org/t/agents-jl-question-collecting-data-in-abm-video/77826/2 "2022-03-14T12:42:42Z")

</div>

Have you tried using [`abm_play`](https://juliadynamics.github.io/Agents.jl/stable/interact/#InteractiveDynamics.abm_play)? Does it do what you want to do? If not, I think I misunderstood what you were implicitly asking for.

On a sidenote: We’re in the final steps of reworking the Agents-related plotting functions and options for interactive applications. It will be InteractiveDynamics 0.20.0 and will probably be released together with Agents.jl 5.0. This rework might allow for a more seamless operation of the headless mode you prefer and a interactive view of the model’s space (well, again, at least I think that’s what you’re asking for).

---

<div class="post-metadata">

### Author: ![codekomali](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/codekomali/32/34483_2.png) [@codekomali](https://discourse.julialang.org/u/codekomali)
#### Post date: [March 14, 2022, 4:23pm UTC](https://discourse.julialang.org/t/agents-jl-question-collecting-data-in-abm-video/77826/3 "2022-03-14T16:23:04Z")

</div>

Thanks for your reply. ‘abm\_play’ will not work. I don’t want to launch an interactive application with buttons. I just want the following: I want to run my ABM in a headless mode and collect data in dataframes. (say) While analyzing the data, I noticed that something odd/interesting is happening at step 120. I should be able to open the (mp4) video and fast forward to step 115 and watch the rest of the video to visually investigate/debug further.  
Currently, in Agents.jl, I can do ‘run!’ for running my simulation in headless mode and get back data. Similarly, I can do ‘abm\_data\_exploration’ for interactive window and run the simulation thru it. The function returns fig, adf and mdf (i.e agent-dataframe and model-dataframe) . So, both run! and abm\_data\_exploration returns the data collected, but abm\_video returns ‘nothing’. I was hoping that there is someway to pass the model to to abm\_video and collect data as well.

Hope I explained my problem clearly. Again thanks for the help. I am eagerly looking forward to Agents.jl 5.0.

---

<div class="post-metadata">

### Author: ![fbanning](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fbanning/32/14972_2.png) [@fbanning](https://discourse.julialang.org/u/fbanning)
#### Post date: [March 14, 2022, 5:28pm UTC](https://discourse.julialang.org/t/agents-jl-question-collecting-data-in-abm-video/77826/4 "2022-03-14T17:28:48Z")

</div>

> [@codekomali](#):
>
> So, both run! and abm\_data\_exploration returns the data collected, but abm\_video returns ‘nothing’. I was hoping that there is someway to pass the model to to abm\_video and collect data as well.

Ah, I see. No this is currently not possible. And while there are fundamental changes in the next next releases of InteractiveDynamics and Agents which will make constructing more customised figures and interactive applications a lot easier, this will not change anything about the behaviour of `abm_video` which will still exist in its current form as a convenience function. We don’t have plans to extend this to your use case as of now but contributions are always welcome, of course. 😉

To achieve what you’re trying to do, you actually just need to write a simple function yourself. It should contain the step-wise model advancement and data collection (not via `run!` but via `step!`), as well as the recording of the videoframe after each step. For actually writing it, you can then orient yourself on the code of `abm_video` and the advice given [here in the docs](https://juliadynamics.github.io/Agents.jl/stable/api/#Data-collection). After initialising model and dataframes, the core loop should be something like “record frame, step model, record adata/mdata in dataframes”. Hope this helps. 🙂

---

<div class="post-metadata">

### Author: ![codekomali](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/codekomali/32/34483_2.png) [@codekomali](https://discourse.julialang.org/u/codekomali)
#### Post date: [March 14, 2022, 11:26pm UTC](https://discourse.julialang.org/t/agents-jl-question-collecting-data-in-abm-video/77826/5 "2022-03-14T23:26:02Z")

</div>

Thanks! I’ll try this.
