Creating a population of
To create a population
- Drag the Agent
element from the Agent
the diagram of the agent type where you want to create the
population of agents (usually - Main
type). The New agent
dialog box will be
- First, choose, whether you want to create the agent
population, one single agent, or you just define the
agent pattern. Click Population
of agents. The wizard will
take you to the next step.
- If you already have some custom agent types in your model, you will be asked whether you want to create a new type (I want to create a new agent type option), or use the existing agent type (I want to use an existing agent type).
- Here you should choose whether you will read agent
attributes from database, or create a new agent type "from scratch". We
describe how to create agent population using a database here. Choose the option Create the agent type "from scratch".
- On the same page of the wizard, specify the Agent type name (e.g. Person). You will see that the Agent population name changed automatically.
- If you plan to use the agents of this type in the flowcharts
(e.g. in the Process Modeling Library flowchart, or as a
pedestrian in Pedestrian Library flowchart), select the checkbox Agent will be used in flowcharts
and then choose the role for this agent from the drop-down list to
the right. Click Next.
- Specify the
animation for the agent. Here you can choose some animation shape for
your agent. If you want the agents to be animated both in 2D and 3D,
choose 3D and select the
animation shape from the list below. If you need the shape that is
shown only in 2D, choose 2D. Choose the shape from the list, or if no shapes satisfy your
needs, just choose None. You
can draw animation on the agent type later on whenever you need.
Finished with choosing the animation, click Next
to proceed to the next step.
Specify the parameters for this agent type. Click <add new...>
in the list on the left to create a new parameter. Having selected a parameter in
list, you can set its name, type and initial value using the controls
in the right panel. Select the parameter and click the "cross" button
at the bottom to remove the parameter from the list. Click Next
when finished defining all the required parameters for this agent type.
- On the next page of the wizard you have to define the initial
number of agents in the population. Choose whether you want to Create population with specified
number of agents, or you want to Create
initially empty population and add agents later on dynamically
(e.g. in the Startup code of Main). In the example below, we are creating
the population with 1000 agents. Click Next
and you will get to the last page of the wizard.
- Here you may configure the environment where these agents will
live. Choose the type of the space (Continuous,
GIS, or Discrete), and configure it using
the controls below. Having chosen the continuous or discrete space type, define the space
dimensions, width and height, in the Size fields (in the case of discrete
space, you should also define the number of rows and columns that make up the
space, in the Cells fields).
- The drop-down list Network
type allows you to choose
how the network of agent contacts should be created. You can find more
information on agent networks here. In the example
below, the network type is User-defined.
- You can make AnyLogic randomly locate agents of this population in the space. To do this, select the option Apply random layout.
- Click Finish to end the
When finished, you will see the
element on the diagram
- it is agent population. The
population contains the specified number of agents - instances of
the agent type. You can
see the created agent type in the model tree (in the figure given below
it is Patient):
Open the diagram of this class (by double-clicking it in the Projects
view) and you will see the animation and parameters you have chosen for
this agent while creating it with the wizard. You can add variables,
parameters, statecharts, and any other elements defining the agent
state and behavior here.