Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misc/ocm/docs and tests #2223

Merged
merged 224 commits into from
Dec 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
224 commits
Select commit Hold shift + click to select a range
064d63f
• component.py
jdcpni Apr 30, 2021
614a53a
Merge branch 'devel' of https://github.com/PrincetonUniversity/PsyNeu…
jdcpni Apr 30, 2021
a32f213
Merge branch 'devel' of https://github.com/PrincetonUniversity/PsyNeu…
jdcpni Apr 30, 2021
75cf069
Merge branch 'devel' of https://github.com/PrincetonUniversity/PsyNeu…
jdcpni May 5, 2021
dff1a37
Merge branch 'devel' of https://github.com/PrincetonUniversity/PsyNeu…
jdcpni Jul 8, 2021
cd5e38e
Merge branch 'devel' of https://github.com/PrincetonUniversity/PsyNeu…
jdcpni Oct 23, 2021
9361857
Merge branch 'devel' of https://github.com/PrincetonUniversity/PsyNeu…
jdcpni Oct 30, 2021
0129ff7
Merge branch 'devel' of https://github.com/PrincetonUniversity/PsyNeu…
jdcpni Nov 4, 2021
bbd20f5
Merge branch 'devel' of https://github.com/PrincetonUniversity/PsyNeu…
jdcpni Nov 4, 2021
f9aba91
Merge branch 'devel' of https://github.com/PrincetonUniversity/PsyNeu…
jdcpni Nov 7, 2021
a3c0f6c
• optimizationcontrolmechanism.py:
jdcpni Nov 7, 2021
7069b3a
• optimizationcontrolmechanism.py:
jdcpni Nov 7, 2021
65b960e
• optimizationcontrolmechanism.py:
jdcpni Nov 7, 2021
5cc58f6
Merge branch 'devel' of https://github.com/PrincetonUniversity/PsyNeu…
jdcpni Nov 8, 2021
bc05b51
Merge branch 'devel' of https://github.com/PrincetonUniversity/PsyNeu…
jdcpni Nov 8, 2021
a8d428b
- modified test_mode_based_num_estimates
jdcpni Nov 8, 2021
1218b6f
-
jdcpni Nov 8, 2021
41567bb
-
jdcpni Nov 8, 2021
b65650f
Merge branch 'devel' of https://github.com/PrincetonUniversity/PsyNeu…
jdcpni Nov 8, 2021
822742f
• optimizationcontrolmechanism.py:
jdcpni Nov 9, 2021
5a3efba
• composition.py
jdcpni Nov 9, 2021
7acdebd
• composition.py:
jdcpni Nov 9, 2021
f81baf5
-
jdcpni Nov 9, 2021
cc1e98e
• composition.py
jdcpni Nov 9, 2021
a00b95f
• composition.py:
jdcpni Nov 10, 2021
ed0a720
-
jdcpni Nov 10, 2021
cb0b930
• optimizationcontrolmechanism.py:
jdcpni Nov 10, 2021
8cadf24
-
jdcpni Nov 10, 2021
1cc216e
• optimizationcontrolmechanism.py:
jdcpni Nov 10, 2021
ba278c1
-
jdcpni Nov 10, 2021
b5f1c66
-
jdcpni Nov 10, 2021
0e38f1b
Merge branch 'devel' of https://github.com/PrincetonUniversity/PsyNeu…
jdcpni Nov 10, 2021
b4a9b82
• optimizationcontrolmechanism.py
jdcpni Nov 10, 2021
2050118
-
Nov 10, 2021
b925dab
• optimizationcontrolmechanism.py
jdcpni Nov 11, 2021
bdb12fb
Merge branch 'refactor/ocm/state_input_ports' of https://github.com/P…
jdcpni Nov 11, 2021
c1b3000
• optimizationcontrolmechanism.py
jdcpni Nov 11, 2021
7ca8a0b
-
jdcpni Nov 11, 2021
d1010fd
-
jdcpni Nov 11, 2021
e57cd2d
Merge branch 'devel' of https://github.com/PrincetonUniversity/PsyNeu…
jdcpni Nov 11, 2021
0ff99ec
Merge branch 'fix/ocm/llvm_num_estimates' into refactor/ocm/state_inp…
jdcpni Nov 11, 2021
3607a9a
-
jdcpni Nov 11, 2021
6017b7b
-
jdcpni Nov 11, 2021
2395f7e
• composition.py
jdcpni Nov 11, 2021
f317567
• composition.py
jdcpni Nov 11, 2021
8edacf6
llvm/struct generation: Make sure num_estimats per trial is always in…
jvesely Nov 11, 2021
8ed5e87
-
jdcpni Nov 11, 2021
bcfbae9
Merge branch 'fix/ocm/llvm_num_estimates' into refactor/ocm/state_inp…
jdcpni Nov 11, 2021
8a564aa
Merge branch 'devel' of https://github.com/PrincetonUniversity/PsyNeu…
jdcpni Nov 11, 2021
883b49d
• composition.py:
jdcpni Nov 12, 2021
d2faa86
-
jdcpni Nov 12, 2021
a632f72
• composition.py
jdcpni Nov 12, 2021
0e1a32e
• test_control.py
jdcpni Nov 12, 2021
1d996fb
Merge branch 'devel' of https://github.com/PrincetonUniversity/PsyNeu…
jdcpni Nov 12, 2021
cbe6d24
Merge branch 'devel' of https://github.com/PrincetonUniversity/PsyNeu…
jdcpni Nov 12, 2021
3856bdd
• optimizationfunctions.py:
jdcpni Nov 12, 2021
0eb6514
Merge branch 'refactor/ocm/state_input_ports' of https://github.com/P…
jdcpni Nov 12, 2021
4b2fe4a
-
jdcpni Nov 13, 2021
d580849
• composition.py
jdcpni Nov 13, 2021
79b6ed6
-
jdcpni Nov 15, 2021
1a5dd50
Merge branch 'devel' of https://github.com/PrincetonUniversity/PsyNeu…
jdcpni Nov 15, 2021
34b179e
• composition.py:
jdcpni Nov 15, 2021
dff750a
• composition.py:
jdcpni Nov 16, 2021
38e5bae
Merge branch 'refactor/ocm/state_input_ports' of https://github.com/P…
jdcpni Nov 16, 2021
d487a4c
• composition.py
jdcpni Nov 16, 2021
779add6
-
jdcpni Nov 16, 2021
5c361e2
• composition.py:
jdcpni Nov 17, 2021
0c2de6a
-
jdcpni Nov 17, 2021
a7436db
Merge branch 'devel' of https://github.com/PrincetonUniversity/PsyNeu…
jdcpni Nov 17, 2021
27b2d76
-
jdcpni Nov 17, 2021
0981388
-
jdcpni Nov 17, 2021
698d824
-
jdcpni Nov 17, 2021
900da17
-
jdcpni Nov 17, 2021
aa5a431
-
jdcpni Nov 17, 2021
780be92
-
jdcpni Nov 17, 2021
fa4e038
Merge branch 'refactor/ocm/state_input_ports' of https://github.com/P…
jdcpni Nov 17, 2021
af135d6
-
jdcpni Nov 17, 2021
f13747a
• Passing all test_control tests except test_mode_based_num_estimates
jdcpni Nov 17, 2021
eff7005
• Passing all test_control tests
jdcpni Nov 17, 2021
ea1465e
-
jdcpni Nov 17, 2021
1c39268
• optimizationcontrolmechanism.py
jdcpni Nov 18, 2021
a7f7cf4
-
jdcpni Nov 18, 2021
7a6b5a7
• optimizationcontrolmechanism.py
jdcpni Nov 18, 2021
11cf225
• test_show_graph.py: passes all tests
jdcpni Nov 18, 2021
72b922a
-
jdcpni Nov 18, 2021
b6e697e
• test_report.py: passing all tests
Nov 18, 2021
1609acc
• Passes all tests!
Nov 18, 2021
b889604
-
jdcpni Nov 19, 2021
c4b081e
Merge branch 'refactor/ocm/state_input_ports' of https://github.com/P…
jdcpni Nov 19, 2021
47a757a
-
Nov 19, 2021
78f4ec6
Merge branch 'refactor/ocm/state_input_ports' of https://github.com/P…
jdcpni Nov 19, 2021
faaf256
• composition.py: reorganize with #region and #enregions
jdcpni Nov 19, 2021
fb9c424
• composition.py: reorganize with #region and #enregions
jdcpni Nov 19, 2021
0c96840
• controlmechanism.py, optimizationcontrolmechanism.py:
jdcpni Nov 19, 2021
d40082c
-
jdcpni Nov 19, 2021
1630f87
-
jdcpni Nov 19, 2021
a76a2d0
-
jdcpni Nov 19, 2021
b1f9778
• controlmechanism.py, optimizationcontrolmechanism.py:
jdcpni Nov 19, 2021
451abb3
• controlmechanism.py, optimizationcontrolmechanism.py:
jdcpni Nov 19, 2021
304174e
-
jdcpni Nov 20, 2021
428eed8
• composition.py:
Nov 20, 2021
5c71808
-
jdcpni Nov 20, 2021
3733ea9
- test_control: only test_hanging_control_spec_outer_controller not p…
jdcpni Nov 20, 2021
5851949
-
Nov 20, 2021
e8909b7
-
Nov 20, 2021
2018260
-
Nov 20, 2021
98be7a0
-
jdcpni Nov 20, 2021
636b7c7
-
jdcpni Nov 20, 2021
f3a857a
-
jdcpni Nov 20, 2021
2552f73
• composition.py:
jdcpni Nov 20, 2021
c02735e
• test_paremtercomposition.py:
jdcpni Nov 20, 2021
8568b47
ª Attempt to fix problem with partially overlapping local and ocm con…
jdcpni Nov 21, 2021
1aadd6d
see later commit
jdcpni Nov 21, 2021
da80ad6
see later commit
jdcpni Nov 21, 2021
fa1683f
see later commit
jdcpni Nov 21, 2021
8dee921
see later commit
jdcpni Nov 21, 2021
d17b5cd
- This branch passes all tests except:
jdcpni Nov 21, 2021
2503dfc
- small mods; don't impact anything relevant to prior commit message
jdcpni Nov 21, 2021
6cf4609
- small mods; don't impact anything relevant to prior commit message
jdcpni Nov 21, 2021
cdb6399
- small mods; don't impact anything relevant to prior commit message
jdcpni Nov 21, 2021
5cf0bc2
- finished adding formatting regions to composition.py
jdcpni Nov 21, 2021
46ccc47
-
jdcpni Nov 21, 2021
2b3b857
• composition.py:
jdcpni Nov 21, 2021
bd5cd10
• show_graph.py: addressed bug associated with ocm.allow_direct_probe
jdcpni Nov 22, 2021
6d894a7
• show_graph.py: addressed bug associated with ocm.allow_direct_probe
jdcpni Nov 22, 2021
689d7b6
-
jdcpni Nov 22, 2021
bcddef5
Composition: add_controller: set METHOD as context source early
kmantel Nov 23, 2021
7fd49c6
-
jdcpni Nov 23, 2021
35c97d3
Merge branch 'refactor/ocm/state_input_ports_PROBE_FIX' of https://gi…
jdcpni Nov 23, 2021
79cb012
• composition.py
jdcpni Nov 24, 2021
9bc7b18
• composition.py
jdcpni Nov 24, 2021
0f93f47
• test_partially_overlapping_local_and_control_mech_control_specs_in_…
Nov 25, 2021
47b56b2
Merge branch 'devel' of https://github.com/PrincetonUniversity/PsyNeu…
jdcpni Nov 25, 2021
81f1112
• composition.py
jdcpni Nov 25, 2021
0cd9db3
• composition.py
jdcpni Nov 25, 2021
c808664
• composition.py
jdcpni Nov 25, 2021
0cb21ab
-
jdcpni Nov 25, 2021
28289a0
- confirm that it passes all tests exception test_composition/test_pa…
Nov 25, 2021
1cf9602
• composition.py: some more fixed to add_controller that now fail on…
jdcpni Nov 25, 2021
72c4c41
• Passes *all* current tests
jdcpni Nov 25, 2021
45b25eb
• composition.py:
Nov 25, 2021
a79723b
-
Nov 25, 2021
49350a1
-
jdcpni Nov 26, 2021
f7b9fc5
Merge branch 'devel' of https://github.com/PrincetonUniversity/PsyNeu…
jdcpni Nov 26, 2021
7a6682a
-
jdcpni Nov 26, 2021
8858ab5
• controlmechanism.py:
jdcpni Nov 26, 2021
d1ac2da
-
jdcpni Nov 26, 2021
dbdc2d1
• composition.py: in progress fix of bug in instantiating shadow pro…
jdcpni Nov 27, 2021
6b00fbd
• composition.py:
jdcpni Nov 27, 2021
179e7d0
• optimizationcontrolmechanism.py
jdcpni Nov 27, 2021
88ce1a6
-
jdcpni Nov 27, 2021
5089cf3
• composition.py
jdcpni Nov 27, 2021
97a71c4
• test_show_graph.py: update for fixes
Nov 27, 2021
3bc799e
-
Nov 27, 2021
6a27e4a
• tests: passes all in test_show_graph.py and test_report.py
Nov 27, 2021
8cdad10
Passes all tests
Nov 27, 2021
2d15f6d
- comment clean-up
Nov 27, 2021
787856b
• composition.py
jdcpni Nov 27, 2021
3ed598e
• composition.py, optimizationcontrolmechanism.py:
Nov 28, 2021
38e5f99
• show_graph.py: fixed bug causing extra projections to OCM
jdcpni Nov 28, 2021
658c161
• composition.py:
jdcpni Nov 28, 2021
7396806
Merge branch 'devel' of https://github.com/PrincetonUniversity/PsyNeu…
jdcpni Nov 28, 2021
8b54f03
• optimizationcontrolmechanism.py: add agent_rep_type property
jdcpni Nov 28, 2021
1ecf0fa
• optimizationcontrolmechanism.py:
jdcpni Nov 28, 2021
24a03f3
• optimizationcontrolmechanism.py:
jdcpni Nov 29, 2021
6713df9
-
jdcpni Nov 29, 2021
8b3bdf0
-
jdcpni Nov 29, 2021
d001991
• Passes all tests except test_json with 'model_with_control'
jdcpni Nov 29, 2021
888863a
-
jdcpni Nov 30, 2021
6fb5cf6
• composition.py
jdcpni Nov 30, 2021
c1fd334
• composition.py
jdcpni Nov 30, 2021
00e7da9
• composition.py
jdcpni Nov 30, 2021
77ae108
-
jdcpni Nov 30, 2021
774f6b3
• test_two_origins_two_input_ports: crashes on failure of C->B to up…
jdcpni Nov 30, 2021
c4fedbe
-
jdcpni Nov 30, 2021
e29f618
• composition.py
Dec 1, 2021
d551e9d
• optimizationcontrolmechanism.py
jdcpni Dec 1, 2021
66c05f7
• optimizationcontrolmechanism.py
jdcpni Dec 1, 2021
a401857
• composition.py
jdcpni Dec 1, 2021
a91695e
• composition.py
jdcpni Dec 1, 2021
48012a3
Port: _remove_projection_to_port: don't reduce variable below length 1
kmantel Dec 1, 2021
cb828c8
• composition.py
jdcpni Dec 1, 2021
c6853b6
• show_graph.py
jdcpni Dec 2, 2021
d11e117
• composition.py:
jdcpni Dec 2, 2021
756c076
• show_graph.py
jdcpni Dec 2, 2021
f9924f3
• composition.py
jdcpni Dec 2, 2021
944d214
• composition.py
jdcpni Dec 2, 2021
546378b
• composition.py:
jdcpni Dec 2, 2021
67dd8c7
Merge branch 'refactor/ocm/state_input_ports_PROBE_STATE_FEAT_FCT' of…
jdcpni Dec 2, 2021
7de2c62
• show_graph.py
jdcpni Dec 2, 2021
d4ee355
Merge branch 'refactor/ocm/state_input_ports_PROBE_STATE_FEAT_FCT' of…
jdcpni Dec 2, 2021
be76389
-
jdcpni Dec 2, 2021
399d1f7
• composition.py
jdcpni Dec 2, 2021
bc47b76
-
jdcpni Dec 2, 2021
4afdf0a
-
jdcpni Dec 2, 2021
7423d37
• test_composition.py
jdcpni Dec 2, 2021
4134cde
Merge branch 'refactor/ocm/state_input_ports_PROBE_STATE_FEAT_FCT' of…
jdcpni Dec 2, 2021
de80376
Merge branch 'devel' of https://github.com/PrincetonUniversity/PsyNeu…
jdcpni Dec 2, 2021
4e63090
-
jdcpni Dec 2, 2021
552fc04
-
jdcpni Dec 3, 2021
24a7340
-
jdcpni Dec 3, 2021
1cca7d6
-
jdcpni Dec 3, 2021
9d07c46
Merge branch 'devel' of https://github.com/PrincetonUniversity/PsyNeu…
jdcpni Dec 3, 2021
a9ff72c
• optimizationcontrolmechanism.py: docstring mods
jdcpni Dec 3, 2021
91a4fbe
Merge branch 'devel' of https://github.com/PrincetonUniversity/PsyNeu…
jdcpni Dec 3, 2021
eed7e89
Merge branch 'refactor/ocm/state_input_ports' into devel
jdcpni Dec 3, 2021
c5cad39
• optimizationcontrolmechanism.py
jdcpni Dec 3, 2021
860d793
• optimizationcontrolmechanism.py: docstring mods
jdcpni Dec 4, 2021
40f10e0
• optimizationcontrolmechanism.py:
jdcpni Dec 4, 2021
4f2b23b
• composition.py
jdcpni Dec 4, 2021
cfe79c0
• optimizationcontrolmechanism.py
jdcpni Dec 4, 2021
d857e64
• optimizationcontrolmechanism.py
jdcpni Dec 4, 2021
fe28f55
• optimizationcontrolmechanism.py
jdcpni Dec 4, 2021
fd46b75
• test_control.py
jdcpni Dec 4, 2021
915993e
• test_control.py
jdcpni Dec 4, 2021
dd6c5db
-
jdcpni Dec 4, 2021
4173563
-
jdcpni Dec 4, 2021
af719d1
-
jdcpni Dec 5, 2021
eb7bfcf
• optimizationcontrolmechanism.py
jdcpni Dec 5, 2021
1a7e391
-
jdcpni Dec 5, 2021
e28086c
-
jdcpni Dec 5, 2021
ce03b2f
-
Dec 5, 2021
d0e5d72
Merge branch 'misc/ocm/docs_and_tests' of https://github.com/Princeto…
Dec 5, 2021
bcf0bcf
• optimizationcontrolmechanism.py: docstring mods
Dec 5, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -630,9 +630,9 @@ def _is_control_spec(spec):
return False

