-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make EventQueueABM
work with Union
types
#1015
Comments
But there is no way to specify multiple dispatch in the event model. Or at least, there is no meaning to do so. You need to specify a function corresponding to an event, and the "kinds" it can be applied to. If we allow Unions, what changes is that we specify the "types" it applies to instead of "kinds". but it's not like we can actually use multiple dispatch to specify this. The specification is demanded as input, it can't be deduced by multiple dispatch. |
Say you have 2 types and an event function attack!(agent::AT1, model)
...
end
function attack!(agent::AT2, model)
...
end also, you can dispatch inside the |
What's the benefit of doing all this? Is there in general any benefit in using union types for event based? Besides the fact that "you can use the same name for the different actions"? |
I would say the same reasoning applies to Actually, also, with a In general I would expect that there should be needed very few changes to make this working also with types anyway |
This is not the same. Because, in contrast to But sure, if you can make it work with a few changes and it doesn't cost much of your time, go for it! I guess it is easy: we make a boolean typed parameter |
I fail to see which if clause is "mandatory" though, can you please point me out in https://github.com/JuliaDynamics/Agents.jl/blob/main/examples/event_rock_paper_scissors.jl what would be it? In this case it doesn't seem necessary any additional if clause
seems a good way to me! |
it was a figure of speech, the 'if' clause is implicit in the fact that we specify the target agent kinds when creating the event type. :D |
This is useful because even if multiple dispatch can't be used in stepping function of Agents because there aren't really any in this type of model, having multiple dispatch for small unions could be useful anyway when implementing the event functions, or even for some more specific functions inside the event functions. This is also something which we allow in a
StandardABM
so I think that allowing it also here is good for consistencyThe text was updated successfully, but these errors were encountered: