S. Luise
S. Luise

Reputation: 3

How can I create new agents in a function in the agent Class that have certain parameter values?

I have created a function in the Palette agent class that assigns certain values to the parameters p_quantity, p_articleID and p_customerID.

If p_quantity > 600, I want a 2nd agent to be created with the same parameters of this agent. Only that the 2nd agent has the remaining quantity as parameter value.

For example, if p_quantity = 900, then there should be 2 agents with the same customer ID and item ID. But one agent has the quantity 600, the other the remaining 300.

My consideration was a for loop in the function that is called in the "on startup" field of the agent class. However, I cannot access the agent population here. Could someone help me with this?enter image description here

Upvotes: 0

Views: 67

Answers (1)

Benjamin
Benjamin

Reputation: 1

Your agent population sits 1 level higher in the hierarchy, i.e. main.add_Pallete(...) should work.

Learn about your model hierarchy and how to navigate it here: https://anylogic.help/advanced/code/access.html#where-am-i-and-how-do-i-get-to

Upvotes: 0

Related Questions