• Github
Table of Contents
0.18.0.0+139
  • Welcome to PsyNeuLink
  • Basics and Primer
  • Quick Reference
  • Core
  • Library
  • Contributors Guide
  • Docs >
  • IntegratorFunctions
Shortcuts

IntegratorFunctions¶

Functions that integrate current value of input with previous value.

  • IntegratorFunction

  • AccumulatorIntegrator

  • SimpleIntegrator

  • AdaptiveIntegrator

  • DualAdaptiveIntegrator

  • DriftDiffusionIntegrator

  • DriftOnASphereIntegrator

  • OrnsteinUhlenbeckIntegrator

  • InteractiveActivationIntegrator

  • LeakyCompetingIntegrator

  • FitzHughNagumoIntegrator

class psyneulink.core.components.functions.stateful.integratorfunctions.SimpleIntegrator(default_variable=None, rate=None, noise=None, offset=None, initializer=None, params=None, owner=None, prefs=None)¶

Acculuates at a rate determined by its variable and rate; function returns:

\[previous\_value + rate * variable + noise + offset\]

Modulatory Parameters:

MULTIPLICATIVE_PARAM: rate
ADDITIVE_PARAM: offset

Parameters:
  • default_variable (number, list or array : default class_defaults.variable) – specifies a template for the value to be integrated; if it is a list or array, each element is independently integrated.

  • rate (float, list or 1d array : default 1.0) – specifies the rate of integration; if it is a list or array, it must be the same length as variable (see rate for details).

  • noise (float, function, list or 1d array : default 0.0) – specifies random value added to integral in each call to function; if it is a list or array, it must be the same length as variable (see noise for details).

  • offset (float, list or 1d array : default 0.0) – specifies constant value added to integral in each call to function; if it is a list or array, it must be the same length as variable (see offset for details).

  • initializer (float, list or 1d array : default 0.0) – specifies starting value(s) for integration; if it is a list or array, it must be the same length as variable (see initializer for details).

  • params (Dict[param keyword: param value] : default None) – a parameter dictionary that specifies the parameters for the function. Values specified for parameters in the dictionary override any assigned to those parameters in arguments of the constructor.

  • owner (Component) – component to which to assign the Function.

  • name (str : default see name) – specifies the name of the Function.

  • prefs (PreferenceSet or specification dict : default Function.classPreferences) – specifies the PreferenceSet for the Function (see prefs for details).

variable¶

current input value some portion of which (determined by rate) will be added to the prior value; if it is an array, each element is independently integrated.

Type:

number or array

rate¶

determines the rate of integration. If it is a float or has a single element, it is applied to all elements variable; if it has more than one element, each element is applied to the corresponding element of variable. Serves as MULTIPLICATIVE_PARAM for modulation of function.

Type:

float or 1d array

noise¶

random value added to integral in each call to function (see noise for details).

Type:

float, Function or 1d array

offset¶

constant value added to integral in each call to function. If variable is an array and offset is a float, offset is applied to each element of the integral; if offset is a list or array, each of its elements is applied to each of the corresponding elements of the integral (i.e., Hadamard addition). Serves as ADDITIVE_PARAM for modulation of function.

Type:

float or 1d array

initializer¶

determines the starting value(s) for integration (i.e., the value to which previous_value is set (see initializer for details).

Type:

float or 1d array

previous_value¶

stores previous value with which variable is integrated.

Type:

1d array : default class_defaults.variable

owner¶

component to which the Function has been assigned.

Type:

Component

name¶

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

Type:

str

prefs¶

the PreferenceSet for function; if it is not specified in the prefs argument of the Function’s constructor, a default is assigned using classPreferences defined in __init__.py (see Preferences for details).

Type:

PreferenceSet or specification dict : Function.classPreferences

_function(variable=None, context=None, params=None)¶
Parameters:
  • variable (number, list or array : default class_defaults.variable) – a single value or array of values to be integrated.

  • params (Dict[param keyword: param value] : default None) – a parameter dictionary that specifies the parameters for the function. Values specified for parameters in the dictionary override any assigned to those parameters in arguments of the constructor.

Returns:

  • updated value of integral (2d array)

class psyneulink.core.components.functions.stateful.integratorfunctions.AdaptiveIntegrator(default_variable=None, rate=None, noise=None, offset=None, initializer=None, params=None, owner=None, prefs=None)¶

function returns exponentially weighted moving average (EWMA) of input:

\[((1-rate) * previous\_value) + (rate * variable) + noise + offset\]

Modulatory Parameters:

MULTIPLICATIVE_PARAM: rate
ADDITIVE_PARAM: offset

Parameters:
  • default_variable (number, list or array : default class_defaults.variable) – specifies a template for the value to be integrated; if it is a list or array, each element is independently integrated.

  • rate (float, list or 1d array : default 1.0) – specifies the smoothing factor of the EWMA. If it is a list or array, it must be the same length as variable (see rate for details).

  • noise (float, function, list or 1d array : default 0.0) – specifies random value added to integral in each call to function; if it is a list or array, it must be the same length as variable (see noise for details).

  • offset (float, list or 1d array : default 0.0) – specifies constant value added to integral in each call to function; if it is a list or array, it must be the same length as variable (see offset for details).

  • initializer (float, list or 1d array : default 0.0) – specifies starting value(s) for integration. If it is a list or array, it must be the same length as variable (see initializer for details).

  • params (Dict[param keyword: param value] : default None) – a parameter dictionary that specifies the parameters for the function. Values specified for parameters in the dictionary override any assigned to those parameters in arguments of the constructor.

  • owner (Component) – component to which to assign the Function.

  • name (str : default see name) – specifies the name of the Function.

  • prefs (PreferenceSet or specification dict : default Function.classPreferences) – specifies the PreferenceSet for the Function (see prefs for details).

variable¶

current input value some portion of which (determined by rate) will be added to the prior value; if it is an array, each element is independently integrated.

Type:

number or array

rate¶

determines the smoothing factor of the EWMA. All rate elements must be between 0 and 1 (rate = 0 –> no change, variable is ignored; rate = 1 –> previous_value is ignored). If rate is a float or has a single element, its value is applied to all elements of variable and previous_value; if it is an array, each element is applied to the corresponding element of variable and previous_value). Serves as MULTIPLICATIVE_PARAM for modulation of function.

Type:

float or 1d array

noise¶

random value added to integral in each call to function (see noise for details).

Type:

float, Function or 1d array

offset¶

constant value added to integral in each call to function. If variable is a list or array and offset is a float, offset is applied to each element of the integral; if offset is a list or array, each of its elements is applied to each of the corresponding elements of the integral (i.e., Hadamard addition). Serves as ADDITIVE_PARAM for modulation of function.

Type:

float or 1d array

initializer¶

determines the starting value(s) for integration (i.e., the value(s) to which previous_value is set (see initializer for details).

Type:

float or 1d array

previous_value¶

stores previous value with which variable is integrated.

Type:

1d array : default class_defaults.variable

owner¶

component to which the Function has been assigned.

Type:

Component

name¶

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

Type:

str

prefs¶

the PreferenceSet for function; if it is not specified in the prefs argument of the Function’s constructor, a default is assigned using classPreferences defined in __init__.py (see Preferences for details).

Type:

PreferenceSet or specification dict : Function.classPreferences

_validate_params(request_set, target_set=None, context=None)¶

Check inner dimension (length) of all parameters used for the function

Insure that for any parameters that are in the Parameters class, designated as function_arg, and

specified by the user with length>1: 1) they all have the same length; 2) if default_variable:

  • was specified by the user, the parameters all have the same length as that

  • was NOT specified by the user, they all have the same length as each other; in this case, default_variable will be set to the length of those parameters in _instantiate_attributes_before_function below

_function(variable=None, context=None, params=None)¶
Parameters:
  • variable (number, list or array : default class_defaults.variable) – a single value or array of values to be integrated.

  • params (Dict[param keyword: param value] : default None) – a parameter dictionary that specifies the parameters for the function. Values specified for parameters in the dictionary override any assigned to those parameters in arguments of the constructor.

Returns:

  • updated value of integral (ndarray (dimension equal to variable))

class psyneulink.core.components.functions.stateful.integratorfunctions.DriftDiffusionIntegrator(default_variable=None, rate=None, noise=None, offset=None, starting_value=None, non_decision_time=None, threshold=None, time_step_size=None, seed=None, params=None, owner=None, prefs=None, **kwargs)¶

Accumulate “evidence” to a bound. function returns one time step of integration:

\[previous\_value + rate \cdot variable \cdot time\_step\_size + \mathcal{N}(\sigma^2)\]

where

\[\sigma^2 =\sqrt{time\_step\_size \cdot noise}\]

Modulatory Parameters:

MULTIPLICATIVE_PARAM: rate
ADDITIVE_PARAM: offset