class ControlMechanismError(Exception):
def __init__(self, error_value):
def __init__(self, error_value, data=None):
self.error_value = error_value

self.data = data

def validate_monitored_port_spec(owner, spec_list):
for spec in spec_list:
Expand Down Expand Up @@ -1620,6 +1620,22 @@ def _parse_monitor_for_control_input_ports(self, context):

return outcome_input_port_specs, port_value_sizes, monitored_ports

def _validate_monitor_for_control(self, nodes):
# Ensure all of the Components being monitored for control are in the Composition being controlled
from psyneulink.core.components.ports.port import Port
invalid_outcome_specs = [item for item in self.monitor_for_control
if ((isinstance(item, Mechanism)
and item not in nodes)
or ((isinstance(item, Port)
and item.owner not in nodes)))]
if invalid_outcome_specs:
names = [item.name if isinstance(item, Mechanism) else item.owner.name
for item in invalid_outcome_specs]
raise ControlMechanismError(f"{self.name} has 'outcome_ouput_ports' that receive "
f"Projections from the following Components that do not "
f"belong to the Composition it controls: {names}.",
names)

def _instantiate_output_ports(self, context=None):

# ---------------------------------------------------
Expand Down Expand Up @@ -1793,7 +1809,6 @@ def _check_for_duplicates(self, control_signal, control_signals, context):
f"has one or more {projection_type.__name__}s redundant with ones already on "
f"an existing {ControlSignal.__name__} ({existing_ctl_sig.name}).")


