Default Network Node
Default Network Node is the default agent component in network simulations
constructed by Repast Py. It acts as template from which all the agents
in the simulation are constructed.
Network Model. Network Nodes must
be added only to a Network Model.
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.
Actions |
See the section on Actions and editing
them if you are unfamiliar with Actions. The Actions property is
where you specify the behavior of your agent.
Default Network Node defines a single actions 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 executed by default every iteration of
your simluation.
|
Group Name |
The name of the Default Group into which all the agents created from this Agent Component will be put. This
group becomes an implicit field in the model. See the section on Agent Groups in the model
documentation.
|
Name |
The name of the agent. This name becomes the agent's type and is used internally by Repast Py.
It will also be used in your own code when you need to cast an object to the type of your agent.
For example, assuming that you've named your agent Friend
for agent as Friend in self.nodes:
agent.init()
the as Agent here ensures that the agent variable is treated as a Friend
and allows you to call any actions you have defined on the Friend agent.
|
Network Source |
The agents created from your agent component can be created a part of
a network. This property defines the structure of that network. Five types are
available, and the attributes (e.g. number of nodes, etc.) particular
to that type of network source can be edited by clicking on the edit
button.
- Matrix File. The network is created from a file description in
UCINet dl format. The editable attributes are the file name, and its
type. Type refers to the edge strength as given in the dl adjacency
matrix where binary is 0, or 1, small is -128 to 128 and large every
thing else.
- Random Density. The network is created from the specified number of
nodes, which are then linked at random according to the specified
density.
- Square Lattice. The network is created as a square lattice.
- Unlinked Nodes. The "network" is created with the specified number
of nodes that are not linked.
- Watts-Strogatz Small World. The network is created as a ring
substrate of a Watts-Strogatz type small world.
Note that the attributes of these network source types will become
implicit fields in your model component. The name of these fields will be
the agent's group name followed by the attribute name, for example, "nodesDensity".
|
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 agent to have.
|
Schedule |
See the schedule help and
tutorial 3 for more information on the
schedule property. The schedule property defines the execution schedule for
any actions defined in your agent. By default the step action is
scheduled to execute every tick.
|
|
Implicit Fields are variables that the component exposes for your use in code. For
example, if there is a field named model, you can refer to
that field with self.model in your NQPy code.
model |
Every agent has a reference to the model with which it is associated. You
can use this in your own agent action code as self.model.
|
|
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.
Default Network Node is based on the java class
DefaultDrawableNode.
DefaultDrawableNode is an implementation of the Node interface that is also
drawable. As an implementor of the Node interface, DefaultDrawableNode and thus
the Default Network Node component, contains many methods for basic network
type operations, such as adding and removing edges and nodes. In fact,
all the network type behavior that you want to construct in your simulation is
derives from these methods. For example,
self.addOutEdge(Edge)
which will add an outgoing edge from the calling node to the specified node.
Many of the sample projects included with SimBuilder are good examples of
how to work with nodes.
In addition to the network operations, Default Network Node also has some
simple cooperation game playing type operations, such as set/getPayoff and
setting strategies (LEFT or RIGHT).
The of a Java parent class can be used
just as if they were parameters in your own model. For example,
self.payoff and so on. The format used below is
field name : field type
description
where the field type is a Java class type.
-
item :
NetworkDrawable
- This does the actual drawing of the node. There is no reason to work
with this object in a SimBuilder simulation
-
payoff :
float
- The current payoff value. This is cooperation game type field
-
strategy :
int
- The current strategy for this Default Network Node. Appropriate
values are GameAgent.LEFT and GameAgent.RIGHT.
|
|
The of a Java parent
class can be used just as if they were actions in your own model. For example,
self.hasEdgeTo(someNode) and so on. Note that many of the methods
below refer to Edge and Node as method arguments and / or
return types. All Repast Py produced network nodes can be used where Node
is mentioned below. Similarly any edges associated with Repast Py produced
network nodes can be used where Edge is mentioned below.
The format used in the table 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.
-
addInEdge(
Edge
) :
- Add an in edge to this node.
-
addOutEdge(
Edge
) :
- Add an out edge to this node.
-
allowResizing(
boolean
) :
- Sets whether or not this DefaultDrawableNode will be resized to fit
its label. If this is set to true, any setting of the width or height
is ignored.
-
calcSize(
SimGraphics
) :
- Calculates the size of this DefaultDrawableNode. This is used to
ensure that the DefaultDrawableNode is large enough to accomodate its
label. This method is used internally by RePast.
-
clearInEdges(
) :
- Clears (removes) all the in edges.
-
clearOutEdges(
) :
- Clears (removes) all the out edges.
-
contains(
Point
) :
boolean
- Does this object contain the point specified by p. This is necessary
for probing when returning what is in a cell on a grid is impossible.
-
getBorderColor(
) :
Color
- Gets the border color for this DefaultDrawableNode.
-
getBorderWidth(
) :
int
- Gets the border width for this DefaultDrawableNode.
-
getColor(
) :
Color
- Gets the color of this DefaultDrawableNode.
-
getFont(
) :
Font
- Gets the label font for this DefaultDrawableNode.
-
getHeight(
) :
int
- Gets the height of this DefaultDrawableNode.
-
getId(
) :
Object
- Gets the id associated with this node.
-
getInEdges(
) :
ArrayList
- Gets the edges coming into this node.
-
getLabelColor(
) :
Color
- Gets label color for this DefaultDrawableNode.
-
getNodeLabel(
) :
String
- Gets the label of this node.
-
getOutEdges(
) :
ArrayList
- Gets the edges going out from this node.
-
getPayoff(
) : float
- Gets the current payoff value for this Default Network Node.
This is a cooperation game type action.
-
getStrategy(
) : int
- Gets the current strategy (GameAgent.LEFT or GameAgent.RIGHT) for this
Default Network Node. This is a cooperation game type action.
-
getWidth(
) :
int
- Gets the width of this DefaultDrawableNode.
-
getX(
) :
double
- Gets the x coordinate for this node.
-
getY(
) :
double
- Gets the y coordinate for this node.
-
hasEdgeFrom(
Node
) :
boolean
- Returns true if this DefaultNode has an Edge from the specified
Node, otherwise false.
-
hasEdgeTo(
Node
) :
boolean
- Returns true if this DefaultNode has an Edge to the specified Node,
otherwise false.
-
removeInEdge(
Edge
) :
- Removes the specified edge from the list of "in" edges.
-
removeOutEdge(
Edge
) :
- Removes the specified edge from the list of "out" edges.
-
setBorderColor(
Color
) :
- Sets the border color for this DefaultDrawableNode.
-
setBorderWidth(
int
) :
- Sets the border width for this DefaultDrawableNode.
-
setColor(
Color
) :
- Sets the color of this DefaultDrawableNode.
-
setDrawable(
NetworkDrawable
) :
- Sets the drawable for this DefaultNetworkNode. All the properties
(color, borderWidth, etc.) of the current NetworkDrawable will be
copied to the specified NetworkDrawable.
-
setDrawableNoCopy(
NetworkDrawable
) :
-
setFont(
Font
) :
- Sets the label font for this DefaultDrawableNode.
-
setHeight(
int
) :
- Sets the height of this DefaultDrawableNode.By default this will
be ignored and the DefaultDrawableNode will be sized to fit its
label. Do allowsResizing(false) to set the width and height
manually.
-
setLabelColor(
Color
) :
- Sets label color for this DefaultDrawableNode.
-
setNodeLabel(
String
) :
- Sets the label for this DefaultDrawableNode.
-
setNodeLabel(
String
) :
-
setPayoff(
float
) :
- Sets the payoff value. This is a cooperation game type action.
-
setStrategy(
int
)
- Sets the current strategy for this
Default Network Node. Appropriate values are GameAgent.LEFT or GameAgent.RIGHT.
This is a cooperation game type action.
-
setWidth(
int
) :
- Sets the width of this DefaultDrawableNode. By default this will
be ignored and the DefaultDrawableNode will be sized to fit its
label. Do allowsResizing(false) to set the width and height manually.
-
setX(
double
) :
- Sets the x coordinate for this node. Used by GraphLayouts.
-
setX(
int
) :
- Implements the moveable interface, setting the x coordinate to
some integer value.
-
setY(
double
) :
- Sets the y coordinate for this node. Used by GraphLayouts.
-
setY(
int
) :
- Implements the moveable interface, setting the y coordinate to
some integer value.
|
|
|