Agents.jl Schedulers not defined error


I’m new to Agents.jl and Julia. I’ve been trying out the example from

I get the error UndefVarError: Schedulers not defined when trying to run the following code.

using Agents

space = GridSpace((10, 10); periodic = false)

mutable struct SchellingAgent <: AbstractAgent
    id::Int             # The identifier number of the agent
    pos::NTuple{2, Int} # The x, y location of the agent on a 2D grid
    mood::Bool          # whether the agent is happy in its position. (true = happy)
    group::Int          # The group of the agent, determines mood as it interacts with neighbors

properties = Dict(:min_to_be_happy => 3)

schelling = ABM(
    properties = properties,
    scheduler = Schedulers.by_property(:group),

I understand that Schedulers is a submodule inside the Agents package. What could be the reason that it is not working?

In pkg REPL I ran test Agents and this resulted in 5 failed tests as shown in

I have uninstalled and reinstalled Julia, including removing the ~/.julia folder. But the error persists.

This code segment was working earlier. But unsure what I did to break it.

Any help would be much appreciated. I’m stuck now and not sure where to look for clues.

Julia Version 1.6.1 and Agents v4.0.1

Thank you!

v4.0.1 is older, so it follows this syntax. You can either stick with v4 for now and learn most of what you need there, or upgrade to the most recent version of Agents and use the example file you linked above.

Let me know if you’re not sure how to upgrade your version.

1 Like