JuliaDynamics / Agents.jl

Agent-based modeling framework in Julia
https://juliadynamics.github.io/Agents.jl/stable/
MIT License
736 stars 119 forks source link

Improve time offset implementation #1007

Closed Tortar closed 6 months ago

Tortar commented 6 months ago

this improves the time offset implementation, the collected dataframe is no more modified, the points are just moved in the plots

Tortar commented 6 months ago

I verified it works correctly by running and verify the working of

using Revise
using Agents, GLMakie
using AgentsExampleZoo

model = AgentsExampleZoo.daisyworld(;
    solar_luminosity = 1.0, solar_change = 0.0, scenario = :change
)

daisycolor(a) = a.breed # agent color
agent_size = 20    # agent size
agent_marker = '✿'  # agent marker
agentsplotkwargs = (strokewidth = 1.0,) # add stroke around each agent

heatarray = :temperature
heatkwargs = (colorrange = (-20, 60), colormap = :thermal)
plotkwargs = (;
    agent_color = daisycolor, agent_size, agent_marker,
    agentsplotkwargs = (strokewidth = 1.0,),
    heatarray, heatkwargs
)

params = Dict(
    :surface_albedo => 0:0.01:1,
    :solar_change => -0.1:0.01:0.1,
)

using Statistics: mean
black(a) = a.breed == :black
white(a) = a.breed == :white
adata = [(black, count), (white, count)]
temperature(model) = mean(model.temperature)
mdata = [temperature, :solar_luminosity]
fig, abmobs = abmexploration(model;
    params, plotkwargs...,  adata, alabels = ["Black daisys", "White daisys"],
    mdata, mlabels = ["T", "L"]
)
fig
Tortar commented 6 months ago

it's probably better if we add a slightly modified version of this to #1001 but it doesn't work as intended there because the branch already doesn't work correctly, so first that should be fixed

Datseris commented 6 months ago

Can you please do this PR on the existing branch of PR #1001 ?