def show(self):
"""Display the OutputPorts monitored by ControlMechanism's `objective_mechanism
<ControlMechanism.objective_mechanism>` and the parameters modulated by its `control_signals
Expand Down Expand Up @@ -1894,7 +1909,8 @@ def _activate_projections_for_compositions(self, composition=None):
# and will therefore be added to the Composition along with the ControlMechanism
from psyneulink.core.compositions.composition import NodeRole
assert (self.objective_mechanism, NodeRole.CONTROL_OBJECTIVE) in self.aux_components, \
f"PROGRAM ERROR: {OBJECTIVE_MECHANISM} for {self.name} not listed in its 'aux_components' attribute."
f"PROGRAM ERROR: {OBJECTIVE_MECHANISM} for {self.name} " \
f"not listed in its 'aux_components' attribute."
dependent_projections.add(self._objective_projection)
# Add all Projections to and from objective_mechanism
for aff in self.objective_mechanism.afferents:
Expand Down

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions psyneulink/core/components/ports/inputport.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,21 @@
list. In other words, for each InputPort specified, a new one is created that receives exactly the same inputs
from the same `senders <Projection_Base.sender>` as the ones specified.

If an InputPort shadows another, its `shadow_inputs <InputPort.shadow_inputs>` attribute identifies the InputPort
that it shadows.

.. note::
Only InputPorts belonging to Mechanisms in the *same Composition*, or ones that are `INPUT <NodeRole.INPUT>`
`Nodes <Composition_Nodes>` of a `nested <Composition_Nested>` can be specified for shadowing.

.. hint::
If an InputPort needs to be shadowed that belongs to a Mechanism in a `nested <Composition_Nested>` that is
not an `INPUT <NodeRole.INPUT>` `Node <Composition_Nodes>` of that Composition, this can be accomplished as
follows: 1) add a Mechanism to the nested Composition with an InputPort that shadows the one to be
shadowed; 2) specify `OUTPUT <NodeRole.INPUT>` as a `required_role <Composition.add_node.required_roles>`
for that Mechanism; 3) use that Mechanism as the `InputPort specification <InputPort_Specification>`
for the shadowing InputPort.

.. _InputPort_Compatability_and_Constraints:

InputPort `variable <InputPort.variable>`: Compatibility and Constraints
Expand Down Expand Up @@ -659,6 +674,9 @@ class InputPort(Port_Base):
<Port.owner>` is an `INPUT` `Node <Composition_Nodes>` of that Composition; if `True`, external input is
*not* required or allowed.

shadow_inputs : InputPort
identifies the InputPort of another `Mechanism` that is being shadowed by this InputPort.

name : str
the name of the InputPort; if it is not specified in the **name** argument of the constructor, a default is
assigned by the InputPortRegistry of the Mechanism to which the InputPort belongs. Note that some Mechanisms
Expand Down
19 changes: 15 additions & 4 deletions psyneulink/core/compositions/composition.py
Original file line number Diff line number Diff line change
Expand Up @@ -3165,7 +3165,7 @@ class Composition(Composition_Base, metaclass=ComponentsMeta):

controller_time_scale: TimeScale[TIME_STEP, PASS, TRIAL, RUN] : default TRIAL
deterines the frequency at which the `controller <Composition.controller>` is executed, either before or
after the Composition as determined by `controller_mode <cComposition.ontroller_mode>` (see
after the Composition as determined by `controller_mode <Composition.ontroller_mode>` (see
`Composition_Controller_Execution` for additional details).

controller_condition : Condition
Expand Down Expand Up @@ -3909,6 +3909,12 @@ def _get_nested_compositions(self,
visited_compositions)
return nested_compositions

def _get_all_nodes(self):
"""Return all nodes, including those within nested Compositions at any level
Note: this is distinct from the _all_nodes propety, which returns all nodes at the top level
"""
return [k[0] for k in self._get_nested_nodes()] + list(self.nodes)

def _determine_origin_and_terminal_nodes_from_consideration_queue(self):
"""Assigns NodeRole.ORIGIN to all nodes in the first entry of the consideration queue and NodeRole.TERMINAL
to all nodes in the last entry of the consideration queue. The ObjectiveMechanism of a Composition's
Expand Down Expand Up @@ -4106,6 +4112,7 @@ def _complete_init_of_partially_initialized_nodes(self, context=None):
if hasattr(self.controller, 'state_input_ports'):
self.controller._update_state_input_ports_for_controller(context=context)
# self._instantiate_controller_shadow_projections(context=context)
self.controller._validate_monitor_for_control(self._get_all_nodes())
self._instantiate_control_projections(context=context)
# FIX: 11/15/21 - CAN'T SET TO FALSE HERE, AS THIS IS CALLED BY _analyze_graph() FROM add_node()
# BEFORE PROJECTIONS TO THE NODE HAS BEEN ADDED (AFTER CALL TO add_node())
Expand Down Expand Up @@ -5384,9 +5391,10 @@ def _get_correct_sender(comp, shadowed_projection):
def _get_sender_at_right_level(shadowed_proj):
"""Search back up hierarchy of nested Compositions for sender at same level as **input_port**"""
if not isinstance(shadowed_proj.sender.owner, CompositionInterfaceMechanism):
raise CompositionError(f"Attempt to shadow the input(s) to a node "
raise CompositionError(f"Attempt to shadow the input to a node "
f"({shadowed_proj.receiver.owner.name}) in a nested Composition "
f"(of {self.name}) is not currently supported.")
f"of {self.name} that is not an INPUT Node of that Composition is "
f"not currently supported.")
else:
# WANT THIS ONE'S SENDER
# item[0] item[1,0] item[1,1]
Expand Down Expand Up @@ -7182,6 +7190,7 @@ def add_controller(self, controller:ControlMechanism, context=None):
if self.controller.objective_mechanism:
# If controller has objective_mechanism, then add it and all associated Projections to Composition
if self.controller.objective_mechanism not in invalid_aux_components:
self.controller._validate_monitor_for_control(self._get_all_nodes())
self.add_node(self.controller.objective_mechanism, required_roles=NodeRole.CONTROLLER_OBJECTIVE)
else:
# Otherwise, if controller has any afferent inputs (from items in monitor_for_control), add them
Expand All @@ -7205,7 +7214,9 @@ def add_controller(self, controller:ControlMechanism, context=None):
keep_checking = True
# Otherwise, return usual error
else:
raise CompositionError(e.error_value)
error_msg = e.error_value + f" Try setting 'allow_probes' argument of " \
f"{self.controller.name} to True."
raise CompositionError(error_msg)
else:
assert False, f"PROGRAM ERROR: Unable to apply NodeRole.OUTPUT to {node} of {nested_comp} "\
f"specified in 'monitor_for_control' arg for {controller.name} of {self.name}"
Expand Down
14 changes: 6 additions & 8 deletions psyneulink/core/globals/keywords.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@
'MECHANISM_DEFAULTParams', 'MECHANISM_EXECUTED_LOG_ENTRY', 'MECHANISM_NAME', 'MECHANISM_PARAM_VALUE',
'MECHANISM_TYPE', 'MECHANISM_VALUE', 'MEDIAN', 'METRIC', 'MIN_VAL', 'MIN_ABS_VAL', 'MIN_ABS_INDICATOR',
'MODE', 'MODULATES','MODULATION', 'MODULATORY_PROJECTION', 'MODULATORY_SIGNAL', 'MODULATORY_SIGNALS',
'MONITOR', 'MONITOR_FOR_CONTROL', 'MONITOR_FOR_LEARNING', 'MONITOR_FOR_MODULATION', 'MODEL_FREE', 'MODEL_BASED',
'MODEL_SPEC_ID_GENERIC', 'MODEL_SPEC_ID_INPUT_PORTS', 'MODEL_SPEC_ID_OUTPUT_PORTS', 'MODEL_SPEC_ID_PSYNEULINK',
'MODEL_SPEC_ID_SENDER_MECH', 'MODEL_SPEC_ID_SENDER_PORT', 'MODEL_SPEC_ID_RECEIVER_MECH',
'MODEL_SPEC_ID_RECEIVER_PORT',
'MODEL_SPEC_ID_PARAMETER_SOURCE', 'MODEL_SPEC_ID_PARAMETER_VALUE', 'MODEL_SPEC_ID_TYPE', 'MSE',
'MULTIPLICATIVE', 'MULTIPLICATIVE_PARAM', 'MUTUAL_ENTROPY',
'MONITOR', 'MONITOR_FOR_CONTROL', 'MONITOR_FOR_LEARNING', 'MONITOR_FOR_MODULATION',
'MODEL_SPEC_ID_GENERIC', 'MODEL_SPEC_ID_INPUT_PORTS', 'MODEL_SPEC_ID_OUTPUT_PORTS',
'MODEL_SPEC_ID_PSYNEULINK', 'MODEL_SPEC_ID_SENDER_MECH', 'MODEL_SPEC_ID_SENDER_PORT',
'MODEL_SPEC_ID_RECEIVER_MECH', 'MODEL_SPEC_ID_RECEIVER_PORT','MODEL_SPEC_ID_PARAMETER_SOURCE',
'MODEL_SPEC_ID_PARAMETER_VALUE', 'MODEL_SPEC_ID_TYPE',
'MSE', 'MULTIPLICATIVE', 'MULTIPLICATIVE_PARAM', 'MUTUAL_ENTROPY',
'NAME', 'NESTED', 'NEWEST', 'NODE', 'NOISE', 'NORMAL_DIST_FUNCTION', 'NORMED_L0_SIMILARITY', 'NOT_EQUAL',
'NUM_EXECUTIONS_BEFORE_FINISHED',
'OBJECTIVE_FUNCTION_TYPE', 'OBJECTIVE_MECHANISM', 'OBJECTIVE_MECHANISM_OBJECT', 'OFF', 'OFFSET', 'OLDEST', 'ON',
Expand Down Expand Up @@ -776,8 +776,6 @@ def _is_metric(metric):
SAVE_ALL_VALUES_AND_POLICIES = 'save_all_values_and_policies'
EVC_SIMULATION = 'CONTROL SIMULATION'
ALLOCATION_SAMPLES = "allocation_samples"
MODEL_FREE = 'model_free'
MODEL_BASED = 'model_based'

