Generic Agent

 Generic Agent

The Generic Agent is can be used as a non-GIS based agent in your model. This is especially useful as VectorAgents are closely tied to the GIS representation.

Appropriate Parent Component

GIS Model. The Generic Agent is added to a GIS Model.

Properties

Properties are the items that appear in the property pane when you click on a component in the project tree. For more information of properties, see here.

Name     Description
Actions See the section on Actions and editing them if you are unfamiliar with Actions.

Generic Agent defines one action by default.

  • step. The step action is where you define the behavior of your agents. Of course, you can have your step action call other actions, but the step action of every agent created from your agent component is by default executed every iteration of your simluation.
Group Name The name of the Default Group into which you can put the agents created from this Generic Agent Component. Note that the agents produced by Generic Agent are NOT automatically created and inserted into an agent group. This needs to be done manually and is typically done in the initAgents action of your model. This group becomes an implicit field in the model. See the section on Agent Groups in the GIS Model documentation.
Name The name of the agent. This property is used internally by RepastPy and must not contain any spaces or quote characters. The name of the agent will be used in any errors associated with the agent's code. You can use this to name your agent's type to something more descriptive of its function. For example, if the agent represents a resident in a region, then you set the name property to Resident.
Fields See the the Fields section of the help docs for information on creating and editing fields. Here you can define any fields you want your agent to have.
Parent Class You can choose another Generic Agent producer here that will act as the "Parent Class" for this Generic Agent producer. In practice what this means is that the agents produced by this producer include all of the actions and fields of the agent produced by the parent Generic Agent producer. If you wish to call the parent class action when the child contains an action of the same name, you can do this in the typical Pythonic way by specifying the name of the parent agent followed by the action name. Note that if child doesn't contain an action of the same name, you can call the action in the normal manner.
Schedule See the schedule help and tutorial 3 for more information on the schedule property. The schedule property defines the execution schedule of any actions defined in your model.




Usage

A good example of using a Generic Agent is provided in the demonstration schelling_gis project.

As mentioned above Generic Agents are not automatically created by RepastPy and added to an agent group for you. You will need to do this yourself. Typically this is done in the initAgents action of your model. For example,

for i in range(10):
  agent = GenericAgent()
  agent.setModel(self)
  self.genericAgentGroup.add(agent)

This will loop 10 times, creating 10 GenericAgents, providing them with a reference to the model and adding them to the an agent group.