Accessing agent- and model-data in combination

Hi. I want to use abm_exploration to display data that requires access to both agents and model, something like this:

function demo()
	model = initialise_model()
	params = Dict(
		:reaction_norm => 0:0.01:1,
	)
	plotkwargs = (
		ac=(ag->ag.exploit),
		as=30,
		adata = [
			((agent->(agent.genetic_radius < model.food_radius)), count),
		],
		alabels=["Genetic success"],
	)
	playground, = abmexploration( model; agent_step!, params, plotkwargs...)

	playground
end

The problem seems to be that model is not available to adata - I had hoped that model.food_radius would simply insert its numberical value into the call, but that is not the case. I thought of evaulating model.food_radius before the call to abmexploration, but I couldn’t find out how to do it. Can someone please tell me what I’m missing?

Thanks.

Hi, the model and the agents are available to the mdata though. So you can create a custom function that access the model field you want, and its agents with e.g. looping over allagents(model).

CU!

George (he/him)

Got it - thanks very much! :smile: