EX:
I have a population people
with agent type Person
with a parameter wrist_size
.
In the agent type Person
I've created another population =watches
, agent type =Watch
.
Now I want to create a variable in the lower agent type that will be based on the parameter of the upper agent.
length
of the watch
should be equal to the wrist_size
of the person
What should code should I put to the variable?
Many thanks.
You can simply use people.wrist_size
in the "initial value" field of Watch.length
.
Each embedded population (here Watch
within Person
) gets a "link" up to their parent agent (here Person
named people
).
See https://anylogic.help/advanced/code/access.html#where-am-i-and-how-do-i-get-to for understanding model hierarchies.