11.1 Environments

The Environment is used by the processes to present inputs to the Network, and to provide training values for the network as well. At appropriate intervals, the processes will ask the environment for an Event. The event is a snapshot or instance of the environment at a given time. It is up to the environment to generate the appropriate event given an index presented by the processes. Typically, these events are precomputed and the environment simply iterates over the a list of events. Optionally, an environment can perform more complicated event choosing operations and can even modify or generate events on the fly if so desired.

Sometimes the events may need to be further organized into subgroups of events in order to represent groups of events that belong in a particular sequence (see section 11.3 Representing Sequences of Events). Specialized processes like the SequenceEpoch and the SequenceProcess interact with the Environment by asking it for one of these subgroups of Events. The Sequence Epoch allows updating of weights and other operations to occur after the entire "batch" of events in the Event SubGroup has been presented (see section 12.6.1 Processes for Sequences of Events).

In the generic Environment class there are two groups:

Event_Group events
This is where the events are stored.
BaseSpec_Group event_specs
This is where the EventSpec objects are stored. Note that event specs, unlike other specs, reside in the environment, and not in the Project .specs group. This makes environments self-contained so that they can be loaded and saved independent of the project.

The following functions are defined on the Environment object. Note that a given process will either use the Group model or the Event model of the environment. The group model is for sequences, which are stored in subgroups, and the event model treats the environment just like a flat list of events.

InitEvents()
Initializes events for an epoch. Used for algorithmically generated events which are generated at the start of each epoch. This does nothing in the base class.
UpdateAllEvents()
Updates all events in accordance with their corresponding event specs.
EventCount()
Returns the number of events in the Environment. This is used by the processes to determine how long an epoch should be.
GetEvent(int event_number)
Returns a pointer to the Event corresponding to event_number. The event number should be between 0 and EventCount().
GroupCount()
Returns the number of event groups in the Environment, for sequence-based processing. This determines how many sequences go in an epoch.
GetGroup(int group_number)
Returns a pointer to the Event group corresponding to group_number, which should be between 0 and GroupCount().
ReadText(ostream& strm, EventSpec* espec, TextFmt fmt = NAME_FIRST)
Reads in an Environment from a text file which is in the format from the old PDP software. This uses the given event spec which must correspond to the pattern file being read in. See section 11.7 Importing Environments from Text Files.
WriteText(istreamm& strm, int pat_no=-1, TextFmt fmt = NAME_FIRST)
Writes an Environment to a text file in the format from the old PDP software. See section 11.7 Importing Environments from Text Files.