Id error on creating an agent

I am in the process of updating my code for the Agents.jl 6.x package and I’m running into some trouble.

I have the following Agents structures:

@agent struct Actor(NoSpaceAgent)
    types::Set{Symbol} = Set{Symbol}()
    behaviors::Vector{Function} = Vector{Function}()
    properties::D where {D <: Dict{Symbol, <:Any}} = Dict{Symbol, Any}()
end

@agent struct MonetaryActor(Actor)
    balance::AbstractBalance = Balance()
end

If I execute:

MonetaryActor()

I get the following error:
ERROR: UndefKeywordError: keyword argument id not assigned
Stacktrace:
[1] MonetaryActor()
@ EconoSim ~/.julia/packages/Agents/ONd0c/src/core/agents.jl:216
[2] top-level scope
@ REPL[1]:1

It seems that there is a problem with assigning an id. What am I missing?

This is due to the fact that id can’t be decided automatically if you don’t pass the model instance.

One of these two should work instead:

julia> model = StandardABM(MonetaryActor);

julia> MonetaryActor(id = 1)
MonetaryActor(1, Set{Symbol}(), Function[], Dict{Symbol, Any}(), Balance())

julia> MonetaryActor(model)
MonetaryActor(1, Set{Symbol}(), Function[], Dict{Symbol, Any}(), Balance())
1 Like