Agents.jl Question: collecting data in abm_video

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.

Have you tried using 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).

1 Like

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.

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. :wink:

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. After initialising model and dataframes, the core loop should be something like “record frame, step model, record adata/mdata in dataframes”. Hope this helps. :slight_smile:

Thanks! I’ll try this.