Package topo :: Package base :: Module simulation
[hide private]
[frames] | no frames]

Module simulation

source code

A general-purpose Simulation class for discrete events.

The Simulation object is the central object of a simulation. It handles the simulation clock time and maintains communication between the components of the simulation.

A simulation is structured as a directed graph of event-processing nodes called EventProcessors (EPs). EventProcessors generate data-carrying Events, which are routed through the graph to other EventProcessors via delayed connections. Most objects in the simulation will be a subclass of EventProcessor, customized to provide some specific behavior.

There are different subclasses of Event, each doing different types of computation, and each can contain any arbitrary Python data. A simulation begins by giving each EventProcessor an opportunity to send any initial events. It then proceeds by processing and delivering events to EventProcessors in time order. After all events for the current time are processed, the simulation gives each EventProcessor a chance to do any final computation, after which simulation time skips to the time of the earliest event remaining in the queue.

PORTS

All connections between EPs are tagged with a source port and a destination port. Ports are internal addresses that EPs can use to distinguish between inputs and outputs. A port specifier can be any hashable Python object. If not specified, the input and output ports for a connection default to None.

src_ports distinguish different types of output that an EP may produce. When sending output, the EP must call self.send_output() separately for each port. dest_ports distinguish different types of input an EP may receive and process. The EP is free to interpret the input port designation on an incoming event in any way it chooses.

An example dest_port might be for an EP that receives 'ordinary' neural activity on the default port, and receives a separate modulatory signal that influences learning. The originator of the modulatory signal might have a connection to the EP with dest_port = 'Modulation'. Multiple ports can be grouped by a dest EP by assuming a convention that the keys are tuples, e.g. ('JointNormalize','Group1'), ('JointNormalize','Group2').

An example src_port use might be an EP that sends different events to itself than it sends out to other EPs. In this case the self connections might have src_port = 'Recurrent', and probably also a special dest_port.

$Id: simulation.py 11090 2010-06-22 11:09:01Z ceball $


Version: $Revision: 11090 $

Classes [hide private]
  EventProcessor
Base class for EventProcessors, i.e.
  EventProcessorParameter
Parameter whose value can be any EventProcessor instance.
  EPConnection
EPConnection stores basic information for a connection between two EventProcessors.
  Event
Hierarchy of classes for storing simulation events of various types.
  EPConnectionEvent
An Event for delivery to an EPConnection.
  CommandEvent
An Event consisting of a command string to execute.
  FunctionEvent
Event that executes a given function function(*args,**kw).
  EventSequence
Event that contains a sequence of other events to be scheduled and executed.
  PeriodicEventSequence
An EventSequence that reschedules itself periodically
  SomeTimer
Provides a countdown timer for functions that run repeatedly.
  Simulation
A simulation class that uses a simple sorted event list (instead of e.g.
Variables [hide private]
  SLEEP_EXCEPTION = 'Sleep Exception'
  STOP = 'Simulation Stopped'
  Forever = -1
  simulation_path = 'topo.sim'
  __package__ = 'topo.base'