Object Oriented Technology

The logical structure of swarms of agents interacting through discrete events is implemented in a straightforward way in Objective C, an object oriented (OO) language. In OO programming software consists of the definitions of various classes of objects. An object is a combination of instance variables for the object's state and methods that implement the object's behavior [7]. In Swarm an agent is modeled directly as an object. Types of agents (generic coyotes) are classes, and specific agents (a particular coyote) are objects, instances of the Coyote class. Each object carries with it its own state variables, but the generic definition of its behavior is provided by the class.

The instance variables for an object directly represent the state of the agent. For example, a particular rabbit's mass could be stored as an integer variable in the class Rabbit. The methods of an object implement the behavior of the agent. Rabbits hide: this is implemented by having a ``hide'' method defined on class Rabbit. The schedule of activity for a model is then simply a partially ordered series of such actions to be performed on objects. Each action specifies a method to be executed on a target object.

The Swarm system itself is an object framework: a set of class libraries that are designed to work together. There are seven core libraries in Swarm: defobj, collections, random, tkobjc, activity, swarmobject, and simtools. The first four libraries are support libraries with potential use outside of Swarm; the last three are Swarm-specific. There are also currently three domain-specific libraries available for Swarm model builders: space, ga, and neuro. The details of each library is discussed below.

In addition to being a natural way to implement multiagent simulations, OO programming is also a convenient technology for building libraries of reusable software. Users can start to build models by directly instantiating useful classes from the Swarm libraries. If there is no particular class that has the precisely needed behavior, one can take a preexisting class and specialize it, adding new variables and methods via inheritance. Inheritance and OO encapsulation make writing reusable code easier than traditional procedural programming. This in turn makes it easier for people to share Swarm modeling software they have written, facilitating the exchange of ideas and techniques within simulation communities.

One addition to standard OO programming that Swarm implements is the ``probe'' facility. In most computer programs, it is enough that the program does what you want -- that Windows doesn't lose your files, that your word processor can print out your papers. But in simulation it is important that all aspects of the computation be observable, that it be easy for the researcher to measure data from a running model. The Swarm system defines the ability for any object to be probed. Probes allow any object's state to be read or set and any method to be called in a generic fashion, without requiring extra user code. Probes are used to make data analysis tools work in a general way and are also the basis of graphical tools to inspect objects in a running system.


next up previous
Next: Structure of a Swarm Up: The Swarm Simulation System: Previous: Swarms

Formatted: Wed Jun 11 18:08:29 EDT 1997
Nelson Minar