Skip to content
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

Add a dynamic version of agents #1070

Open
Tortar opened this issue Aug 24, 2024 · 5 comments
Open

Add a dynamic version of agents #1070

Tortar opened this issue Aug 24, 2024 · 5 comments
Labels
agent-construction About making agents enhancement New feature or request multi-agent Related with multi-agent models

Comments

@Tortar
Copy link
Member

Tortar commented Aug 24, 2024

Saw this package: https://github.com/AntonOresten/DynamicStructs.jl

We could maybe incorporate it in Agents.jl to offer a dynamic version of an @agent which can have new attributes over time, to be added with

@agent [:static/:dynamic] struct NewAgent(GridAgent{2})
    ...
end

:static being the old version and the default. This seems like a cool feature, provided that it is easy to integrate.

@Datseris
Copy link
Member

Hm I am concerned about the performance implications this has... The implementation in that package is actually rather simple. A dict with symbol keys is added to the type. We can do this here as well, but the better question is should we? It would likely have terrible performance plus it is also easy for a user to do this on their own no? Anyone can make an additional properties dictionary for the agents.

@Tortar
Copy link
Member Author

Tortar commented Aug 24, 2024

yes sure, it's simple, the point to me is that it reduces the boilerplate needed to do it by yourself, so it's mostly for convenience. That package also implements an interface, apart from using a dictionary as a field. Sure, even this is not that difficult, but it would require some more code to do also that yourself. It will surely cause some performance degradation though. But you can always go back to :static mode if that is not affordable.

@Datseris
Copy link
Member

In this discussion we are not putting any weight on the cost of the impact this has on the learning curve. Sure, for you it's simple to just add another concept to grasp, static or dynamic, but when one learns the agents macro they have to learn all of them at once. And the macro is already somehing non trivial.

I guess you can document this new feature at the end of the existing docstring as a new section. That probably will be enough.

I am not a fan of introducing new macros though such as that has macro. Macros put a heavy load on the learning curve. Which is the minimal functionality that we need here?

@Tortar
Copy link
Member Author

Tortar commented Aug 26, 2024

I guess you can document this new feature at the end of the existing docstring as a new section. That probably will be enough.

Exactly, we can just do that. I think it won't need much more than that.

Which is the minimal functionality that we need here?

I think that :dynamic will allow the simulation be more Python-style in the sense that an agent will be more flexible, and not everything should be declared beforehand. Surely there are alternative, but allowing a different flavour/style is good in my opinion. At the same time now the macro is much smarter, I would say it won't be easy to replicate it in its current form by a user.

@Datseris Datseris added enhancement New feature or request agent-construction About making agents multi-agent Related with multi-agent models labels Aug 26, 2024
@Datseris
Copy link
Member

First of all, let's think if this feature is useful: in what kind of simulation do you foresee requiring to add completely new properties to an agent, in a way that can't be done in an existing dictionary property?

I am trying to think a simulation where I would need to add completely new, and unexpected, properties to agents, but I can't think of something.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
agent-construction About making agents enhancement New feature or request multi-agent Related with multi-agent models
Projects
None yet
Development

No branches or pull requests

2 participants