Schedule agents by type

Schedulers.by_type works differently than how you use it here. See here. It’s for activating agents in certain order determined by their type.

To do what you want to do, you need to construct an iterable (e.g. a vector) of all the agent ids for agents of a given type. Something like

function by_type(T, model)
    ids = Int[]
    for id in allids(model)
        if model[id] isa T 
            push!(ids, id)
        end
    end
    return ids
end

should work, I suppose? I don’t have a mixed agent model at hand right now, so I can’t test it. Worked just fine for a model with a single agent type.

1 Like