简体   繁体   中英

How to assign individual attributes to Any Logic Agents

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM