How can I set the parameter of an agent when it is created in a source block?
In my case I create agents of type "Pallet" in the source block. This agent has a boolean parameter "Tracker". The assignment of the trackers should be random, but follow a certain coverage of the trackers. In the end I want to perform a Parameter variation experiment where I want to vary the coverage of trackers.
I tried various ways to access or set the agents parameter: self.Tracker
, agent.Tracker
, pallet.Tracker
but none of them work, throwing different error messages.
I know this is not SOF style but if it is answered easily I would appreciate another hint on: How can I access the parameter later on, i.e. in queue blocks or so, to see how many agents with which parameter value are in the blocks?
How can I set the parameter of an agent when it is created in a source block?
In my case I create agents of type "Pallet" in the source block. This agent has a boolean parameter "Tracker". The assignment of the trackers should be random, but follow a certain coverage of the trackers. In the end I want to perform a Parameter variation experiment where I want to vary the coverage of trackers.
I tried various ways to access or set the agents parameter: self.Tracker
, agent.Tracker
, pallet.Tracker
but none of them work, throwing different error messages.
I know this is not SOF style but if it is answered easily I would appreciate another hint on: How can I access the parameter later on, i.e. in queue blocks or so, to see how many agents with which parameter value are in the blocks?
Share Improve this question edited Nov 20, 2024 at 9:31 Charlotte Fränkel asked Nov 20, 2024 at 9:25 Charlotte FränkelCharlotte Fränkel 351 silver badge4 bronze badges 1- Do open a 2nd question for the 2nd issue, pls. This helps future users to find specific issues faster (and not get them buried at the end of a long question) – Benjamin Commented Nov 20, 2024 at 9:54
1 Answer
Reset to default 1In my case I create agents of type "Pallet" in the source block.
No, you still create generic agents, see your properties. You need to select "Pallet" in the "New agent" dropdown.
Only then do you have access to its parameters. You can set them in the Source block's "on at exit" using agent.set_MyParam(yourValue);
Or you use the population, where Tracker
is already waiting for what it should be.
PS: Strongly recommend you do all the step-by-step tutorials as they cover these basics and much more: https://anylogic.help/tutorials/index.html