So I have several different agent types: Person, Factory, Hospital, Home, Doctor. Now, all of these agents except Person are connected through a network, while the initial population size of Person = 0.
Now, when the model runs, Person agents will be generated with a given rate. What I want to accomplish is that each instance of Person determines which instance of Factory, Hospital or Home is the nearest, and then makes a connection to that particular agent.
How would I accomplish this?
I have so far been able to let instances of Person connect to the nearest Hospital, the nearest Factory, or the nearest Home. I wrote the following code in the entry action box in a Person's statechart:
Hospital nearestHospital = this.getNearestAgent(main.Hospital); this.connectTo(nearestHospital);
But I have been unable to let the instances of Person determine the nearest instance of Hospital, Factory, Home concurrently.