Agents.jl: OpenStreetMaps example of zombie outbreak not running

Hi, currently learning Julia and the Agents.jl library. So far, I’ve managed to reproduce other examples in the package tutorials, so I guess it has nothing to do with versions(?).

The code is taken from Zombie Outbreak in a City · Agents.jl

and the zombie outbreak is throwing the following error (I think at the visualization part? because I can step the model forward, just can’t seem to get the nice plot in the example)

Thanks for any hints as to what might be going on.

If is of any help, after trying to update Julia, I get that there were 2 direct dependencies failing to precompile: AgentsGraphVisualizations and AgentsOSMVisualizations. I think these are also responsible for the error:

{
“name”: “LoadError”,
“message”: "MethodError: no method matching agents_space_dimensionality(::Agents.OSM.OpenStreetMapSpace)
The function agents_space_dimensionality exists, but no method is defined for this combination of argument types.

Closest candidates are:
agents_space_dimensionality(::Nothing)
@ AgentsVisualizations ~/.julia/packages/Agents/dTr7O/ext/AgentsVisualizations/src/spaces/nothing.jl:5
agents_space_dimensionality(::AgentBasedModel{Nothing})
@ AgentsVisualizations ~/.julia/packages/Agents/dTr7O/ext/AgentsVisualizations/src/spaces/nothing.jl:3
agents_space_dimensionality(::AgentBasedModel)
@ AgentsVisualizations ~/.julia/packages/Agents/dTr7O/ext/AgentsVisualizations/src/spaces/abstract.jl:1

",
“stack”: "MethodError: no method matching agents_space_dimensionality(::Agents.OSM.OpenStreetMapSpace)
The function agents_space_dimensionality exists, but no method is defined for this combination of argument types.

Closest candidates are:
agents_space_dimensionality(::Nothing)
@ AgentsVisualizations ~/.julia/packages/Agents/dTr7O/ext/AgentsVisualizations/src/spaces/nothing.jl:5
agents_space_dimensionality(::AgentBasedModel{Nothing})
@ AgentsVisualizations ~/.julia/packages/Agents/dTr7O/ext/AgentsVisualizations/src/spaces/nothing.jl:3
agents_space_dimensionality(::AgentBasedModel)
@ AgentsVisualizations ~/.julia/packages/Agents/dTr7O/ext/AgentsVisualizations/src/spaces/abstract.jl:1

Stacktrace:
[1] agents_space_dimensionality(model::StandardABM{Agents.OSM.OpenStreetMapSpace, Zombie, Dict{Int64, Zombie}, Tuple{DataType}, typeof(zombie_step!), typeof(dummystep), typeof(Agents.Schedulers.fastest), Dict{Symbol, Float64}, MersenneTwister})
@ AgentsVisualizations ~/.julia/packages/Agents/dTr7O/ext/AgentsVisualizations/src/spaces/abstract.jl:1
[2] axistype(model::StandardABM{Agents.OSM.OpenStreetMapSpace, Zombie, Dict{Int64, Zombie}, Tuple{DataType}, typeof(zombie_step!), typeof(dummystep), typeof(Agents.Schedulers.fastest), Dict{Symbol, Float64}, MersenneTwister})
@ AgentsVisualizations ~/.julia/packages/Agents/dTr7O/ext/AgentsVisualizations/src/abmplot.jl:15
[3] abmplot(model::StandardABM{Agents.OSM.OpenStreetMapSpace, Zombie, Dict{Int64, Zombie}, Tuple{DataType}, typeof(zombie_step!), typeof(dummystep), typeof(Agents.Schedulers.fastest), Dict{Symbol, Float64}, MersenneTwister}; figure::@NamedTuple{size::Tuple{Int64, Int64}}, axis::@NamedTuple{title::Observable{String}, titlealign::Symbol}, warn_deprecation::Bool, kwargs::@Kwargs{add_controls::Bool, agent_color::typeof(zombie_color), agent_size::typeof(zombie_size)})
@ AgentsVisualizations ~/.julia/packages/Agents/dTr7O/ext/AgentsVisualizations/src/abmplot.jl:8
[4] abmvideo(file::String, model::StandardABM{Agents.OSM.OpenStreetMapSpace, Zombie, Dict{Int64, Zombie}, Tuple{DataType}, typeof(zombie_step!), typeof(dummystep), typeof(Agents.Schedulers.fastest), Dict{Symbol, Float64}, MersenneTwister}; spf::Nothing, dt::Int64, framerate::Int64, frames::Int64, title::String, showstep::Bool, figure::@NamedTuple{size::Tuple{Int64, Int64}}, axis::@NamedTuple{}, recordkwargs::@NamedTuple{compression::Int64}, kwargs::@Kwargs{agent_color::typeof(zombie_color), agent_size::typeof(zombie_size)})
@ AgentsVisualizations ~/.julia/packages/Agents/dTr7O/ext/AgentsVisualizations/src/convenience.jl:115
[5] top-level scope
@ In[7]:6"
}

See:

In particular, I guess you want to:

  • Mention Agents.jl in the post title

  • Enclose code in Markdown code blocks using backticks

3 Likes

