Network Model

Network Model

This is a network model. It contains the common model properties for initializing and creating a simulation. It is appropriate for creating simulations using a network topology.

Appropriate Parent Component

Environment. The default network model is automatically added to the Environment component.

Properties

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

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

Network Model includes a single default action: initAgents. This action will be executed at the beginning of the simulation as part of set up. This action will execute after the agents (network nodes) have been created and added to their respective groups. Consequently, you can iterate through an agent group and perform any additional custom initialization. For example,

for agent as Agent in self.nodes:
  agent.init()

which will iterate through all the agents in the nodes group and call the init() action on them. This assumes of course, that you have created an init action for your Agent component.

Display Name This name will be displayed as the title of your model when it is running.
Master Schedule See the schedule help and tutorial 3 for more information on schedules and scheduling.

The master schedule property gives you an editable view of all the scheduled actions in relation to each other. You can edit their relative order here. By default, the step action of every agent is scheduled to execute every iteration of the simulation beginning at the first iteration.

Model Name The name of the model used internally by Repast Py during compilation. This name should not have any spaces it in it. The java class created by Repast Py uses this name.
Fields See the the Fields section of the help docs for information on creating and editing fields. Here you can define any fields (variables) you want your model to have.
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.



Implicit Fields

Implicit Fields are variables that the Repast Py exposes for your use in code. For example, if there is an implicit field named agentGroup, you can refer to that field with self.agentGroup in your NQPy code.

Name     Description
Agent Groups For each type of agent that you create, Repast Py creates a DefaultGroup (a Java class) that contains all the agents of that type. The name of this variable is the value of the Agent Component's Group Name property. For example, if the group name is "agents" then Repast Py will create a Default Group called "agents". You can access this group from within model actions with self.groupName (e.g. self.agents). These groups are also exposed via a "get" accessor method. So, assuming you have a reference to the model, you can do something like model.getGroupName() (e.g. self.getAgents()). A Default Group in general behaves much like an indexable list. So, you can do things like

agent = self.agents.get(3)

to get the third agent in the list, and

numAgents = self.agents.size()

to get the size of the Default Group and so on.



Java Parent Class

Many of the Repast Py components are based on Java code. What this means is that these components come with built-in fields and methods inherited from their Java parent classes. The docs below describe these built in fields and methods.

Network Model is based on SimModelImpl. SimModelImpl is a partial implementation of the SimModel interface. Most, if not all, actual models will inherit from this class. By default SimModelImpl initializes the random number generator in the Random class using the current timestamp as a seed. Random can then be used for random number generator. If you need to have two random number streams with different seeds, you'll need to make your own. See the random number how to in repast/docs/how_to/random.html for more information. When data is collected from a model, it is this seed for this rng that is written out.


The fields of a Java parent class can be used just as if they were fields in your own model. For example, self.descriptors and so on. The format used below is

field name : field type
description

where the field type is a Java class type.

Java Parent Class Fields
descriptors : Hashtable
Used to store property descriptors. The key should be the property or parameter name and the value the descriptor associated with that property.

modelManipulator : ModelManipulator
A ModelManipulator that can be used to manipulate the model at run time.


The methods or actions of a Java parent class can be used just as if they were actions in your own model. For example, self.setRngSeed(33) and so on. The format used below is

method name(argument types, if any) : return type - an optional explanation of the return type
description

where the return type is a Java class type.

Java Parent Class Methods (Actions)
addPropertyListener( PropertyListener ) :
Adds a PropertyListener to this model.

addSimEventListener( SimEventListener ) :
Adds a SimEventListener to listen for SimEvents broadcast from this model.

clearMediaProducers( ) :
Clears the vector of media producers.

clearPropertyListeners( ) :
Clears the list of PropertyListeners.

fireBooleanPropertyEvent( PropertyEvent ) :
Broadcasts a boolean property event to all this model's PropertyEventListeners.

fireEndSim( ) :
Broadcasts a SimEvent with an id of SimEvent.END_EVENT to all this model's listeners.

fireNumericPropertyEvent( PropertyEvent ) :
Broadcasts a numeric property event to all this model's PropertyEventListeners.

fireObjectPropertyEvent( PropertyEvent ) :
Broadcasts an object property event to all this model's PropertyEventListeners.

firePauseSim( ) :
Broadcasts a SimEvent with an id of SimEvent.PAUSE_EVENT to all this model's listeners.

fireSimEvent( SimEvent ) :
Broadcast the specified SimEvent to all this model's SimEventListeners

fireStopSim( ) :
Broadcasts a SimEvent with an id of SimEvent.STOP_EVENT to all this model's listeners.

fireStringPropertyEvent( PropertyEvent ) :
Broadcasts a string property event to all this model's PropertyEventListeners.

generateNewSeed( ) :
Generates a new seed for the random number generator using the current timestamp.

getAgentList( ) : ArrayList
Gets list of agents controlled by this model.

getController( ) : IController
Gets the BaseController associated with this model.

getMediaProducers( ) : Vector
Gets the mediaProducers registered with this model. The returned vector will contain a ProducerNamePair objects.

getModelManipulator( ) : ModelManipulator
Gets the ModelManipulator.

getParameterDescriptors( ) : Hashtable
Gets a hashtable of ParameterDescriptors where key is parameter name, and value is the ParameterDescriptor.

getPropertiesValues( ) : String - a list of the model parameters and values.
Gets a String listing the model parameters and values. For example, <pre> MaxVision: 3 MaxMetabolism: 4 NumAgents: 52 </pre>

getRngSeed( ) : long
Gets the current random seed.

getTickCount( ) : double
Gets the current tick count

pause( ) :
Pause the simulation.

registerDisplaySurface( String , DisplaySurface ) :
Registers a DisplaySurface with this model and associates it with a particular name.

registerMediaProducer( String , MediaProducer ) :
Registers a MediaProducer with this model and associates it with the specified name.

removePropertyListener( PropertyListener ) :
Removes a PropertyListener from this model.

removeSimEventListener( SimEventListener ) :
Removes a SimEventListener from the list of listeners listening for SimEvents broadcast from this model.

setController( IController ) :
Sets the controller associated with this model

setRngSeed( long ) :
Sets the random number generator in Random to a new value. Note this will invalidate any distributions created with Random. These will need to be recreated.

stop( ) :
Stops the simulation.