Search code examples
gissimulationanylogicagent-based-modelingstatechart

How I can send command to the person agents living in one specific GIS region? Consider there are several GIS regions


Suppose there are 1000 Person agent on 4 (a,b, c,d) GIS region area. On a certain event, I want to communicate with all the agents living inside GIS region "a" . In "a" region we have 200 person agents.If I send message or command to Person state chart, how I can make sure that only those 200 person agents living on that specific GIS region "a" is getting my command? Is there any way to model that?


Solution

  • You can filter messages inside the Agent's statechart transition, in order to only executethe transition when a certain expression is true (in your case: Agent is in the right region).

    Filter transition execution

    Of course you could do this filtering in a lot of other places too, for example when sending the message, or when receiving it. However you can always use this code to check if the Agent is located inside of a GISRegion:

    main.gisRegion1.contains(this.getLatitude(), this.getLongitude())

    This is assuming you executed this inside the Agent (therefore main. and this.) and the region you are looking for is named gisRegion1.