anylogic - How to assign a parameter to agents separately on creation in a source block? - Stack Overflow

How can I set the parameter of an agent when it is created in a source block?In my case I create agent

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
Add a comment  | 

1 Answer 1

Reset to default 1

In 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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742369000a4430878.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信