Swarm Libraries

Swarm libraries serve two major functions. The libraries are a set of classes that model builders can use by direct instantiation. For many objects, especially highly technical ones such as schedule data structures, it's likely that all a user will ever do is use the classes as provided. But in addition, one can use Swarm libraries by subclassing them, specializing particular classes for particular modeling needs. Both modes of using the Swarm libraries are important; Swarm is designed to facilitate both as appropriate.

Simulation Libraries

The main novelty in the Swarm system is the design of the simulation-specific libraries themselves. The swarmobject, activity, and simtools libraries are the center of the Swarm modeling paradigm; their use is essential to all Swarm models.

The swarmobject library contains the core classes upon which agents in Swarm models are based. At the center of this library are two classes: SwarmObject and Swarm. SwarmObject is the root class for all simulated agents: all agent classes inherit behavior from it. SwarmObject defines the basic interface for memory management as well as the support for probes. In addition, the Swarm class is in the swarmobject library. Model swarms and observer swarms are written by using code inherited from this base class.

The activity library contains the heart of the simulation mechanism, the scheduling data structures and execution support. The underlying structure of the activity structures are partial orders, time dependencies between two events. A common special case of partial orders is a time-ordered schedule, a clock with specific events at particular times. These schedules are implemented in activity as a collection of actions sorted by timestamp.

Ambiguity can occur in partial orders and time-based schedules as a result of two or more actions scheduled at the same time or in the same relative order. Swarm resolves such ambiguity by defining a ``concurrent group type,'' an explicit indication of how to execute a group of actions that are defined at the same time. Options include running the group in an arbitrary, fixed order; running the group in a random order every time; or actually running each action concurrently, for future implementation on parallel machines. The explicit notation of a concurrent group type helps to expose and remove any hidden assumptions in the time structure of a model.

The final Swarm library specifically for simulation is the simtools library, a miscellaneous collection of classes needed to build simulations. simtools contains classes to control the execution of the entire simulation apparatus. Two modes of operation are supported: a fully graphical mode for interactive exploration and a batch mode for offline data collection. simtools also contains the data analysis and display support. The library contains classes that can generate summaries of statistical data, draw time series graphs, etc. Data analysis objects are completely generic in their application; users specify the particular data to collect by creating probes on the observed objects.

Software Support Libraries

In addition to simulation support libraries, Swarm also contains libraries that were written to support modeling but could also have applications beyond simulation. Whereas the simulation-specific libraries are used to define and execute the Swarm style of simulation, the defobj, collections, random, and tkobjc libraries do the more prosaic job of encapsulating the basic engineering tasks that are needed to write effective software.

defobj and collections are a set of general-purpose tools for building OO programs. collections implements the container classes used to track objects in a system: maps, lists, sets, etc. defobj defines the infrastructure for the Swarm object model. It augments the basic Objective C runtime to support tunable implementations, a split between object interface and implementation that provides highly optimized specific solutions to customizable forms of abstract object designs. This framework is used by the collections library to provide a group of classes that are simple to use but have complicated machinery underneath to efficiently handle a wide variety of object tracking needs.

The random library gives the user a suite of random number generators. In computer simulation the quality of random number generators is absolutely essential: it is very easy to have subtly wrong results because of a generator with biases or correlations. The Swarm random number library includes several classes of generators drawn from published research. It includes a bibliography as well as tested implementations. Because the library itself is object oriented it is simple to have multiple, independent random number streams, a feature that aids repeatability of experiments.

The final library of basic programming support in Swarm is tkobjc, a graphical user interface library based on Tcl/Tk [6], which in turn is based on X windows. The classes in tkobjc encapsulate the basic objects needed to make a user interface: buttons, raster displays, histograms, graphs, forms, etc. The library itself is intended to be very simple and easy to use, implementing enough for common graphics needs. If a tkobjc class is not powerful enough, a user can use the lower Tcl/Tk level to write more specific code.

Model-specific Libraries

In addition to the support and simulation libraries required for all Swarm applications there are several optional libraries that can be used for particular modeling domains. Libraries exist to support two dimensional spaces, genetic algorithms, and neural networks. Development effort for Swarm so far has concentrated on the required libraries; now that the Swarm infrastructure is in place, effort is shifting towards building more model-specific libraries. There are many opportunities for user-contributed code.

The Swarm distribution comes with a simple space library, a set of classes for two dimensional discrete lattices. These sorts of spaces are common in ecosystem simulations. The base class in space is an two dimensional array that stores objects or integer values at particular grid points. Several classes inherit from this base to provide dynamics, for instance a cellular automata approximation to diffusion. The current space library is merely a suggestion of the kinds of environments a model could use: in the future, we plan to have spaces with continuous values and dynamics defined by differential equations. Spaces with other topologies are also crucial: three dimensions, non-discrete coordinates, and arbitrary graph structures are all needed by applications.

The final libraries currently available for Swarm are the ga and neuro libraries. This code represents Swarm's first user-contributed libraries, software written by Juan J. Merelo while visiting the Santa Fe Institute. ga provides a set of classes for basic genetic algorithms; neuro implements a variety of neural networks. As Swarm matures, we hope that it will grow with the contributions of users.


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

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