Parameters:
  • default_variable (number, list or array : default class_defaults.variable) – specifies the stimulus component of drift rate – the drift rate is the product of variable and rate

  • rate (float, list or 1d array : default 1.0) – applied multiplicatively to variable; If it is a list or array, it must be the same length as variable (see rate for details).

  • noise (float : default 0.0) – specifies a value by which to scale the normally distributed random value added to the integral in each call to function (see noise for details).

  • offset (float, list or 1d array : default 0.0) – specifies constant value added to integral in each call to function if it’s absolute value is below threshold; if it is a list or array, it must be the same length as variable (see offset for details).

  • starting_value (float, list or 1d array: default 0.0) – specifies the starting value for the integration process; if it is a list or array, it must be the same length as variable (see starting_value for details).

  • threshold (float : default 0.0) – specifies the threshold (boundaries) of the drift diffusion process – i.e., at which the integration process terminates (see threshold for details).

  • time_step_size (float : default 0.0) – specifies the timing precision of the integration process (see time_step_size for details.

  • initializer (float, list or 1d array : default 0.0) – specifies starting value(s) for integration. If it is a list or array, it must be the same length as variable (see initializer for details).

  • params (Dict[param keyword: param value] : default None) – a parameter dictionary that specifies the parameters for the function. Values specified for parameters in the dictionary override any assigned to those parameters in arguments of the constructor.

  • owner (Component) – component to which to assign the Function.

  • name (str : default see name) – specifies the name of the Function.

  • prefs (PreferenceSet or specification dict : default Function.classPreferences) – specifies the PreferenceSet for the Function (see prefs for details).

variable¶

current input value (can be thought of as implementing the stimulus component of the drift rate); if it is an array, each element represents an independently integrated decision variable.

Type:

float or array

rate¶

applied multiplicatively to variable (can be thought of as implementing the attentional component of the drift rate). If it is a float or has a single element, its value is applied to all the elements of variable; if it is an array, each element is applied to the corresponding element of variable. Serves as MULTIPLICATIVE_PARAM for modulation of function.

Type:

float or 1d array

random_state¶

private pseudorandom number generator

Type:

numpy.RandomState

noise¶

scales the normally distributed random value added to integral in each call to function. If variable is a list or array, and noise is a float, a single random term is generated and applied for each element of variable. If noise is a list or array, it must be the same length as variable, and a separate random term scaled by noise is applied for each of the corresponding elements of variable.

Type:

float or 1d array

offset¶

constant value added to integral in each call to function if it’s absolute value is below threshold. If variable is an array and offset is a float, offset is applied to each element of the integral; if offset is a list or array, each of its elements is applied to each of the corresponding elements of the integral (i.e., Hadamard addition). Serves as ADDITIVE_PARAM for modulation of function.

Type:

float or 1d array

starting_value¶

determines the starting value for the integration process; if it is a list or array, it must be the same length as variable. If variable is an array and starting_value is a float, starting_value is used for each element of the integral; if starting_value is a list or array, each of its elements is used as the starting point for each element of the integral.

Type:

float or 1d array

non_decision_time¶

specifies the starting time of the model and is used to compute previous_time

Type:

float : default 0.0

threshold¶

determines the boundaries of the drift diffusion process: the integration process can be scheduled to terminate when the result of function equals or exceeds either the positive or negative value of threshold (see hint). NOTE: Vector version of this parameter acts as a saturation barrier. While it is possible to subtract from value == threshold, any movement in the threshold direction will be capped at the threshold value.

Hint

To terminate execution of the Mechanism to which the function is assigned, a WhenFinished Condition should be assigned for that Mechanism to scheduler of the Composition to which the Mechanism belongs.

Type:

float

time_step_size¶

determines the timing precision of the integration process and is used to scale the noise parameter according to the standard DDM probability distribution.

Type:

float

initializer¶

determines the starting value(s) for integration (i.e., the value(s) to which previous_value is set (see initializer for details).

Type:

float or 1d array

previous_time¶

stores previous time at which the function was executed and accumulates with each execution according to time_step_size.

Type:

float

previous_value¶

stores previous value with which variable is integrated.

Type:

1d array : default class_defaults.variable

owner¶

component to which the Function has been assigned.

Type:

Component

name¶

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

Type:

str

prefs¶

the PreferenceSet for function; if it is not specified in the prefs argument of the Function’s constructor, a default is assigned using classPreferences defined in __init__.py (see Preferences for details).

Type:

PreferenceSet or specification dict : Function.classPreferences

_function(variable=None, context=None, params=None)¶
Parameters:
  • variable (number, list or array : default class_defaults.variable) – a single value or array of values to be integrated (can be thought of as the stimulus component of the drift rate).

  • params (Dict[param keyword: param value] : default None) – a parameter dictionary that specifies the parameters for the function. Values specified for parameters in the dictionary override any assigned to those parameters in arguments of the constructor.

Returns:

  • updated value of integral (2d array)

reset(previous_value=None, previous_time=None, context=None)¶

Resets value and previous_value to the specified value(s).

If arguments are passed into the reset method, then reset sets each of the attributes in stateful_attributes to the value of the corresponding argument. Next, it sets the value to a list containing each of the argument values.

If reset is called without arguments, then it sets each of the attributes in stateful_attributes to the value of the corresponding attribute in initializers. Next, it sets the value to a list containing the values of each of the attributes in initializers.

Often, the only attribute in stateful_attributes is previous_value and the only attribute in initializers is initializer, in which case the reset method sets previous_value and value to either the value of the argument (if an argument was passed into reset) or the current value of initializer.

For specific types of StatefulFunction functions, the reset method may carry out other reinitialization steps.

_assign_to_mdf_model(model, input_id)¶

Adds an MDF representation of this function to MDF object model, including all necessary auxiliary functions. input_id is the input to the singular MDF function or first function representing this psyneulink Function, if applicable.

Returns:

the identifier of the final MDF function representing this psyneulink Function

Return type:

str

class psyneulink.core.components.functions.stateful.integratorfunctions.DriftOnASphereIntegrator(default_variable=None, rate=1.0, noise=0.0, offset=0.0, time_step_size=1.0, initializer=None, dimension=3, seed=None, params=None, owner=None, prefs=None)¶

Integrate a state evolving on the unit sphere \(S^{dimension-1}\) embedded in \(\mathbb{R}^{dimension}\). The value stored in previous_value is always a unit vector, and updates occur by applying drift and noise in the tangent space and mapping back to the sphere using the exponential map. This yields the correct form of geometric Brownian motion on a sphere.

Drift Input
  • If variable is a scalar, drift is applied along a persistent tangent direction that is parallel transported at each step.

  • If it is a vector of length (dimension - 1), it is interpreted as a tangent-space displacement.

    The magnitude of the vector corresponds to an angular rotation (in radians) along the sphere.

  • If it is a vector (length = dimension), it is a target on the sphere to in.

    The magnitude is ignored and the vector is projected onto the sphere.

Rate

The rate parameter controls the amount of angular movement per unit time:

  • In scalar drift mode, rate scales the angular velocity along the persistent drift direction.

  • In tangent mode, the norm of the input vector encodes an angular displacement (in radians), and rate scales this angular step size.

  • In target mode, the drift direction is the geodesic pointing toward the target; rate specifies the fraction of the remaining geodesic distance traveled per time step. Thus, with rate = 1.0 and time_step_size = 1.0, the system reaches the target in exactly one step. Values 0 < rate < 1 move only partway toward the target.

Initializer
  • A 1D array of length dimension is interpreted as a Cartesian point (normalized to unit length).

  • A 1D array of length dimension - 1 is interpreted as hyperspherical coordinates.

Noise
  • A scalar specifies isotropic diffusion on the sphere.

  • A 1D array of length dimension - 1 specifies anisotropic diffusion in tangent coordinates.

Mathematical Form .. math:

y = dt \cdot \text{drift\_tangent} \;+\; \sqrt{dt} \cdot \text{noise\_tangent}
\\
x_{t+dt} = \exp_{x}(y)

where \(\exp_{x}\) is the exponential map on the unit sphere and all drift/noise terms are orthogonally projected into the tangent space \(T_{x}S^{d-1}\) at the current state \(x\).

—

Modulatory Parameters

MULTIPLICATIVE_PARAM: rate
ADDITIVE_PARAM: offset

—

Parameters:
  • default_variable (float or 1d array : default class_defaults.variable) – Template for input to the integrator. If a vector, its length must equal dimension - 1.

  • rate (float or 1d array : default 1.0) – Multiplies the drift input (see rate).

  • noise (float or 1d array : default 0.0) – Scales random diffusion. A float applies isotropically; an array must be length dimension - 1.

  • offset (float or 1d array : default 0.0) – Additive drift term (projected into tangent space).

  • time_step_size (float : default 1.0) – Integration time step \(dt\).

  • initializer (1d array or None) – Starting point on the sphere; either Cartesian of length dimension or hyperspherical of length dimension-1.

  • dimension (int : default 3) – Ambient dimension of the embedding space \(\mathbb{R}^{dimension}\).

  • seed (int : default None) – Seeds the internal random number generator.

  • params (Dict[param keyword : param value] : default None) – Parameter dictionary.

  • owner (Component) – Component to which this Function is assigned.

  • prefs (PreferenceSet or specification dict) – Preference settings.

previous_value¶

Current point on the sphere.

Type:

1d array

drift_dir¶

The persistent drift direction used for scalar drift inputs, transported along the sphere.

Type:

1d array

random_state¶

Private pseudorandom number generator.

Type:

numpy.RandomState

static _proj_tangent(x, v)¶

Project v into the tangent space at x.

static _expmap_sphere(x, y)¶

Exponential map at point x with tangent vector y.

static _parallel_transport_exact(x, y, v)¶

Parallel transport tangent vector v along geodesic exp_x(y).

static _tangent_basis(x)¶

Return orthonormal basis of tangent space at x (matrix shape: [dimension, dimension-1]). Uses a Householder reflection to align x with e_0.

static _hyperspherical_to_cartesian(theta)¶

Convert hyperspherical angle vector of length d-1 to a unit Cartesian vector in R^d.

static _logmap_sphere(x, t)¶

Return tangent vector y at x such that exp_x(y)=t (shortest geodesic).

_instantiate_attributes_before_function(function=None, context=None)¶

Insure inner dimension of default_variable matches the length of any parameters that have len>1

_function(variable=None, context=None, params=None)¶

Compute one integration step on the unit sphere.

The state evolves from the current position \(x\) by computing a drift term and a diffusion term in the tangent space \(T_x S^{dimension-1}\), then mapping the result back to the sphere using the exponential map.

Parameters:
  • variable (float or 1d array) – Drift input. If a scalar is provided, it scales the persistent tangent drift direction (drift_dir). If a 1d array of length dimension is provided, it is projected into the tangent space and used directly as the drift direction.

  • params (Dict[param keyword: param value]) – Parameter override dictionary. Values in params temporarily replace current parameter values for this call only.

Returns:

The updated position on the sphere \(S^{dimension-1}\). The returned vector is guaranteed to have unit norm.

Return type:

1d array

reset(*args, context=None, **kwargs)¶

Reset previous_value to initializer and return reset state consistent with PNL integrator reset protocol.

class psyneulink.core.components.functions.stateful.integratorfunctions.OrnsteinUhlenbeckIntegrator(default_variable=None, rate=None, decay=None, noise=None, offset=None, non_decision_time=None, time_step_size=None, starting_value=None, params=None, seed=None, owner=None, prefs=None, **kwargs)¶

function returns one time step of integration according to an Ornstein Uhlenbeck process:

\[previous\_value + (decay \cdot previous\_value) - (rate \cdot variable) + \mathcal{N}(\sigma^2)\]

where

\[\sigma^2 =\sqrt{time\_step\_size \cdot noise}\]

Modulatory Parameters:

MULTIPLICATIVE_PARAM: rate
ADDITIVE_PARAM: offset

Parameters:
  • default_variable (number, list or array : default class_defaults.variable) – specifies a template for the stimulus component of drift rate – the drift rate is the product of variable and rate

  • rate (float, list or 1d array : default 1.0) – specifies value applied multiplicatively to variable; If it is a list or array, it must be the same length as variable (see rate for details).

  • decay (float, list or 1d array : default 1.0) – specifies value applied multiplicatively to previous_value; If it is a list or array, it must be the same length as variable ( see decay for details).

  • noise (float : default 0.0) – specifies a value by which to scale the normally distributed random value added to the integral in each call to function (see noise for details).

  • offset (float, list or 1d array : default 0.0) – specifies a constant value added to integral in each call to function; if it is a list or array, it must be the same length as variable (see offset for details)

  • non_decision_time (float : default 0.0) – specifies the starting time of the model and is used to compute previous_time

  • time_step_size (float : default 0.0) – determines the timing precision of the integration process (see time_step_size for details.

  • initializer (float, list or 1d array : default 0.0) – specifies starting value(s) for integration. If it is a list or array, it must be the same length as variable (see initializer for details).

  • params (Dict[param keyword: param value] : default None) – a parameter dictionary that specifies the parameters for the function. Values specified for parameters in the dictionary override any assigned to those parameters in arguments of the constructor.

  • owner (Component) – component to which to assign the Function.

  • name (str : default see name) – specifies the name of the Function.

  • prefs (PreferenceSet or specification dict : default Function.classPreferences) – specifies the PreferenceSet for the Function (see prefs for details).

variable¶

represents the stimulus component of drift. The product of variable and rate is multiplied by time_step_size to model the accumulation of evidence during one step.

Type:

number or array

rate¶

applied multiplicatively to variable. If it is a float or has a single element, its value is applied to all the elements of variable; if it is an array, each element is applied to the corresponding element of variable. Serves as MULTIPLICATIVE_PARAM for modulation of function.

Type:

float or 1d array

decay¶

applied multiplicatively to previous_value; If it is a float or has a single element, its value is applied to all the elements of previous_value; if it is an array, each element is applied to the corresponding element of previous_value.

Type:

float or 1d array

noise¶

scales the normally distributed random value added to integral in each call to function. A single random term is generated each execution, and applied to all elements of variable if that is an array with more than one element.

Type:

float

offset¶

constant value added to integral in each call to function. If variable is an array and offset is a float, offset is applied to each element of the integral; if offset is a list or array, each of its elements is applied to each of the corresponding elements of the integral (i.e., Hadamard addition). Serves as ADDITIVE_PARAM for modulation of function.

Type:

float or 1d array

non_decision_time¶

determines the start time of the integration process.

Type:

float

time_step_size¶

determines the timing precision of the integration process and is used to scale the noise parameter appropriately.

Type:

float

initializer¶

determines the starting value(s) for integration (i.e., the value(s) to which previous_value is set (see initializer for details).

Type:

float or 1d array

previous_value¶

stores previous value with which variable is integrated.

Type:

1d array : default class_defaults.variable

previous_time¶

stores previous time at which the function was executed and accumulates with each execution according to time_step_size.

Type:

float

random_state¶

private pseudorandom number generator

Type:

numpy.RandomState

owner¶

component to which the Function has been assigned.

Type:

Component

name¶

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

Type:

str

prefs¶

the PreferenceSet for function; if it is not specified in the prefs argument of the Function’s constructor, a default is assigned using classPreferences defined in __init__.py (see Preferences for details).

Type:

PreferenceSet or specification dict : Function.classPreferences

_function(variable=None, context=None, params=None)¶
Parameters:
  • variable (number, list or array : default class_defaults.variable) – a single value or array of values to be integrated.

  • params (Dict[param keyword: param value] : default None) – a parameter dictionary that specifies the parameters for the function. Values specified for parameters in the dictionary override any assigned to those parameters in arguments of the constructor.

Returns:

  • updated value of integral (2d array)

reset(previous_value=None, previous_time=None, context=None)¶

Resets value and previous_value to the specified value(s).

If arguments are passed into the reset method, then reset sets each of the attributes in stateful_attributes to the value of the corresponding argument. Next, it sets the value to a list containing each of the argument values.

If reset is called without arguments, then it sets each of the attributes in stateful_attributes to the value of the corresponding attribute in initializers. Next, it sets the value to a list containing the values of each of the attributes in initializers.

Often, the only attribute in stateful_attributes is previous_value and the only attribute in initializers is initializer, in which case the reset method sets previous_value and value to either the value of the argument (if an argument was passed into reset) or the current value of initializer.

For specific types of StatefulFunction functions, the reset method may carry out other reinitialization steps.

class psyneulink.core.components.functions.stateful.integratorfunctions.FitzHughNagumoIntegrator(default_variable=None, initial_w=None, initial_v=None, a_v=None, b_v=None, c_v=None, d_v=None, e_v=None, f_v=None, time_constant_v=None, a_w=None, b_w=None, c_w=None, time_constant_w=None, t_0=None, threshold=None, time_step_size=None, mode=None, uncorrelated_activity=None, integration_method=None, params=None, owner=None, prefs=None, **kwargs)¶

function returns one time step of integration of the Fitzhugh-Nagumo model of an excitable oscillator:

\[time\_constant_v \frac{dv}{dt} = a_v * v^3 + (1 + threshold) * b_v * v^2 + (- threshold) * c_v * v^2 + d_v + e_v * w + f_v * I_{ext}\]

where

\[time\_constant_w * \frac{dw}{dt} =` mode * a_w * v + b_w * w +c_w + (1 - mode) * uncorrelated\_activity\]

Either Euler or Dormand–Prince (4th Order Runge-Kutta) methods of numerical integration can be used.

The FitzHughNagumoIntegrator implements all of the parameters of the FitzHughNagumo model; however, not all combinations of these are sensible. Typically, they are combined into two sets. These are described below, followed by a describption of how they are used to implement three common variants of the model with the FitzHughNagumoIntegrator.

Parameter Sets¶

Fast, Excitatory Variable:

\[\frac{dv}{dt} = \frac{a_v v^{3} + b_v v^{2} (1+threshold) - c_v v\, threshold + d_v + e_v\, previous_w + f_v\, variable)}{time\, constant_v}\]

Slow, Inactivating Variable:

\[\frac{dw}{dt} = \frac{a_w\, mode\, previous_v + b_w w + c_w + uncorrelated\,activity\,(1-mode)}{time\, constant_w}\]

Three Common Variants¶

  1. Fitzhugh-Nagumo Model

    Fast, Excitatory Variable:

    \[\frac{dv}{dt} = v - \frac{v^3}{3} - w + I_{ext}\]

    Slow, Inactivating Variable:

    \[\frac{dw}{dt} = \frac{v + a - bw}{T}\]

    \(\frac{dw}{dt}\) often has the following parameter values:

    \[\frac{dw}{dt} = 0.08\,(v + 0.7 - 0.8 w)\]

    Implementation in FitzHughNagumoIntegrator

    The default values implement the above equations.

  2. Modified FitzHughNagumo Model

    Fast, Excitatory Variable:

    \[\frac{dv}{dt} = v(a-v)(v-1) - w + I_{ext}\]

    Slow, Inactivating Variable:

    \[\frac{dw}{dt} = bv - cw\]

    Mahbub Khan (2013) provides a nice summary of why this formulation is useful.

    Implementation in FitzHughNagumoIntegrator

    The following parameter values must be specified in the equation for \(\frac{dv}{dt}\):

    FitzHughNagumoIntegrator Parameter

    a_v

    b_v

    c_v

    d_v

    e_v

    f_v

    time_constant_v

    Value

    -1.0

    1.0

    1.0

    0.0

    -1.0

    1.0

    1.0

    When the parameters above are set to the listed values, the FitzHughNagumoIntegrator equation for \(\frac{dv}{dt}\) reduces to the Modified FitzHughNagumo formulation, and the remaining parameters in the \(\frac{dv}{dt}\) equation correspond as follows:

    FitzHughNagumoIntegrator Parameter

    threshold

    variable

    Modified FitzHughNagumo Parameter

    a

    \(I_{ext}\)

    The following parameter values must be set in the equation for \(\frac{dw}{dt}\):

    FitzHughNagumoIntegrator Parameter

    c_w

    mode

    time_constant_w

    uncorrelated_activity

    Value

    0.0

    1.0

    1.0

    0.0

    When the parameters above are set to the listed values, the FitzHughNagumoIntegrator equation for \(\frac{dw}{dt}\) reduces to the Modified FitzHughNagumo formulation, and the remaining parameters in the \(\frac{dw}{dt}\) equation correspond as follows:

    FitzHughNagumoIntegrator Parameter

    a_w

    NEGATIVE b_w

    Modified FitzHughNagumo Parameter

    b

    c

  3. Modified FitzHughNagumo Model as implemented in Gilzenrat (2002)

    Fast, Excitatory Variable:

    [Eq. (6) in Gilzenrat (2002) ]

    \[\tau_v \frac{dv}{dt} = v(a-v)(v-1) - u + w_{vX_1}\, f(X_1)\]

    Slow, Inactivating Variable:

    [Eq. (7) & Eq. (8) in Gilzenrat (2002) ]

    \[\tau_u \frac{du}{dt} = Cv + (1-C)\, d - u\]

    Implementation in FitzHughNagumoIntegrator

    The following FitzHughNagumoIntegrator parameter values must be set in the equation for \(\frac{dv}{dt}\):

    FitzHughNagumoIntegrator Parameter

    a_v

    b_v

    c_v

    d_v

    e_v

    Value

    -1.0

    1.0

    1.0

    0.0

    -1.0

    When the parameters above are set to the listed values, the FitzHughNagumoIntegrator equation for \(\frac{dv}{dt}\) reduces to the Gilzenrat formulation, and the remaining parameters in the \(\frac{dv}{dt}\) equation correspond as follows:

    FitzHughNagumoIntegrator Parameter

    threshold

    variable

    f_v

    Gilzenrat Parameter

    a

    \(f(X_1)\)

    \(w_{vX_1}\) | \(T_{v}\)

    The following FitzHughNagumoIntegrator parameter values must be set in the equation for \(\frac{dw}{dt}\):

    FitzHughNagumoIntegrator Parameter

    a_w

    b_w

    c_w

    Value

    1.0

    -1.0

    0.0

    When the parameters above are set to the listed values, the FitzHughNagumoIntegrator equation for \(\frac{dw}{dt}\) reduces to the Gilzenrat formulation, and the remaining parameters in the \(\frac{dw}{dt}\) equation correspond as follows:

    FitzHughNagumoIntegrator Parameter

    mode

    uncorrelated_activity

    time_constant_v

    Gilzenrat Parameter

    C

    d

    \(T_{u}\)

type default_variable:

number, list or array : default class_defaults.variable

param default_variable:

specifies a template for the external stimulus

type default_variable:

number, list or array : default class_defaults.variable

type initial_w:

float, list or 1d array : default 0.0

param initial_w:

specifies starting value for integration of dw/dt. If it is a list or array, it must be the same length as variable.

type initial_w:

float, list or 1d array : default 0.0

type initial_v:

float, list or 1d array : default 0.0

param initial_v:

specifies starting value for integration of dv/dt. If it is a list or array, it must be the same length as variable

type initial_v:

float, list or 1d array : default 0.0

type time_step_size:

float : default 0.1

param time_step_size:

specifies the time step size of numerical integration

type time_step_size:

float : default 0.1

type t_0:

float : default 0.0

param t_0:

specifies starting value for time

type t_0:

float : default 0.0

type a_v:

float : default -1/3

param a_v:

coefficient on the v^3 term of the dv/dt equation

type a_v:

float : default -1/3

type b_v:

float : default 0.0

param b_v:

coefficient on the v^2 term of the dv/dt equation

type b_v:

float : default 0.0

type c_v:

float : default 1.0

param c_v:

coefficient on the v term of the dv/dt equation

type c_v:

float : default 1.0

type d_v:

float : default 0.0

param d_v:

constant term in the dv/dt equation

type d_v:

float : default 0.0

type e_v:

float : default -1.0

param e_v:

coefficient on the w term in the dv/dt equation

type e_v:

float : default -1.0

type f_v:

float : default 1.0

param f_v:

coefficient on the external stimulus (variable) term in the dv/dt equation

type f_v:

float : default 1.0

type time_constant_v:

float : default 1.0

param time_constant_v:

scaling factor on the dv/dt equation

type time_constant_v:

float : default 1.0

type a_w:

float : default 1.0,

param a_w:

coefficient on the v term of the dw/dt equation

type a_w:

float : default 1.0,

type b_w:

float : default -0.8,

param b_w:

coefficient on the w term of the dv/dt equation

type b_w:

float : default -0.8,

type c_w:

float : default 0.7,

param c_w:

constant term in the dw/dt equation

type c_w:

float : default 0.7,

type threshold:

float : default -1.0

param threshold:

specifies a value of the input below which the LC will tend not to respond and above which it will

type threshold:

float : default -1.0

type mode:

float : default 1.0

param mode:

coefficient which simulates electrotonic coupling by scaling the values of dw/dt such that the v term (representing the input from the LC) increases when the uncorrelated_activity term (representing baseline activity) decreases

type mode:

float : default 1.0

type uncorrelated_activity:

float : default 0.0

param uncorrelated_activity:

constant term in the dw/dt equation

type uncorrelated_activity:

float : default 0.0

type time_constant_w:

float : default 12.5

param time_constant_w:

scaling factor on the dv/dt equation

type time_constant_w:

float : default 12.5

type integration_method:

str : default “RK4”

param integration_method:

selects the numerical integration method. Currently, the choices are: “RK4” (4th Order Runge-Kutta) or “EULER” (Forward Euler)

type integration_method:

str : default “RK4”

type params:

Optional[Mapping]

param params:

a parameter dictionary that specifies the parameters for the function. Values specified for parameters in the dictionary override any assigned to those parameters in arguments of the constructor.

type params:

Dict[param keyword: param value] : default None

type owner:

Component

param owner:

component to which to assign the Function.

type owner:

Component

param name:

specifies the name of the Function.

type name:

str : default see name

type prefs:

Union[None, BasePreferenceSet, dict[Literal['_report_output_pref', '_log_pref', '_delivery_pref', '_param_validation_pref', '_verbose_pref', '_runtime_param_modulation_pref'], Any]]

param prefs:

specifies the PreferenceSet for the Function (see prefs for details).

type prefs:

PreferenceSet or specification dict : default Function.classPreferences

variable¶

External stimulus

Type:

number or array

previous_v¶

stores accumulated value of v during integration

Type:

1d array : default class_defaults.variable

previous_w¶

stores accumulated value of w during integration

Type:

1d array : default class_defaults.variable

previous_t¶

stores accumulated value of time, which is incremented by time_step_size on each execution of the function

Type:

float

owner¶

component to which the Function has been assigned.

Type:

Component

initial_w¶

specifies starting value for integration of dw/dt. If it is a list or array, it must be the same length as variable

Type:

float, list or 1d array : default 0.0

initial_v¶

specifies starting value for integration of dv/dt. If it is a list or array, it must be the same length as variable

Type:

float, list or 1d array : default 0.0

time_step_size¶

specifies the time step size of numerical integration

Type:

float : default 0.1

t_0¶

specifies starting value for time

Type:

float : default 0.0

a_v¶

coefficient on the v^3 term of the dv/dt equation

Type:

float : default -1/3

b_v¶

coefficient on the v^2 term of the dv/dt equation

Type:

float : default 0.0

c_v¶

coefficient on the v term of the dv/dt equation

Type:

float : default 1.0

d_v¶

constant term in the dv/dt equation

Type:

float : default 0.0

e_v¶

coefficient on the w term in the dv/dt equation

Type:

float : default -1.0

f_v¶

coefficient on the external stimulus (variable) term in the dv/dt equation

Type:

float : default 1.0

time_constant_v¶

scaling factor on the dv/dt equation

Type:

float : default 1.0

a_w¶

coefficient on the v term of the dw/dt equation

Type:

float : default 1.0

b_w¶

coefficient on the w term of the dv/dt equation

Type:

float : default -0.8

c_w¶

constant term in the dw/dt equation

Type:

float : default 0.7

threshold¶

coefficient that scales both the v^2 [ (1+threshold)*v^2 ] and v [ (-threshold)*v ] terms in the dv/dt equation under a specific formulation of the FitzHughNagumo equations, the threshold parameter behaves as a “threshold of excitation”, and has the following relationship with variable (the external stimulus):

  • when the external stimulus is below the threshold of excitation, the system is either in a stable state, or will emit a single excitation spike, then reach a stable state. The behavior varies depending on the magnitude of the difference between the threshold and the stimulus.

  • when the external stimulus is equal to or above the threshold of excitation, the system is unstable, and will emit many excitation spikes

  • when the external stimulus is too far above the threshold of excitation, the system will emit some excitation spikes before reaching a stable state.

Type:

float : default -1.0

mode¶

coefficient which simulates electrotonic coupling by scaling the values of dw/dt such that the v term (representing the input from the LC) increases when the uncorrelated_activity term (representing baseline activity) decreases

Type:

float : default 1.0

uncorrelated_activity¶

constant term in the dw/dt equation

Type:

float : default 0.0

time_constant_w¶

scaling factor on the dv/dt equation

Type:

float : default 12.5

prefs¶

the PreferenceSet for the Function (see prefs for details).

Type:

PreferenceSet or specification dict : default Function.classPreferences

_validate_params(request_set, target_set=None, context=None)¶

Check inner dimension (length) of all parameters used for the function

Insure that for any parameters that are in the Parameters class, designated as function_arg, and

specified by the user with length>1: 1) they all have the same length; 2) if default_variable:

  • was specified by the user, the parameters all have the same length as that

  • was NOT specified by the user, they all have the same length as each other; in this case, default_variable will be set to the length of those parameters in _instantiate_attributes_before_function below

_function(variable=None, context=None, params=None)¶
Parameters:

params (Dict[param keyword: param value] : default None) – a parameter dictionary that specifies the parameters for the function. Values specified for parameters in the dictionary override any assigned to those parameters in arguments of the constructor.

Return type:

(ndarray, ndarray, ndarray)

Returns:

  • current value of v , current value of w, current time_step of integration (ndarray)

reset(previous_v=None, previous_w=None, previous_time=None, context=None)¶

Resets value and previous_value to the specified value(s).

If arguments are passed into the reset method, then reset sets each of the attributes in stateful_attributes to the value of the corresponding argument. Next, it sets the value to a list containing each of the argument values.

If reset is called without arguments, then it sets each of the attributes in stateful_attributes to the value of the corresponding attribute in initializers. Next, it sets the value to a list containing the values of each of the attributes in initializers.

Often, the only attribute in stateful_attributes is previous_value and the only attribute in initializers is initializer, in which case the reset method sets previous_value and value to either the value of the argument (if an argument was passed into reset) or the current value of initializer.

For specific types of StatefulFunction functions, the reset method may carry out other reinitialization steps.

_assign_to_mdf_model(model, input_id)¶

Adds an MDF representation of this function to MDF object model, including all necessary auxiliary functions. input_id is the input to the singular MDF function or first function representing this psyneulink Function, if applicable.

Returns:

the identifier of the final MDF function representing this psyneulink Function

Return type:

str

class psyneulink.core.components.functions.stateful.integratorfunctions.AccumulatorIntegrator(default_variable=None, rate=None, increment=None, noise=None, initializer=None, params=None, owner=None, prefs=None)¶

Accumulates at a constant rate, that is either linear or exponential, depending on rate; function ignores variable and returns:

\[previous\_value \cdot rate + increment + noise\]

so that, with each call to function, the accumulated value increases by:

\[increment \cdot rate^{time\_step}.\]

Thus, accumulation increases lineary in steps of increment if rate=1.0, and exponentially otherwise.

Modulatory Parameters:

MULTIPLICATIVE_PARAM: rate
ADDITIVE_PARAM: increment

Parameters:
  • default_variable (number, list or array : default class_defaults.variable) – specifies a template for the value to be integrated; if it is a list or array, each element is independently integrated.

  • rate (float, list or 1d array : default 1.0) – specifies the rate of decay; if it is a list or array, it must be the same length as variable (see rate for additional details.

  • increment (float, list or 1d array : default 0.0) – specifies an amount to be added to previous_value in each call to function; if it is a list or array, it must be the same length as variable (see increment for details).

  • noise (float, Function, list or 1d array : default 0.0) – specifies random value added to prevous_value in each call to function; if it is a list or array, it must be the same length as variable (see noise for additional details).

  • initializer (float, list or 1d array : default 0.0) – specifies starting value(s) for integration. If it is a list or array, it must be the same length as variable (see initializer for details).

  • params (Dict[param keyword: param value] : default None) – a parameter dictionary that specifies the parameters for the function. Values specified for parameters in the dictionary override any assigned to those parameters in arguments of the constructor.

  • owner (Component) – component to which to assign the Function.

  • name (str : default see name) – specifies the name of the Function.

  • prefs (PreferenceSet or specification dict : default Function.classPreferences) – specifies the PreferenceSet for the Function (see prefs for details).

variable¶

Ignored by the AccumulatorIntegrator function. Use LeakyCompetingIntegrator or AdaptiveIntegrator for integrator functions that depend on both a prior value and a new value (variable).

Type:

number or array

rate¶

determines the rate of exponential decay of previous_value in each call to function. If it is a float or has a single element, its value is applied to all the elements of previous_value; if it is an array, each element is applied to the corresponding element of previous_value. Serves as MULTIPLICATIVE_PARAM for modulation of function.

Type:

float or 1d array

increment¶

determines the amount added to previous_value in each call to function. If it is a list or array, it must be the same length as variable and each element is added to the corresponding element of previous_value (i.e., it is used for Hadamard addition). If it is a scalar or has a single element, its value is added to all the elements of previous_value. Serves as ADDITIVE_PARAM for modulation of function.

Type:

float, function, or 1d array

noise¶

random value added in each call to function (see noise for details).

Type:

float, Function or 1d array

initializer¶

determines the starting value(s) for integration (i.e., the value(s) to which previous_value is set (see initializer for details).

Type:

float or 1d array

previous_value¶

stores previous value to which rate and noise will be added.

Type:

1d array : default class_defaults.variable

owner¶

component to which the Function has been assigned.

Type:

Component

name¶

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

Type:

str

prefs¶

the PreferenceSet for function; if it is not specified in the prefs argument of the Function’s constructor, a default is assigned using classPreferences defined in __init__.py (see Preferences for details).

Type:

PreferenceSet or specification dict : Function.classPreferences

_accumulator_check_args(variable=None, context=None, params=None, target_set=None)¶

validate params and assign any runtime params.

Called by AccumulatorIntegrator to validate params Validation can be suppressed by turning parameter_validation attribute off target_set is a params dictionary to which params should be assigned;

Does the following: - assign runtime params to context - validate params if PARAM_VALIDATION is set

Parameters:

params – (dict) - params to validate

Target_set:

(dict) - set to which params should be assigned

Returns:

_function(variable=None, context=None, params=None)¶
Parameters:

params (Dict[param keyword: param value] : default None) – a parameter dictionary that specifies the parameters for the function. Values specified for parameters in the dictionary override any assigned to those parameters in arguments of the constructor.

Returns:

  • updated value of integral (2d array)

class psyneulink.core.components.functions.stateful.integratorfunctions.LeakyCompetingIntegrator(default_variable=None, leak=None, noise=None, offset=None, time_step_size=None, initializer=None, params=None, owner=None, prefs=None, **kwargs)¶

Implements Leaky Competitive Accumulator (LCA) described in Usher & McClelland (2001). function returns:

\[previous\_value + (variable - leak \cdot previous\_value) \cdot time\_step\_size + noise \sqrt{time\_step\_size}\]

where variable corresponds to \(\rho_i\) + \(\beta\)\(\Sigma f(x_{\neq i})\) (the net input to a unit), leak corresponds to \(k\), and time_step_size corresponds to \(\frac{dt}{\tau}\) in Equation 4 of Usher & McClelland (2001).

Note

When used as the function of an LCAMechanism, the value passed to variable is the sum of the external and recurrent inputs to the Mechanism (see here for how the external and recurrent inputs can be configured in a RecurrentTransferMechanism, of which LCAMechanism is subclass).

Note

the value of the leak argument is assigned to the rate parameter (and the leak parameter as an alias of the rate parameter); this is to be consistent with the parent class, IntegratorFunction. However, note that in contrast to a standard IntegratorFunction, where \(rate \cdot previous\_value\) is added to variable, here it is subtracted from variable in order to implement decay. Thus, the value returned by the function can increase in a given time step only if rate (aka leak) is negative or variable is sufficiently positive.

Modulatory Parameters:

MULTIPLICATIVE_PARAM: rate
ADDITIVE_PARAM: offset

Parameters:
  • default_variable (number, list or array : default class_defaults.variable) – specifies a template for the value to be integrated; if it is a list or array, each element is independently integrated.

  • leak (float, list or 1d array : default 1.0) – specifies the value used to scale the rate of decay of the integral on each time step. If it is a list or array, it must be the same length as variable (see leak for details).

  • noise (float, function, list or 1d array : default 0.0) – specifies random value added to integral in each call to function; if it is a list or array, it must be the same length as variable (see noise for additonal details).

  • offset (float, list or 1d array : default 0.0) – specifies a constant value added to integral in each call to function; if it is a list or array, it must be the same length as variable (see offset for details).

  • time_step_size (float : default 0.0) – specifies the timing precision of the integration process (see time_step_size for details.

  • initializer (float, list or 1d array : default 0.0) – specifies starting value(s) for integration. If it is a list or array, it must be the same length as variable (see initializer for details).

  • params (Dict[param keyword: param value] : default None) – a parameter dictionary that specifies the parameters for the function. Values specified for parameters in the dictionary override any assigned to those parameters in arguments of the constructor.

  • owner (Component) – component to which to assign the Function.

  • name (str : default see name) – specifies the name of the Function.

  • prefs (PreferenceSet or specification dict : default Function.classPreferences) – specifies the PreferenceSet for the Function (see prefs for details).

variable¶

current input value some portion of which (determined by rate) will be added to the prior value; if it is an array, each element is independently integrated.

Type:

number or array

rate¶

scales the contribution of previous_value to the decay of the value on each time step (corresponding to the leak term of the function described in Equation 4 of Usher & McClelland, 2001). If it is a float or has a single element, its value is applied to all the elements of previous_value; if it is an array, each element is applied to the corresponding element of previous_value. Serves as MULTIPLICATIVE_PARAM for modulation of function.

Note

aliased by the leak parameter.

Type:

float, list or 1d array

leak¶

alias of rate (to be consistent with the standard format of an IntegratorFunction).

Type:

float, list or 1d array

noise¶

random value added to integral in each call to function. (see noise for details).

Type:

float, Function, or 1d array

offset¶

constant value added to integral in each call to function. If variable is an array and offset is a float, offset is applied to each element of the integral; if offset is a list or array, each of its elements is applied to each of the corresponding elements of the integral (i.e., Hadamard addition). Serves as ADDITIVE_PARAM for modulation of function.

Type:

float or 1d array

time_step_size¶

determines the timing precision of the integration process and is used to scale the noise parameter appropriately.

Type:

float

initializer¶

determines the starting value(s) for integration (i.e., the value(s) to which previous_value is set (see initializer for details).

Type:

float or 1d array

previous_value¶

stores previous value with which variable is integrated.

Type:

1d array : default class_defaults.variable

owner¶

component to which the Function has been assigned.

Type:

Component

name¶

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

Type:

str

prefs¶

the PreferenceSet for function; if it is not specified in the prefs argument of the Function’s constructor, a default is assigned using classPreferences defined in __init__.py (see Preferences for details).

Type:

PreferenceSet or specification dict : Function.classPreferences

_function(variable=None, context=None, params=None)¶
Parameters:
  • variable (number, list or array : default class_defaults.variable) – a single value or array of values to be integrated.

  • params (Dict[param keyword: param value] : default None) – a parameter dictionary that specifies the parameters for the function. Values specified for parameters in the dictionary override any assigned to those parameters in arguments of the constructor.

Returns:

  • updated value of integral (2d array)

class psyneulink.core.components.functions.stateful.integratorfunctions.DualAdaptiveIntegrator(default_variable=None, initializer=None, initial_short_term_avg=None, initial_long_term_avg=None, short_term_gain=None, long_term_gain=None, short_term_bias=None, long_term_bias=None, short_term_rate=None, long_term_rate=None, operation=None, offset=None, params=None, owner=None, prefs=None)¶

Combines two exponentially weighted moving averages (EWMA) of its input, each with a different rate, as implemented in Aston-Jones & Cohen (2005) to integrate utility over two time scales.

function computes the EWMA of variable using two integration rates (short_term_rate and long_term_rate), transforms each using a logistic function, and then combines them, as follows:

  • short time scale integral:

    \[short\_term\_avg = short\_term\_rate \cdot variable + (1 - short\_term\_rate) \cdot previous\_short\_term\_avg\]
  • long time scale integral:

    \[long\_term\_avg = long\_term\_rate \cdot variable + (1 - long\_term\_rate) \cdot previous\_long\_term\_avg\]
  • combined integral:

    \[value = operation(1-\frac{1}{1+e^{short\_term\_gain\ \cdot\ short\_term\_avg\ +\ short\_term\_bias}},\ \frac{1}{1+e^{long\_term\_gain\ \cdot\ long\_term\_avg + long\_term\_bias}})\ +\ offset\]

    where operation is the arithmetic operation used to combine the terms.

Modulatory Parameters:

ADDITIVE_PARAM: offset

Parameters:
  • initial_short_term_avg (float : default 0.0) – specifies starting value for integration of short_term_avg

  • initial_long_term_avg (float : default 0.0) – specifies starting value for integration of long_term_avg

  • short_term_gain (float : default 1.0) – specifies gain for logistic function applied to short_term_avg

  • long_term_gain (float : default 1.0) – specifies gain for logistic function applied to long_term_avg

  • short_term_bias (float : default 0.0) – specifies bias for logistic function applied to short_term_avg

  • long_term_bias (float : default 0.0) – specifies bias for logistic function applied to long_term_avg

  • short_term_rate (float : default 1.0) – specifies smoothing factor of EWMA filter applied to short_term_avg

  • long_term_rate (float : default 1.0) – specifies smoothing factor of EWMA filter applied to long_term_avg

  • operation (PRODUCT, SUM, S_MINUS_L or L_MINUS_S : default PRODUCT) – specifies the arithmetic operation used to combine the logistics of the short_term_avg and long_term_avg (see operation for details).

  • offset (float or 1d array) – constant value added to integral in each call to function after logistics of short_term_avg and long_term_avg are combined; if it is a list or array, it must be the same length as variable (see offset for details.

  • params (Dict[param keyword: param value] : default None) – a parameter dictionary that specifies the parameters for the function. Values specified for parameters in the dictionary override any assigned to those parameters in arguments of the constructor.

  • owner (Component) – component to which to assign the Function.

  • name (str : default see name) – specifies the name of the Function.

  • prefs (PreferenceSet or specification dict : default Function.classPreferences) – specifies the PreferenceSet for the Function (see prefs for details).

variable¶

current input value used to compute both the short term and long term EWMA averages.

Type:

number or array

initial_short_term_avg¶

determines starting value for integration of short_term_avg

Type:

float

initial_long_term_avg¶

determines starting value for integration of long_term_avg

Type:

float

short_term_gain¶

determines gain for logistic function applied to short_term_avg

Type:

float

long_term_gain¶

determines gain for logistic function applied to long_term_avg

Type:

float

short_term_bias¶

determines bias for logistic function applied to short_term_avg

Type:

float

long_term_bias¶

determines bias for logistic function applied to long_term_avg

Type:

float

short_term_rate¶

determines smoothing factor of EWMA filter applied to short_term_avg

Type:

float

long_term_rate¶

determines smoothing factor of EWMA filter applied to long_term_avg

Type:

float

operation¶

determines the arithmetic operation used to combine short_term_logistic and long_term_logistic:

  • PRODUCT = (1 - short_term_logistic) * long_term_logistic

  • SUM = (1 - short_term_logistic) + long_term_logistic

  • S_MINUS_L = (1 - short_term_logistic) - long_term_logistic

  • L_MINUS_S = long_term_logistic - (1 - short_term_logistic)

Type:

str

offset¶

constant value added to integral in each call to function after logistics of short_term_avg and long_term_avg are combined. If variable is an array and offset is a float, offset is applied to each element of the integral; if offset is a list or array, each of its elements is applied to each of the corresponding elements of the integral (i.e., Hadamard addition). Serves as ADDITIVE_PARAM for modulation of function.

Type:

float or 1d array

previous_short_term_avg¶

stores previous value with which variable is integrated using the EWMA filter and short term parameters

Type:

1d array

previous_long_term_avg¶

stores previous value with which variable is integrated using the EWMA filter and long term parameters

Type:

1d array

owner¶

component to which the Function has been assigned.

Type:

Component

name¶

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

Type:

str

prefs¶

the PreferenceSet for function; if it is not specified in the prefs argument of the Function’s constructor, a default is assigned using classPreferences defined in __init__.py (see Preferences for details).

Type:

PreferenceSet or specification dict : Function.classPreferences

_validate_params(request_set, target_set=None, context=None)¶

Check inner dimension (length) of all parameters used for the function

Insure that for any parameters that are in the Parameters class, designated as function_arg, and

specified by the user with length>1: 1) they all have the same length; 2) if default_variable:

  • was specified by the user, the parameters all have the same length as that

  • was NOT specified by the user, they all have the same length as each other; in this case, default_variable will be set to the length of those parameters in _instantiate_attributes_before_function below

_function(variable=None, context=None, params=None)¶
Parameters:
  • variable (number, list or array : default class_defaults.variable) – a single value or array of values to be integrated.

  • params (Dict[param keyword: param value] : default None) – a parameter dictionary that specifies the parameters for the function. Values specified for parameters in the dictionary override any assigned to those parameters in arguments of the constructor.

Returns:

  • updated value of integral (2d array)

reset(short=None, long=None, context=NotImplemented)¶

Effectively begins accumulation over again at the specified utilities.

Sets previous_short_term_avg to the quantity specified in the first argument and previous_long_term_avg to the quantity specified in the second argument.

Sets value by computing it based on the newly updated values for previous_short_term_avg and previous_long_term_avg.

If no arguments are specified, then the current values of initial_short_term_avg and initial_long_term_avg are used.

class psyneulink.core.components.functions.stateful.integratorfunctions.InteractiveActivationIntegrator(default_variable=None, rate=None, decay=None, rest=None, max_val=None, min_val=None, noise=None, initializer=None, params=None, owner=None, prefs=None)¶

Implements a generalized version of the interactive activation from McClelland and Rumelhart (1981) that integrates current value of variable toward an asymptotic maximum value max_val for positive inputs and toward an asymptotic mininum value (min_val) for negative inputs, and decays asymptotically towards an intermediate resting value (rest).

function returns:

\[previous\_value + (rate * (variable + noise) * distance\_from\_asymptote) - (decay * distance\_from\_rest)\]

where:

\[if\ variable > 0,\ distance\_from\_asymptote = max\_val - previous\_value\]
\[if\ variable < 0,\ distance\_from\_asymptote = previous\_value - min\_val\]
\[if\ variable = 0,\ distance\_from\_asymptote = 0\]
Parameters:
  • default_variable (number, list or array : default class_defaults.variable) – specifies a template for the value to be integrated; if it is a list or array, each element is independently integrated.

  • rate (float, list or 1d array : default 1.0) – specifies the rate of change in activity; its value(s) must be in the interval [0,1]. If it is a list or array, it must be the same length as variable.

  • decay (float, list or 1d array : default 1.0) – specifies the rate of at which activity decays toward rest. If it is a list or array, it must be the same length as variable; its value(s) must be in the interval [0,1].

  • rest (float, list or 1d array : default 0.0) – specifies the initial value and one toward which value decays. If it is a list or array, it must be the same length as variable.

  • max_val (float, list or 1d array : default 1.0) – specifies the maximum asymptotic value toward which integration occurs for positive values of variable. If it is a list or array, it must be the same length as variable; all values must be greater than the corresponding values of min_val (see max_val for details).

  • min_val (float, list or 1d array : default 1.0) – specifies the minimum asymptotic value toward which integration occurs for negative values of variable. If it is a list or array, it must be the same length as variable; all values must be greater than the corresponding values of max_val (see max_val for details).

  • noise (float, function, list or 1d array : default 0.0) – specifies random value added to variable in each call to function; if it is a list or array, it must be the same length as variable (see noise for details).

  • initializer (float, list or 1d array : default 0.0) – specifies starting value(s) for integration. If it is a list or array, it must be the same length as variable (see initializer for details).

  • params (Dict[param keyword: param value] : default None) – a parameter dictionary that specifies the parameters for the function. Values specified for parameters in the dictionary override any assigned to those parameters in arguments of the constructor.

  • owner (Component) – component to which to assign the Function.

  • name (str : default see name) – specifies the name of the Function.

  • prefs (PreferenceSet or specification dict : default Function.classPreferences) – specifies the PreferenceSet for the Function (see prefs for details).

variable¶

current input value some portion of which (determined by rate) will be added to the prior value; if it is an array, each element is independently integrated.

Type:

number or array

rate¶

determines the rate at which activity increments toward either max_val (variable is positive) or min_val (if variable is negative). If it is a float or has a single element, it is applied to all elements of variable; if it has more than one element, each element is applied to the corresponding element of variable. Serves as MULTIPLICATIVE_PARAM for modulation of function.

Type:

float or 1d array in interval [0,1]

decay¶

determines the rate of at which activity decays toward rest (similary to rate in other IntegratorFuncgtions). If it is a float or has a single element, it applies to all elements of variable; if it has more than one element, each element applies to the corresponding element of variable.

Type:

float or 1d array

rest¶

determines the initial value and one toward which value decays (similar to bias in other IntegratorFunctions). If it is a float or has a single element, it applies to all elements of variable; if it has more than one element, each element applies to the corresponding element of variable.

Type:

float or 1d array

max_val¶

determines the maximum asymptotic value toward which integration occurs for positive values of variable. If it is a float or has a single element, it applies to all elements of variable; if it has more than one element, each element applies to the corresponding element of variable.

Type:

float or 1d array

min_val¶

determines the minimum asymptotic value toward which integration occurs for negative values of variable. If it is a float or has a single element, it applies to all elements of variable; if it has more than one element, each element applies to the corresponding element of variable.

Type:

float or 1d array

noise¶

random value added to variable in each call to function (see noise for details).

Type:

float, Function or 1d array

initializer¶

determines the starting value(s) for integration (i.e., the value(s) to which previous_value is set (see initializer for details).

Type:

float or 1d array

previous_value¶

stores previous value with which variable is integrated.

Type:

1d array : default class_defaults.variable

owner¶

component to which the Function has been assigned.

Type:

Component

name¶

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

Type:

str

prefs¶

the PreferenceSet for function; if it is not specified in the prefs argument of the Function’s constructor, a default is assigned using classPreferences defined in __init__.py (see Preferences for details).

Type:

PreferenceSet or specification dict : Function.classPreferences

_validate_params(request_set, target_set=None, context=None)¶

Check inner dimension (length) of all parameters used for the function

Insure that for any parameters that are in the Parameters class, designated as function_arg, and

specified by the user with length>1: 1) they all have the same length; 2) if default_variable:

  • was specified by the user, the parameters all have the same length as that

  • was NOT specified by the user, they all have the same length as each other; in this case, default_variable will be set to the length of those parameters in _instantiate_attributes_before_function below

_function(variable=None, context=None, params=None)¶
Parameters:
  • variable (number, list or array : default class_defaults.variable) – a single value or array of values to be integrated.

  • params (Dict[param keyword: param value] : default None) – a parameter dictionary that specifies the parameters for the function. Values specified for parameters in the dictionary override any assigned to those parameters in arguments of the constructor.

Returns:

  • updated value of integral (2d array)

class psyneulink.core.components.functions.stateful.integratorfunctions.IntegratorFunction(default_variable=None, rate=None, noise=None, initializer=None, params=None, owner=None, prefs=None, context=None, **kwargs)¶

Base class for Functions that integrate current value of variable with its prior value. For most subclasses, variable can be a single float or an array. If it is an array, each element is integrated independently of the others.

Note

If variable is an array, for any parameter that is specified as a float its value is applied uniformly to all elements of the relevant term of the integral (e.g., variable or previous_value, depending on the subclass); for any parameter specified as an array, it must be the same length as variable, and it is applied elementwise (Hadarmard) to the relevant term of the integral. If, on initialization, the default_variable is not specified, any parameters specified as an array must be the same length, and the default_variable is assumed to have the same length as those parameters.

Parameters:
  • default_variable (number, list or array : default class_defaults.variable) – specifies a template for the value to be integrated; if it is a list or array, each element is independently integrated.

  • initializer (float, list or 1d array : default 0.0) – specifies starting value(s) for integration. If it is a list or array, it must be the same length as variable (see initializer for details).

  • rate (float, list or 1d array : default 1.0) – specifies the rate of integration. If it is a list or array, it must be the same length as variable (see rate for details).

  • noise (float, list, array or function : default 0.0) – specifies value added to integral in each call to function; if it is a list or array, it must be the same length as variable (see noise for additional details).

  • time_step_size (float : default 0.0) – determines the timing precision of the integration process

  • params (Dict[param keyword: param value] : default None) – a parameter dictionary that specifies the parameters for the function. Values specified for parameters in the dictionary override any assigned to those parameters in arguments of the constructor.

  • owner (Component) – component to which to assign the Function.

  • name (str : default see name) – specifies the name of the Function.

  • prefs (PreferenceSet or specification dict : default Function.classPreferences) – specifies the PreferenceSet for the Function (see prefs for details).

variable¶

current input value some portion of which (determined by rate) that will be added to the prior value; if it is an array, each element is independently integrated.

Type:

number or array

rate¶

determines the rate of integration. If it is a float or has a single value, it is applied to all elements of variable and/or previous_value (depending on the subclass); if it has more than one element, each element is applied to the corresponding element of variable and/or previous_value.

Type:

float or 1d array

noise¶

value is added to integral in each call to function. If noise is a float, it is applied to all elements of variable; if it is an array, it is applied Hadamard (elementwise) to each element of variable. If it is a function, it is executed separately and applied independently to each element of variable.

Hint

To generate random noise that varies for every execution and across all elements of an array, a DistributionFunction should be used, that generates a new value on each execution. If noise is specified as a float, a function with a fixed output, or an array of either of these, then noise is simply an offset that is the same across all elements and executions.

Type:

float, array or Function

initializer¶

determines the starting value(s) for integration (i.e., the value(s) to which previous_value is set. If variable is a list or array, and initializer is a float or has a single element, it is applied to each element of previous_value. If initializer is a list or array, each element is applied to the corresponding element of previous_value.

Type:

float or 1d array

previous_value¶

stores previous value with which variable is integrated.

Type:

1d array

owner¶

component to which the Function has been assigned.

Type:

Component

name¶

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

Type:

str

prefs¶

the PreferenceSet for function; if it is not specified in the prefs argument of the Function’s constructor, a default is assigned using classPreferences defined in __init__.py (see Preferences for details).

Type:

PreferenceSet or specification dict : Function.classPreferences

_validate_params(request_set, target_set=None, context=None)¶

Check inner dimension (length) of all parameters used for the function

Insure that for any parameters that are in the Parameters class, designated as function_arg, and

specified by the user with length>1: 1) they all have the same length; 2) if default_variable:

  • was specified by the user, the parameters all have the same length as that

  • was NOT specified by the user, they all have the same length as each other; in this case, default_variable will be set to the length of those parameters in _instantiate_attributes_before_function below

_instantiate_attributes_before_function(function=None, context=None)¶

Insure inner dimension of default_variable matches the length of any parameters that have len>1

_EWMA_filter(previous_value, rate, variable)¶

Return exponentially weighted moving average (EWMA) of a variable.

_logistic(variable, gain, bias)¶

Return logistic transform of variable


© Copyright 2016, Jonathan D. Cohen.

Built with Sphinx using a theme provided by Read the Docs.
  • IntegratorFunctions
    • SimpleIntegrator
      • SimpleIntegrator.variable
      • SimpleIntegrator.rate
      • SimpleIntegrator.noise
      • SimpleIntegrator.offset
      • SimpleIntegrator.initializer
      • SimpleIntegrator.previous_value
      • SimpleIntegrator.owner
      • SimpleIntegrator.name
      • SimpleIntegrator.prefs
      • SimpleIntegrator._function()
    • AdaptiveIntegrator
      • AdaptiveIntegrator.variable
      • AdaptiveIntegrator.rate
      • AdaptiveIntegrator.noise
      • AdaptiveIntegrator.offset
      • AdaptiveIntegrator.initializer
      • AdaptiveIntegrator.previous_value
      • AdaptiveIntegrator.owner
      • AdaptiveIntegrator.name
      • AdaptiveIntegrator.prefs
      • AdaptiveIntegrator._validate_params()
      • AdaptiveIntegrator._function()
    • DriftDiffusionIntegrator
      • DriftDiffusionIntegrator.variable
      • DriftDiffusionIntegrator.rate
      • DriftDiffusionIntegrator.random_state
      • DriftDiffusionIntegrator.noise
      • DriftDiffusionIntegrator.offset
      • DriftDiffusionIntegrator.starting_value
      • DriftDiffusionIntegrator.non_decision_time
      • DriftDiffusionIntegrator.threshold
      • DriftDiffusionIntegrator.time_step_size
      • DriftDiffusionIntegrator.initializer
      • DriftDiffusionIntegrator.previous_time
      • DriftDiffusionIntegrator.previous_value
      • DriftDiffusionIntegrator.owner
      • DriftDiffusionIntegrator.name
      • DriftDiffusionIntegrator.prefs
      • DriftDiffusionIntegrator._function()
      • DriftDiffusionIntegrator.reset()
      • DriftDiffusionIntegrator._assign_to_mdf_model()
    • DriftOnASphereIntegrator
      • DriftOnASphereIntegrator.previous_value
      • DriftOnASphereIntegrator.drift_dir
      • DriftOnASphereIntegrator.random_state
      • DriftOnASphereIntegrator._proj_tangent()
      • DriftOnASphereIntegrator._expmap_sphere()
      • DriftOnASphereIntegrator._parallel_transport_exact()
      • DriftOnASphereIntegrator._tangent_basis()
      • DriftOnASphereIntegrator._hyperspherical_to_cartesian()
      • DriftOnASphereIntegrator._logmap_sphere()
      • DriftOnASphereIntegrator._instantiate_attributes_before_function()
      • DriftOnASphereIntegrator._function()
      • DriftOnASphereIntegrator.reset()
    • OrnsteinUhlenbeckIntegrator
      • OrnsteinUhlenbeckIntegrator.variable
      • OrnsteinUhlenbeckIntegrator.rate
      • OrnsteinUhlenbeckIntegrator.decay
      • OrnsteinUhlenbeckIntegrator.noise
      • OrnsteinUhlenbeckIntegrator.offset
      • OrnsteinUhlenbeckIntegrator.non_decision_time
      • OrnsteinUhlenbeckIntegrator.time_step_size
      • OrnsteinUhlenbeckIntegrator.initializer
      • OrnsteinUhlenbeckIntegrator.previous_value
      • OrnsteinUhlenbeckIntegrator.previous_time
      • OrnsteinUhlenbeckIntegrator.random_state
      • OrnsteinUhlenbeckIntegrator.owner
      • OrnsteinUhlenbeckIntegrator.name
      • OrnsteinUhlenbeckIntegrator.prefs
      • OrnsteinUhlenbeckIntegrator._function()
      • OrnsteinUhlenbeckIntegrator.reset()
    • FitzHughNagumoIntegrator
      • FitzHughNagumoIntegrator.variable
      • FitzHughNagumoIntegrator.previous_v
      • FitzHughNagumoIntegrator.previous_w
      • FitzHughNagumoIntegrator.previous_t
      • FitzHughNagumoIntegrator.owner
      • FitzHughNagumoIntegrator.initial_w
      • FitzHughNagumoIntegrator.initial_v
      • FitzHughNagumoIntegrator.time_step_size
      • FitzHughNagumoIntegrator.t_0
      • FitzHughNagumoIntegrator.a_v
      • FitzHughNagumoIntegrator.b_v
      • FitzHughNagumoIntegrator.c_v
      • FitzHughNagumoIntegrator.d_v
      • FitzHughNagumoIntegrator.e_v
      • FitzHughNagumoIntegrator.f_v
      • FitzHughNagumoIntegrator.time_constant_v
      • FitzHughNagumoIntegrator.a_w
      • FitzHughNagumoIntegrator.b_w
      • FitzHughNagumoIntegrator.c_w
      • FitzHughNagumoIntegrator.threshold
      • FitzHughNagumoIntegrator.mode
      • FitzHughNagumoIntegrator.uncorrelated_activity
      • FitzHughNagumoIntegrator.time_constant_w
      • FitzHughNagumoIntegrator.prefs
      • FitzHughNagumoIntegrator._validate_params()
      • FitzHughNagumoIntegrator._function()
      • FitzHughNagumoIntegrator.reset()
      • FitzHughNagumoIntegrator._assign_to_mdf_model()
    • AccumulatorIntegrator
      • AccumulatorIntegrator.variable
      • AccumulatorIntegrator.rate
      • AccumulatorIntegrator.increment
      • AccumulatorIntegrator.noise
      • AccumulatorIntegrator.initializer
      • AccumulatorIntegrator.previous_value
      • AccumulatorIntegrator.owner
      • AccumulatorIntegrator.name
      • AccumulatorIntegrator.prefs
      • AccumulatorIntegrator._accumulator_check_args()
      • AccumulatorIntegrator._function()
    • LeakyCompetingIntegrator
      • LeakyCompetingIntegrator.variable
      • LeakyCompetingIntegrator.rate
      • LeakyCompetingIntegrator.leak
      • LeakyCompetingIntegrator.noise
      • LeakyCompetingIntegrator.offset
      • LeakyCompetingIntegrator.time_step_size
      • LeakyCompetingIntegrator.initializer
      • LeakyCompetingIntegrator.previous_value
      • LeakyCompetingIntegrator.owner
      • LeakyCompetingIntegrator.name
      • LeakyCompetingIntegrator.prefs
      • LeakyCompetingIntegrator._function()
    • DualAdaptiveIntegrator
      • DualAdaptiveIntegrator.variable
      • DualAdaptiveIntegrator.initial_short_term_avg
      • DualAdaptiveIntegrator.initial_long_term_avg
      • DualAdaptiveIntegrator.short_term_gain
      • DualAdaptiveIntegrator.long_term_gain
      • DualAdaptiveIntegrator.short_term_bias
      • DualAdaptiveIntegrator.long_term_bias
      • DualAdaptiveIntegrator.short_term_rate
      • DualAdaptiveIntegrator.long_term_rate
      • DualAdaptiveIntegrator.operation
      • DualAdaptiveIntegrator.offset
      • DualAdaptiveIntegrator.previous_short_term_avg
      • DualAdaptiveIntegrator.previous_long_term_avg
      • DualAdaptiveIntegrator.owner
      • DualAdaptiveIntegrator.name
      • DualAdaptiveIntegrator.prefs
      • DualAdaptiveIntegrator._validate_params()
      • DualAdaptiveIntegrator._function()
      • DualAdaptiveIntegrator.reset()
    • InteractiveActivationIntegrator
      • InteractiveActivationIntegrator.variable
      • InteractiveActivationIntegrator.rate
      • InteractiveActivationIntegrator.decay
      • InteractiveActivationIntegrator.rest
      • InteractiveActivationIntegrator.max_val
      • InteractiveActivationIntegrator.min_val
      • InteractiveActivationIntegrator.noise
      • InteractiveActivationIntegrator.initializer
      • InteractiveActivationIntegrator.previous_value
      • InteractiveActivationIntegrator.owner
      • InteractiveActivationIntegrator.name
      • InteractiveActivationIntegrator.prefs
      • InteractiveActivationIntegrator._validate_params()
      • InteractiveActivationIntegrator._function()
    • IntegratorFunction
      • IntegratorFunction.variable
      • IntegratorFunction.rate
      • IntegratorFunction.noise
      • IntegratorFunction.initializer
      • IntegratorFunction.previous_value
      • IntegratorFunction.owner
      • IntegratorFunction.name
      • IntegratorFunction.prefs
      • IntegratorFunction._validate_params()
      • IntegratorFunction._instantiate_attributes_before_function()
      • IntegratorFunction._EWMA_filter()
      • IntegratorFunction._logistic()
  • Github