# ModelEvent in continous time model?

**URL:** <https://discourse.julialang.org/t/modelevent-in-continous-time-model/115153>\
**Category:** Modelling & Simulations\
**Tags:** question, agents, modelling\
**Created:** [June 4, 2024, 7:29am UTC](https://discourse.julialang.org/t/modelevent-in-continous-time-model/115153 "2024-06-04T07:29:28Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sahil\_Khan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sahil_khan/32/47573_2.png) [@Sahil\_Khan](https://discourse.julialang.org/u/Sahil_Khan)\
**Post date:** [June 4, 2024, 7:29am UTC](https://discourse.julialang.org/t/modelevent-in-continous-time-model/115153/1 "2024-06-04T07:29:28Z")

</div>

Hello,

I have been working with discrete model type in agents.jl. There we have agent\_step and model\_step functions to work at model or agent level. Now I want to switch to continous time models. i was checking example for same on Agents.jl page. I came across AgentEvent function to influence each agent how we want but how to do something at model level like model\_step in StandardABM and not at each agent level? Is there an option?

Thank you 🙂

---

<div class="post-metadata">

**Author:** ![Datseris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/datseris/32/13406_2.png) [@Datseris](https://discourse.julialang.org/u/Datseris)\
**Post date:** [June 4, 2024, 8:37am UTC](https://discourse.julialang.org/t/modelevent-in-continous-time-model/115153/2 "2024-06-04T08:37:08Z")

</div>

There is no model event in `EventQueueABM` so far, no. Initially we didn’t implement any model step because there wasn’t a time “before all” or “after all” agents have acted for it to trigger.

You should open a feature request at Agents.jl github page. It is actually easy to implement a `ModelEvent` that is a wrapper around `AgentEvent` with a reference to special internal type so that the internal code can understand that the event action acts only on the model.

Until this feature is implemented, keep in mind that all agent events also have the model as argument so you can add one more event that applies to all agents and just modifies the model. (the downside is that such an event won’t trigger if the assigned agent gets remove, hence why the suggestion is good).

The best would even be if you try to implement this of course! 😃

---

<div class="post-metadata">

**Author:** ![Sahil\_Khan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sahil_khan/32/47573_2.png) [@Sahil\_Khan](https://discourse.julialang.org/u/Sahil_Khan)\
**Post date:** [June 4, 2024, 8:45am UTC](https://discourse.julialang.org/t/modelevent-in-continous-time-model/115153/3 "2024-06-04T08:45:32Z")

</div>

In my case there is no agent removal but I will be using interaction\_pair() function which is much better to use at model level rather then agent I believe and thats why I was wondering if AgentEvent() could take all agents in account at a given time?

To be clear what I really want - I’m trying to implement this [model](https://juliadynamics.github.io/Agents.jl/stable/examples/celllistmap/) in continuous time. 🙂

Any suggestion will be helpful.

---

<div class="post-metadata">

**Author:** ![Datseris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/datseris/32/13406_2.png) [@Datseris](https://discourse.julialang.org/u/Datseris)\
**Post date:** [June 4, 2024, 8:47am UTC](https://discourse.julialang.org/t/modelevent-in-continous-time-model/115153/4 "2024-06-04T08:47:04Z")

</div>

> [@Sahil\_Khan](#):
>
> I was wondering if AgentEvent() could take all agents in account at a given time?

Any function `f(model` would take all agents into account if you use the `model`. E.g. in an event

```julia
function attack!(agent, model)
aa = allagents(model) # these are all agents.
end

```

---

<div class="post-metadata">

**Author:** ![Sahil\_Khan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sahil_khan/32/47573_2.png) [@Sahil\_Khan](https://discourse.julialang.org/u/Sahil_Khan)\
**Post date:** [June 4, 2024, 8:53am UTC](https://discourse.julialang.org/t/modelevent-in-continous-time-model/115153/5 "2024-06-04T08:53:05Z")

</div>

ahh thats perfect then 🙂 I will try to implement a small model first and will post here will be helpful for others. :).

Also, I believe it will be really nice if we could have more example for continuous time models too like StandardABM 😅. Maybe when I complete this, it can be added 😀 because although things are pretty straightforward but for someone new its always kind of puzzling while transferring things from one type to other type of model.

---

<div class="post-metadata">

**Author:** ![Datseris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/datseris/32/13406_2.png) [@Datseris](https://discourse.julialang.org/u/Datseris)\
**Post date:** [June 4, 2024, 8:54am UTC](https://discourse.julialang.org/t/modelevent-in-continous-time-model/115153/6 "2024-06-04T08:54:06Z")

</div>

You are very welcomed to contribute more examples to [Introduction · Agents.jl Example Zoo](https://juliadynamics.github.io/AgentsExampleZoo.jl/dev/) !
