0
votes

I would like to solve the following issue:

  • agent based model with a population of 500 agents
  • each agent gets assigned with an ID number using a variable called v_agentID using the order v_agentID++; after being created
  • The agent should then be further processed based on a condition monitoring the individual waiting time

How can I assign individual attributes like waiting times (as a result of the calculation waitingTime=waitingTimeEnd-waitingTimeStart)to each individual agent?

Thanks a lot for your help.

Bastian

1

1 Answers

0
votes

Many ways:

1) create a cyclical event on the individual agent that calculates waitingTime with the formula you provided
2) create a dynamic variable for each agent and make it equal to waitingTimeEnd-waitingTimeStart
3) create the variable whenever you want and change it in all the agents:

for(Agent a : agents){
    a.waitingTime=a.waitingTimeEnd-a.waitingTimeStart;
}

4) Find the agent with the id you want and assign the variable to it

Agent theAgent=findFirst(agents,a->a.id=theIdYouWant);
theAgent.waitingTime=theAgent.waitingTimeEnd-theAgent-waitingTimeStart;

5) If you know the index of the agent just do

agents.get(index).waitingTime=agents.get(index).waitingTimeEnd-agents.get(index).waitingTimeStart