0

Through my model, I have 3 types of agents. Currently, I can only know the total number of A in Source. But my purpose is to know the number of A, B, and C respectively through Source. So logically, I need to put Agent of A, B and C together and then count their number separately. However, I cannot find a way to achieved it?

Winnie
  • 1
  • 2

1 Answers1

0

Depending on how the agents are generated, but a good approach would be to have a separate source for each agent (A, B and C) and count number of agents emitted from each source. This can be done by calling source.out.count(), where source is a Source object, out is the exit port and count() is a counter that shows the number of agents as a small blue number.

Artem P.
  • 816
  • 1
  • 6
  • 8
  • Thank you! I tried to add 3 sources before, however, the problem is in my process of logic, in each block, the Agent type can only be one type of agent the other 2 can not work. So, do you have another way to get the different Agents together? For my agents, I set up 3 types of workers, or maybe can I set an agent which is named workers, and then set 3 parameters which are different values? – Winnie Jul 14 '21 at 09:31
  • You have two options: Agent inheritance as described [here](https://anylogic.help/anylogic/agentbased/inheritance.html#agent-inheritance) and use the common type in process blocks or the parameter-based approach you've described. – Artem P. Jul 14 '21 at 09:34
  • Great, can you please mark the questions as 'answered'? – Artem P. Jul 14 '21 at 10:14
  • Thank you a lot. One more question, I did the actions that we discussed before. However, the new problem is, in the Source, it shows the total number, but I can't distinguish the number of each type of parameter, should I do something through another method to get the 3 numbers? – Winnie Jul 14 '21 at 10:20
  • Ok, which method did you use? Inheritance or property-based? – Artem P. Jul 14 '21 at 10:27
  • Inheritance method – Winnie Jul 14 '21 at 10:35
  • well if you're using inheritance method then you should be able to have 3 sources each emitting an agent of different sub-type. – Artem P. Jul 14 '21 at 11:53