ControlProjection¶
Contents¶
Overview¶
A ControlProjection is a type of ModulatoryProjection that projects to the ParameterPort of a ProcessingMechanism. It takes the value of a
ControlSignal of a ControlMechanism and uses it to modify the value of the parameter associated
with the ParameterPort to which it projects. All of the ControlProjections in a Composition, along with its other
control components, can be displayed using the Composition’s show_graph method with its show_control argument assigned as True.
Creating a ControlProjection¶
A ControlProjection can be created using any of the standard ways to create a Projection,
or by including it in a tuple that specifies a parameter for a Mechanism, MappingProjection, or the function of either of these. If a ControlProjection
is created explicitly (using its constructor), and either its receiver or sender argument is not specified,
its initialization is deferred. If it is included in a parameter
specification, the ParameterPort for the parameter being specified will be assigned
as the ControlProjection’s receiver. If the receiver belongs to a Mechanism that
is part of a Composition, then the ControlProjection’s sender is assigned to a
ControlSignal of the Composition’s controller. Otherwise, its initialization is
deferred.
Deferred Initialization¶
When a ControlProjection is created, its full initialization is deferred until its sender and receiver have been fully specified. This allows
a ControlProjection to be created before its sender and/or receiver have been created (e.g., before them in a script), by calling its constructor without
specifying its sender or receiver arguments. However, for the ControlProjection to be operational,
initialization must be completed by a call to its deferred_init method. This is done automatically if the
ControlProjection is included in a tuple specification for the parameter of a
Mechanism or its function, when the ControlMechanism
is created for the Composition to which the parameter’s owner belongs (see Creating a ControlMechanism).
Structure¶
The sender of a ControlProjection is a ControlSignal of a ControlMechanism. The value of the sender is used by the
ControlProjection as its variable; this is also assigned to its control_signal attribute, and serves as the input to the ControlProjection’s function. The default function for a ControlProjection is an identity
function (Linear with slope=1 and intercept=0); that is, it simply conveys the value of its
control_signal to its receiver, for use in
modifying the value of the parameter that it controls. Its receiver is the
ParameterPort for the parameter of the Mechanism or its function Mechanism_Base.function> that is
controlled by the ControlProjection.
Execution¶
A ControlProjection cannot be executed directly. It is executed when the ParameterPort to which it projects is
updated. Note that this only occurs when the Mechanism to which the ParameterPort belongs is executed
(see Lazy Evaluation for an explanation of “lazy” updating). When a ControlProjection is
executed, its function gets the control_signal from
its sender and conveys that to its receiver. This is used
by the receiver to modify the parameter controlled by the ControlProjection (see
Modulation and ParameterPort Execution for how modulation operates and
how this applies to a ParameterPort).
Note
The changes to a parameter in response to the execution of a ControlProjection are not applied until the Mechanism that receives the ControlProjection are next executed; see Lazy Evaluation for an explanation of “lazy” updating).
Class Reference¶
- class psyneulink.core.components.projections.modulatory.controlprojection.ControlProjection(sender=None, receiver=None, weight=None, exponent=None, function=None, control_signal_params=None, params=None, name=None, prefs=None, **kwargs)¶
Subclass of ModulatoryProjection that modulates the value of an InputPort, ParameterPort, or OutputPort of a Mechanism. See Projection for additional arguments and attributes.
- Parameters:
sender (ControlMechanism or ControlSignal : default None) – specifies the source of the
control_signalfor the ControlProjection; if it is not specified and cannot be inferred from context, initialization is deferred.receiver (Mechanism or ParameterPort : default None) – specifies the InputPort, ParameterPort or OutputPort associated with the parameter to be controlled; if it is not specified, and cannot be inferred from context, initialization is deferred.
control_signal_params (Dict[param keyword: param value] : None) – a parameter dictionary that can be used to specify the parameters for the ControlProjection’s
sender(see Structure for a description of ControlSignal parameters).
- sender¶
source of the
control_signal.- Type:
- receiver¶
ParameterPort for the parameter to be modified by the ControlProjection.
- Type:
ParameterPort of Mechanism
- variable¶
same as
control_signal.- Type:
2d np.array
- value¶
the value used to modify the parameter controlled by the ControlProjection (see Modulation and ParameterPort Execution for how modulation operates and how this applies to a ParameterPort).
- Type:
float
- projection_sender¶
alias of
ControlMechanism
- _instantiate_sender(sender, params=None, context=None)¶
Check if DefaultController is being assigned and if so configure it for the requested ControlProjection
If self.sender is a Mechanism, re-assign to <Mechanism>.outputPort Insure that sender.value = self.defaults.variable
- This method overrides the corresponding method of Projection, before calling it, to check if the
DefaultController is being assigned as sender and, if so: - creates projection-dedicated inputPort and outputPort in DefaultController - puts them in DefaultController’s input_ports and outputPorts attributes - lengthens variable of DefaultController to accommodate the ControlProjection - updates value of the DefaultController (in response to the new variable)
Notes
the default function of the DefaultControlMechanism simply maps the inputPort value to the outputPort
the params arg is assumed to be a dictionary of params for the ControlSignal of the ControlMechanism
- Returns:
- _instantiate_receiver(context=None)¶
Handle situation in which self.receiver was specified as a Mechanism (rather than Port)
- Overrides Projection._instantiate_receiver, to require that if the receiver is specified as a Mechanism, then:
the receiver Mechanism must have one and only one ParameterPort; otherwise, passes control to Projection_Base._instantiate_receiver for validation
- Returns:
- exception psyneulink.core.components.projections.modulatory.controlprojection.ControlProjectionError(message, component=None)¶