Thanks. I changed the title. Just to clarify, there is no code in my post. I just pasted the error that the example code in the Agents.jl package throws at me. The actual code is on their official documentation (link above, Zombie outbreak in a city)

1 Like

Yes, the error is what I meant by “code”. The goal is to have it readable, and prevent contents being misinterpreted as Markdown syntax and @user mentions.

1 Like

Hi, welcome.
Here is how to read Julia error log. I don’t use Agents.jl, but this is the main error, and it said there is a method call agents_space_dimensionality but that method does not take OpenStreetMapSpace as input. Probably need some time to read the doc, as it seems the example is outdated.

It works fine for me on Julia 1.11.5 using

 [46ada45e] Agents v6.2.10
 [13f3f980] CairoMakie v0.12.18
 [76b6901f] OSMMakie v0.0.10
 [9a3f8284] Random v1.11.0

The proper method for agents_space_dimensionality indeed exists:

julia> methods(Agents.agents_space_dimensionality)
# 7 methods for generic function "agents_space_dimensionality" from Agents:
 [1] agents_space_dimensionality(::Agents.OSM.OpenStreetMapSpace)
(...)

I would indeed expect this to be responsible for the error. Have you tried reinstalling Agents.jl etc.?

Thanks for your reply. This is what I get when trying to re install the package:

   Resolving package versions...
  No Changes to `~/.julia/environments/v1.11/Project.toml`
  No Changes to `~/.julia/environments/v1.11/Manifest.toml`
Precompiling project...
  ✗ Agents → AgentsGraphVisualizations
  ✗ Agents → AgentsOSMVisualizations
  0 dependencies successfully precompiled in 6 seconds. 545 already precompiled.
  2 dependencies errored.
  For a report of the errors see `julia> err`. To retry use `pkg> precompile`

julia> err
PkgPrecompileError: The following 2 direct dependencies failed to precompile:

AgentsGraphVisualizations 

Failed to precompile AgentsGraphVisualizations [fc457f6c-ecc5-5e53-a4cf-8c57f0a5571f] to "/Users/rodsxn/.julia/compiled/v1.11/AgentsGraphVisualizations/jl_dTRxzv".
ERROR: LoadError: TypeError: in Type{...} expression, expected UnionAll, got a value of type Nothing
Stacktrace:
 [1] top-level scope
   @ ~/.julia/packages/Agents/WuWeG/ext/AgentsGraphVisualizations/AgentsGraphVisualizations.jl:6
 [2] include
   @ ./Base.jl:557 [inlined]
 [3] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt128}}, source::Nothing)
   @ Base ./loading.jl:2790
 [4] top-level scope
   @ stdin:5
in expression starting at /Users/rodsxn/.julia/packages/Agents/WuWeG/ext/AgentsGraphVisualizations/AgentsGraphVisualizations.jl:2
in expression starting at stdin:5
AgentsOSMVisualizations 

Failed to precompile AgentsOSMVisualizations [611693d8-6f0d-5891-a6b2-55fbcd232bbf] to "/Users/rodsxn/.julia/compiled/v1.11/AgentsOSMVisualizations/jl_Q2X9BP".
ERROR: LoadError: TypeError: in Type{...} expression, expected UnionAll, got a value of type Nothing
Stacktrace:
 [1] top-level scope
   @ ~/.julia/packages/Agents/WuWeG/ext/AgentsOSMVisualizations/AgentsOSMVisualizations.jl:5
 [2] include
   @ ./Base.jl:557 [inlined]
 [3] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt128}}, source::Nothing)
   @ Base ./loading.jl:2790
 [4] top-level scope
   @ stdin:5
in expression starting at /Users/rodsxn/.julia/packages/Agents/WuWeG/ext/AgentsOSMVisualizations/AgentsOSMVisualizations.jl:1
in expression starting at stdin:5

And after removing and reinstalling the package I get the following:

(@v1.11) pkg> add Agents
   Resolving package versions...
    Updating `~/.julia/environments/v1.11/Project.toml`
  [46ada45e] + Agents v6.2.10
    Updating `~/.julia/environments/v1.11/Manifest.toml`
  [46ada45e] + Agents v6.2.10
  [38540f10] + CommonSolve v0.2.4
  [49057fa9] + HybridStructs v0.2.1
  [f56206fc] + LightSumTypes v5.2.1
  [925886fa] + OnlineStatsBase v1.7.1
  [94ee1d12] + Quaternions v0.7.6
  [6038ab10] + Rotations v1.7.1
⌅ [ff63dad9] + StreamSampling v0.6.9
        Info Packages marked with ⌅ have new versions available but compatibility constraints restrict them from upgrading. To see why use `status --outdated -m`
Precompiling project...
  ✗ Agents → AgentsGraphVisualizations
  ✗ Agents → AgentsOSMVisualizations
  0 dependencies successfully precompiled in 6 seconds. 545 already precompiled.
  2 dependencies errored.
  For a report of the errors see `julia> err`. To retry use `pkg> precompile`

(@v1.11) pkg> 

No clue what is going on or how come others can run it :frowning:

After reinstalling everything once again (all of Julia) and trying it in both Pluto and VS code I solved it!

1 Like