# GatingMechanism
GATING_SIGNALS = 'gating_signals'
Expand Down
2 changes: 1 addition & 1 deletion psyneulink/library/compositions/regressioncfa.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ class RegressionCFA(CompositionFunctionApproximator):
regression_weights : 1d array
result returned by `update_weights <RegressionCFA.update_weights>, and used by
`evaluate <RegressionCFA.evaluate>` method together with `prediction_vector <RegressionCFA.prediction_vector>`
to generate predicted `net_outcome <OptimizationControlMechanism.net_outcome>`.
to generate predicted `net_outcome <ControlMechanism.net_outcome>`.

"""

Expand Down
5 changes: 3 additions & 2 deletions tests/composition/test_composition.py
Original file line number Diff line number Diff line change
Expand Up @@ -5907,8 +5907,9 @@ def test_shadow_nested_nodes(self, condition):
with pytest.raises(CompositionError) as err:
O = ProcessingMechanism(name='O',input_ports=[B.input_port])
ocomp = Composition(nodes=[mcomp,O], name='OUTER COMP')
assert 'Attempt to shadow the input(s) to a node (B) in a nested Composition ' \
'(of OUTER COMP) is not currently supported.' in err.value.error_value
assert 'Attempt to shadow the input to a node (B) in a nested Composition of OUTER COMP ' \
'that is not an INPUT Node of that Composition is not currently supported.' \
in err.value.error_value

def test_monitor_input_ports(self):
comp = Composition(name='comp')
Expand Down
Loading