Reputation: 27
I have three sources that create agents and then flow into a queue. All three sources create different agents. My idea is to assign an ID (numerical value of int) to each created agent in each source at "Actions - On before Arrival". The ID should be unique. So it should be prevented that the sources generate the same ID . All ID coming from source 1,2,3 should be stored in the queue in a list after FIFO and output. To do this, I want to create a variable that can then store and output all the ID created.
Can someone help me and find a suitable code for the "source" which assigns an ID to each agent?
I have not managed to find a code that satisfies this property.
Upvotes: 0
Views: 82
Reputation: 12795
Add a variable of type int
named counter
next to the sources. In each source's "on at exit" code box, write:
counter++;
agent.set_p_MyID(counter);
this assumes all your agents created by the sources have a parameter of type int
name p_MyID
With this universal counter, you will get unique ids.
Upvotes: 0