# Pathway¶

## Overview¶

A Pathway is a sequence of Nodes and Projections. Generally, Pathways are assigned to Compositions, but a Pathway object can be created on its and used as a template for specifying a Pathway for a Composition, as described below. See Pathways for additional information about Pathways in Compositions.

## Creating a Pathway¶

Pathway objects are created in one of two ways, either using the constructor to create a template, or automatically when a Pathway is assigned to a Composition.

### Pathway as a Template¶

A Pathway created on its own, using its constructor, is a template, that can be used to specifiy a Pathway for one or more Compositions, as described below; however, it cannot be executed on its own. When a Pathway object is used to assign a Pathway to a Composition, its pathway attribute, and its name if that is not otherwise specified (see below), are used as the specification to create a new Pathway that is assigned to the Composition, and the template remains unassigned.

### Assigning Pathways to a Composition¶

Pathways can be assigned to a Composition using the pathways argument of the Composition’s constructor, or one of its Pathway addition methods. A Pathway object can be used, along with any other form of Pathway specification for those arguments. However, the Pathway object itself is not assigned to the Composition; rather, it serves as a template for a new Pathway object that is automatically created and assigned to the Composition. The Composition’s Pathway addition methods return a Pathway object for each Pathway created and assigned to theComposition. All of the Pathways assigned to a Composition are listed in its pathways attribute.

### Pathway Name¶

If the name argument of the Pathway’s constructor is used to assign it a name, this is used as the name of the Pathway created when it is assigned to a Composition in its constructor, or using its add_pathways method. This is also the case if one of the Composition’s other Pathway addition methods is used, as long as the name argument of those methods is not specified. However, if the name argument is specified in those methods, or Pathway specification dictionary is used to specify the Pathway’s name, that takes precedence over, and replaces one specified in the Pathway template's name attribute.

### Pathway Specification¶

The following formats can be used to specify a Pathway in the pathway argument of the constructor for the Pathway, the pathways argument of a the constructor for a Composition, or the corresponding argument of any of a Composition’s Pathway addition methods:

In addition to the forms of single Pathway specification above, where multiple Pathways can be specified (e.g., the pathways argument of the constructor for a Composition or its add_pathways method), they can be specified in a list, in which each item of the list can be any of the forms above, or one of the following:

• dict: {name : Pathway) – in which name is a str and Pathway is a Pathway object or constuctor, or one of the standard Pathway specifications listed above.

Note

If any of the following is used to specify the pathways argument:
• a standalone Node (i.e., not in a list),
• a single Node alone in a list,
• one or more Nodes with any other form of Pathway specification in the list

then each such Node in the list is treated as its own SINGLETON pathway (i.e., one containing a single Node that is both the ORIGIN and theTERMINAL of the Pathway). However, if the list contains only Nodes, then it is treated as a single Pathway (i.e., the list form of Pathway specification. Thus:

pathway: NODE -> single pathway

pathway: [NODE] -> single pathway

pathway: [NODE, NODE…] -> single pathway

pathway: [NODE, NODE, () or {} or Pathway…] -> three or more pathways

## Structure¶

A Pathway has the following primary attributes:

## Execution¶

A Pathway cannot be executed on its own. Its Components are executed when the Composition to which it belongs is executed, by default in the order in which they appear in the pathway attribute; however, this can be modified by Conditions added to the Composition’s scheduler.

## Class Reference¶

class psyneulink.core.compositions.pathway.Pathway(pathway, name=None, **kwargs)

A sequence of Nodes and Projections in a Composition, or a template for one that can be assigned to one or more Compositions.

Parameters: pathway (list[Node, Node…]) – specifies list of Nodes and intercolated Projections to be created for the Pathway. name (str : default see name) – specifies the name of the Pathway; see name for additional information.
pathway

Node, list, tuple, or dict. – if the Pathway is created on its own, this contains the specification provided to the pathway argument of its constructor, and can take any of the forms permitted for Pathway specification; if the Pathway is created by a Composition, this is a list of the Nodes and intercolated Projections in the Pathway (see above for additional details).

composition

Composition or None – Composition to which the Pathway belongs; if None, then Pathway is a template.

roles

list[PathwayRole] or None – list of PathwayRole(s) assigned to the Pathway, based on the NodeRole(s) assigned to its Nodes in the composition to which it belongs. Returns an empty list if belongs to a Composition but no PathwayRoles have been assigned, and None if the Pathway is a tempalte (i.e., not assigned to a Composition).

learning_function

LearningFunction or None – LearningFunction used by LearningMechanism(s) associated with Pathway if it is a learning pathway.

input

Mechanism or None – INPUT node if Pathway contains one.

output

Mechanism or None – OUTPUT node if Pathway contains one.

target

Mechanism or None – TARGET node if if Pathway contains one; same as learning_components[TARGET_MECHANISM].

learning_objective

Mechanism or None – OBJECTIVE_MECHANISM if Pathway contains one; same as learning_components[COMPATOR_MECHANISM].

learning_components

dict or None – dict containing the following entries if the Pathway is a learning Pathway (and is assigned PathwayRole.LEARNING in roles):

TARGET_MECHANISM: ProcessingMechanism (assigned to target) .. OBJECTIVE_MECHANISM: ComparatorMechanism (assigned to learning_objective) .. LEARNING_MECHANISMS: Learning Mechanism or list[Learning Mechanism] .. LEARNED_PROJECTIONS: Projection or list[Projections]

These are generated automatically and added to the Composition when the Pathway is assigned to it. Returns an empty dict if it is not a learning Pathway, and None if the Pathway is a tempalte (i.e., not assigned to a Composition).

name

str – the name of the Pathway; if it is not specified in the name argument of the constructor, a default is assigned by PathwayRegistry (see Naming for conventions used for default and duplicate names). See note for additional information.

_assign_roles(composition)

Assign PathwayRoles to Pathway based NodeRoles assigned to its Nodes by the composition to which it belongs.

class psyneulink.core.compositions.pathway.PathwayRole(*args, **kwargs)

Roles assigned to the Pathway of a Composition.

ORIGIN

A Pathway that includes an ORIGIN Node of the Composition.

INPUT

A Pathway that includes an INPUT Node of the Composition.

SINGELTON

A Pathway with a single Node that is a SINGLETON of the Composition.

INTERNAL

A Pathway that does not include any ORIGIN or TERMINAL Nodes of the Composition.

OUTPUT

A Pathway that includes an OUTPUT Node of the Composition.

TERMINAL

A Pathway that includes a TERMINAL Node of the Composition.

CYCLE

A Pathway that constitutes a CYCLE in the Composition.

LEARNING

A Pathway that constitutes a learning Pathway of the Composition.

_member_type_

alias of object