JuliaDynamics / Agents.jl

Agent-based modeling framework in Julia
https://juliadynamics.github.io/Agents.jl/stable/
MIT License
736 stars 119 forks source link

Does EventQueueABM require @multiagent? #1039

Closed jdm204 closed 1 month ago

jdm204 commented 4 months ago

Describe the bug I'm trying out the new EventQueueABM functionality, and I get an error that my agent wasn't created with the @multiagent macro, which is true, but I just have a single agent type with no need for Union or @multiagent.

Minimal Working Example

using Agents
@agent struct Foo(GridAgent{2}) end

bar!(agent, model) = println(agent)

function init_foo()
    space = GridSpaceSingle((10, 10))
    events = (
        AgentEvent(action! = bar!, propensity = 0.1),
    )
    model = EventQueueABM(
        Foo,
        events, space)
    add_agent!((5, 5), model)
    model
end
init_foo()

ERROR: ArgumentError: Agent of type Foo has not been created via @multiagent.

Agents.jl version

Agents v6.0.13 https://github.com/JuliaDynamics/Agents.jl.git#8c36b50 Julia 1.10.3

Tortar commented 4 months ago

ooh, yes, I totally agree, surely we should support this, but we should also support Unions (already tracked in #1015) for feature parity with the discrete ABM model. There was a previous iteration where we had support for all of this (but not multiagent) so it is just needed to find the differences and reapply them where needed: https://github.com/JuliaDynamics/Agents.jl/blob/b865a6e2486c7a3259b56a84fff7e8c105356ac0/src/core/model_event_queue.jl