JuliaDynamics / InteractiveDynamics.jl

Fast, general-purpose interactive applications for complex systems
https://juliadynamics.github.io/InteractiveDynamics.jl/dev/
MIT License
174 stars 26 forks source link

Static plotting of ABMs example code not working #104

Closed tatakof closed 2 years ago

tatakof commented 2 years ago

Hello,

I'm exploring the plotting in ABMs described here: https://juliadynamics.github.io/Agents.jl/stable/agents_visualizations/ and the following code (right at the beginning) doesn't work.

using InteractiveDynamics, Agents
using CairoMakie
daisypath = joinpath(dirname(pathof(InteractiveDynamics)), "agents", "daisyworld_def.jl")
include(daisypath)
model, daisy_step!, daisyworld_step! = daisyworld(;
    solar_luminosity = 1.0, solar_change = 0.0, scenario = :change
)

My dependencies:

Julia 1.7.2
Agents v5.4.0
CairoMakie v0.8.8

The error is:

MethodError: no method matching ids_in_position(::Tuple{Int64, Int64}, ::AgentBasedModel{GridSpaceSingle{2, true}, Daisy, typeof(Agents.Schedulers.fastest), Dict{Symbol, Any}, MersenneTwister})
Closest candidates are:
  ids_in_position(::Union{Int64, Tuple{Int64, Int64, Float64}, Tuple{Vararg{Int64, N}}, Tuple{Vararg{var"#s3", M}} where var"#s3"<:AbstractFloat} where {N, M}, ::AgentBasedModel{<:GridSpace}) at ~/Agents.jl/src/spaces/grid_multi.jl:243
  ids_in_position(::Union{Int64, Tuple{Int64, Int64, Float64}, Tuple{Vararg{Int64, N}}, Tuple{Vararg{var"#s3", M}} where var"#s3"<:AbstractFloat} where {N, M}, ::GridSpace) at ~/Agents.jl/src/spaces/grid_multi.jl:244
  ids_in_position(::A, ::Any) where A<:AbstractAgent at ~/Agents.jl/src/spaces/discrete.jl:49
Stacktrace:
 [1] update_surface_temperature!(pos::Tuple{Int64, Int64}, model::AgentBasedModel{GridSpaceSingle{2, true}, Daisy, typeof(Agents.Schedulers.fastest), Dict{Symbol, Any}, MersenneTwister})
   @ Main ~/.julia/packages/InteractiveDynamics/NBLxn/src/agents/daisyworld_def.jl:16
 [2] daisyworld(; griddims::Tuple{Int64, Int64}, max_age::Int64, init_white::Float64, init_black::Float64, albedo_white::Float64, albedo_black::Float64, surface_albedo::Float64, solar_change::Float64, solar_luminosity::Float64, scenario::Symbol, seed::Int64)
   @ Main ~/.julia/packages/InteractiveDynamics/NBLxn/src/agents/daisyworld_def.jl:136
 [3] top-level scope
   @ ~/Agents.jl/examples/interactivity-test.jl:27

Thanks!

tatakof commented 2 years ago

After updating/upgrading packages to what was used in the document by running:

pkg> add Agents@5.4.3 CairoMakie@0.8.12 InteractiveDynamics@0.21.10

I got a new error:

ERROR: UndefVarError: id_in_position not defined
Stacktrace:
 [1] update_surface_temperature!(pos::Tuple{Int64, Int64}, model::AgentBasedModel{GridSpaceSingle{2, true}, Daisy, typeof(Agents.Schedulers.fastest), Dict{Symbol, Any}, MersenneTwister})
   @ Main ~/.julia/packages/InteractiveDynamics/q73Ef/src/agents/daisyworld_def.jl:17
 [2] daisyworld(; griddims::Tuple{Int64, Int64}, max_age::Int64, init_white::Float64, init_black::Float64, albedo_white::Float64, albedo_black::Float64, surface_albedo::Float64, solar_change::Float64, solar_luminosity::Float64, scenario::Symbol, seed::Int64)
   @ Main ~/.julia/packages/InteractiveDynamics/q73Ef/src/agents/daisyworld_def.jl:121
 [3] top-level scope
   @ ~/Agents.jl/examples/interactivity-test.jl:27
Datseris commented 2 years ago

Did your packages actually get updated to these versions? because at these versions the code works for me, otherwise the online docs wouldn't build.

tatakof commented 2 years ago

now I realize they did not. Now after fixing the packages, the code works. Thanks for the quick response George!