IntegratorMechanism

Overview

An IntegratorMechanism integrates its input, possibly based on its prior values. The input can be a single scalar value or an array of scalars (list or 1d np.array). If it is a list or array, then each value is independently integrated. The default function (Integrator) can be parametrized to implement either a simple increment rate, additive accumulator, or an (exponentially weighted) time-averaging of its input. It can also be assigned a custom function.

Creating an IntegratorMechanism

An IntegratorMechanism can be created directly by calling its constructor, or using the mechanism command and specifying INTEGRATOR_MECHANISM as its mech_spec argument. Its function is specified in the function argument, which can be parametrized by calling its constructor with parameter values:

>>> import psyneulink as pnl
>>> my_time_averaging_mechanism = pnl.IntegratorMechanism(function=pnl.AdaptiveIntegrator(rate=0.5))

The default_variable argument specifies the format of its input (i.e., whether it is a single scalar or an array), as well as the value to use if none is provided when Mechanism is executed. Alternatively, the size argument can be used to specify the length of the array, in which case it will be initialized with all zeros.

Structure

An IntegratorMechanism has a single InputState, the value of which is used as the variable for its function. The default for function is AdaptiveIntegrator(rate=0.5). However, a custom function can also be specified, so long as it takes a numeric value, or a list or np.ndarray of numeric values as its input, and returns a value of the same type and format. The Mechanism has a single OutputState, the value of which is assigned the result of the call to the Mechanism’s function.

Execution

When an IntegratorMechanism is executed, it carries out the specified integration, and assigns the result to the value of its primary OutputState. For the default function (Integrator), if the value specified for default_variable is a list or array, or size is greater than 1, each element of the array is independently integrated. If its rate parameter is a single value, that rate will be used for integrating each element. If the rate parameter is a list or array, then each element will be used as the rate for the corresponding element of the input (in this case, rate must be the same length as the value specified for default_variable or size).

Class Reference

class psyneulink.components.mechanisms.processing.integratormechanism.IntegratorMechanism(default_variable=None, size=None, function=AdaptiveIntegrator(rate=0.5), params=None, name=None, prefs=None)

Subclass of ProcessingMechanism that integrates its input.

Parameters:
  • default_variable (number, list or np.ndarray) – the input to the Mechanism to use if none is provided in a call to its execute or run methods; also serves as a template to specify the length of variable for function, and the primary outputState of the Mechanism.
  • size (int, list or np.ndarray of ints) –

    specifies default_variable as array(s) of zeros if default_variable is not passed as an argument; if default_variable is specified, it takes precedence over the specification of size. As an example, the following mechanisms are equivalent:

    T1 = TransferMechanism(size = [3, 2])
    T2 = TransferMechanism(default_variable = [[0, 0, 0], [0, 0]])
    
  • function (IntegratorFunction : default Integrator) – specifies the function used to integrate the input. Must take a single numeric value, or a list or np.array of values, and return one of the same form.
  • params (Dict[param keyword: param value] : default None) – a parameter dictionary that can be used to specify the parameters for the Mechanism, parameters for its function, and/or a custom function and its parameters. Values specified for parameters in the dictionary override any assigned to those parameters in arguments of the constructor.
  • name (str : default see name) – specifies the name of the IntegratorMechanism.
  • prefs (PreferenceSet or specification dict : default Mechanism.classPreferences) – specifies the PreferenceSet for the IntegratorMechanism; see prefs for details.
variable

value: default – the input to Mechanism’s function.

name

str – the name of the IntegratorMechanism; if it is not specified in the name argument of the constructor, a default is assigned by MechanismRegistry (see Naming for conventions used for default and duplicate names).

prefs

PreferenceSet or specification dict – the PreferenceSet for the IntegratorMechanism; if it is not specified in the prefs argument of the constructor, a default is assigned using classPreferences defined in __init__.py (see PreferenceSet for details).