# Accessing agent- and model-data in combination

**URL:** <https://discourse.julialang.org/t/accessing-agent-and-model-data-in-combination/96517>\
**Category:** Modelling & Simulations\
**Tags:** question\
**Created:** [March 23, 2023, 3:42pm UTC](https://discourse.julialang.org/t/accessing-agent-and-model-data-in-combination/96517 "2023-03-23T15:42:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Niall](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/niall/32/22517_2.png) [@Niall](https://discourse.julialang.org/u/Niall)\
**Post date:** [March 23, 2023, 3:42pm UTC](https://discourse.julialang.org/t/accessing-agent-and-model-data-in-combination/96517/1 "2023-03-23T15:42:12Z")

</div>

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

```julia
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.

---

<div class="post-metadata">

**Author:** ![Datseris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/datseris/32/13406_2.png) [@Datseris](https://discourse.julialang.org/u/Datseris)\
**Post date:** [March 23, 2023, 5:30pm UTC](https://discourse.julialang.org/t/accessing-agent-and-model-data-in-combination/96517/2 "2023-03-23T17:30:01Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![Niall](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/niall/32/22517_2.png) [@Niall](https://discourse.julialang.org/u/Niall)\
**Post date:** [March 24, 2023, 7:46am UTC](https://discourse.julialang.org/t/accessing-agent-and-model-data-in-combination/96517/3 "2023-03-24T07:46:47Z")

</div>

Got it - thanks very much! 😄
