Search code examples
anylogic

Drawing agents on top of GIS points in a more scalable way


The problem I am facing is the following:

I have an agent type called "Center" (blue dot in the first image) and I want to draw 3 agent members onto the GIS points (Milwaukee, Madison and Chicago). What I did was to drag in 3 instances into Main and assign them manually to each GIS point. View images below:

enter image description here

So 'center' got allocated to 'Milwaukee', 'center1' to 'Madison' and 'center2' to 'Chicago'. View below for how i did it for the first case:

enter image description here

When running the model, it worked well, and each agent instance was placed on top of the GIS points.

However, this solution is obviously not scalable if I were to handle e.g. 10 000 GIS points. Is there an elegant way to scale this up without having to drag in instances for each GIS point?


Solution

  • Start by creating a collection of the GIS points on which you want a shape to be placed. The fastest way is to go to the project browser, find the GIS points, select them and right-click on create collection. So that will be a click of a button no matter how many points.

    enter image description here

    This will be the result:

    enter image description here

    Then, drag and drop an agent population (make it a population, not a single agent).

    enter image description here

    Write the following in the initial number of agents:

    collection.size()
    

    And have the initial location as:

    collection.get(index)
    

    Finally, make sure you've added the shape you want in your agent window and click on show presentation in main:

    See image below:

    enter image description here