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

Refactor/ocm/state features all as input ports #2359

Merged
merged 396 commits into from
Mar 25, 2022

Conversation

jdcpni
Copy link
Collaborator

@jdcpni jdcpni commented Mar 25, 2022

• optimizationcontrolmechanism.py:

  • fix bug in which state_feature_default = None was being ignored
  • fix bug in which deferred nodes were not being assigned state_feature_default

• test_control.py:

  • test_deferred_init, test_partial_deferred_init():
    added tests for controller.state_input_ports path_afferents

jdcpni and others added 30 commits November 30, 2021 15:58
  - added property shadowing_dict that has shadowing ports as keys and the ports they shadow as values
  - refactored _update_shadowing_projections to use shadowing_dict
  - _update_state_input_ports:  modified validations for nested nodes;  still failing some tests
  - _update_state_input_ports:
     more careful and informative validation that state_input_ports are in comp or nested comp and are INPUT nodes thereof;
     passes all tests except test_two_origins_two_input_ports as before
  _get_invalid_aux_components():  defer all shadow projections until _update_shadow_projections
  _get_invalid_aux_components():  bug fix in test for shadow projections
even ports with no incoming projections have variable at least length 1
  add_node(): marked (but haven't removed) code block instantiating shadow_projections
   that seems now to be redundant with _update_shadow_projection
  - _assign_cim_components: supress showing projections not in composition
  _analyze_graph():  add extra call to _determine_node_roles after _update_shadow_projections
  _run():  moved block of code at beginning initializing scheduler to after
           _complete_init_of_partially_initialized_nodes and _analyze_graph()

• show_graph.py
  - add test to all loops on projections:  "if proj in composition.projection"
  - add show_projections_not_in_composition option for debugging
  _update_shadow_projections(): delete unused shadow projections and corresponding ports
  _update_shadow_projections(): fix bug in deletion of unused shadow projections and ports

• test_show_graph:  tests failing, need mods to accomodate changes
  _analyze_graph():  add extra call to _determine_node_roles after _update_shadow_projections
  _run():  moved block of code at beginning initializing scheduler to after
           _complete_init_of_partially_initialized_nodes and _analyze_graph()

• show_graph.py
  - add test to all loops on projections:  "if proj in composition.projection"
  fixes; now passes all show_graph tests
  _update_shadow_projections:  raise error for attempt to shadow INTERNAL Node of nested comp
  implemented test_shadow_nested_nodes that tests shadowing of nested nodes
…ttps://github.com/PrincetonUniversity/PsyNeuLink into refactor/ocm/state_input_ports_PROBE_STATE_FEAT_FCT

� Conflicts:
�	tests/composition/test_show_graph.py
…Link into refactor/ocm/state_input_ports_PROBE_STATE_FEAT_FCT

� Conflicts:
�	tests/composition/test_show_graph.py
  add _is_in_composition method
…Link into refactor/ocm/state_features_all_as_input_ports
…nto refactor/ocm/state_features_all_as_input_ports
…Link into refactor/ocm/state_features_all_as_input_ports
…Link into refactor/ocm/state_features_all_as_input_ports
  - fix bug in which state_feature_default = None was being ignored
  - fix bug in which deferred nodes were not being assigned state_feature_default
  - fix bug in which state_feature_default = None was being ignored
  - fix bug in which deferred nodes were not being assigned state_feature_default
  - test_deferred_init, test_partial_deferred_init():
    added tests for controller.state_input_ports path_afferents
@github-actions
Copy link

This PR causes the following changes to the html docs (ubuntu-latest-3.7-x64):

diff -r docs-base/OptimizationControlMechanism.html docs-head/OptimizationControlMechanism.html
352c352,353
< <figure class="align-default" id="id7">
---
> <blockquote>
> <div><figure class="align-default" id="id7">
364a366
> </div></blockquote>
458c460
< <ul class="simple" id="optimizationcontrolmechanism-state-feature-input-dict">
---
> <ul class="simple" id="optimizationcontrolmechanism-state-feature-single-spec">
461a464,465
> </ul>
> <ul class="simple" id="optimizationcontrolmechanism-state-feature-input-dict">
482,491c486,494
< <li><p><em>List</em> – a list of individual state_feature specifications, that can be any of the forms of individual input
< specifications listed <a class="reference internal" href="#optimizationcontrolmechanism-state-feature-individual-specs"><span class="std std-ref">below</span></a>. The items correspond
< to all of the <a class="reference internal" href="Composition.html#composition-input-external-inputports"><span class="std std-ref">external InputPorts</span></a> of the <a class="reference internal" href="#psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.agent_rep" title="psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.agent_rep"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">agent_rep</span></code></a>, and must be specified in the order they are listed in the <a class="reference internal" href="#psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.agent_rep" title="psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.agent_rep"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">agent_rep</span></code></a>'s <a class="reference internal" href="Composition.html#psyneulink.core.compositions.composition.Composition.external_input_ports_of_all_input_nodes" title="psyneulink.core.compositions.composition.Composition.external_input_ports_of_all_input_nodes"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">external_input_ports_of_all_input_nodes</span></code></a> attribute. If the list is incomplete, the remaining
< InputPorts are assigned <a class="reference internal" href="#psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.state_feature_default" title="psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.state_feature_default"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">state_feature_default</span></code></a> as their
< state_feature specification. Items can be included in the list that have not yet been added to the
< OptimizationControlMechanism’s Composition or its <a class="reference internal" href="#psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.agent_rep" title="psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.agent_rep"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">agent_rep</span></code></a>. However,
< these must be added before the Composition is executed, and must appear in the list in the same position that the
< InputPorts to which they pertain are listed in the <a class="reference internal" href="#psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.agent_rep" title="psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.agent_rep"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">agent_rep</span></code></a>'s
< <a class="reference internal" href="Composition.html#psyneulink.core.compositions.composition.Composition.external_input_ports_of_all_input_nodes" title="psyneulink.core.compositions.composition.Composition.external_input_ports_of_all_input_nodes"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">external_input_ports_of_all_input_nodes</span></code></a> attribute,
< once construction of the <a class="reference internal" href="#psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.agent_rep" title="psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.agent_rep"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">agent_rep</span></code></a> is complete.</p></li>
---
> <li><p><em>List</em> – a list of individual state_feature specifications, that can be any of the forms of individual
> input specifications listed <a class="reference internal" href="#optimizationcontrolmechanism-state-feature-individual-specs"><span class="std std-ref">below</span></a>. The items
> correspond to all of the <a class="reference internal" href="Composition.html#composition-input-external-inputports"><span class="std std-ref">external InputPorts</span></a> of the <a class="reference internal" href="#psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.agent_rep" title="psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.agent_rep"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">agent_rep</span></code></a>, and must be specified in the order they are listed in the
> <a class="reference internal" href="#psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.agent_rep" title="psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.agent_rep"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">agent_rep</span></code></a>'s <a class="reference internal" href="Composition.html#psyneulink.core.compositions.composition.Composition.external_input_ports_of_all_input_nodes" title="psyneulink.core.compositions.composition.Composition.external_input_ports_of_all_input_nodes"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">external_input_ports_of_all_input_nodes</span></code></a> attribute. If the list is incomplete, the remaining
> InputPorts are assigned <a class="reference internal" href="#psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.state_feature_default" title="psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.state_feature_default"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">state_feature_default</span></code></a>
> as their state_feature specification, which by default is <em>SHADOW_INPUTS</em> (see <a class="reference internal" href="#optimizationcontrolmechanism-shadow-inputs-state-feature"><span class="std std-ref">below</span></a>. Items can be included in the list that
> have not yet been added to the OptimizationControlMechanism’s Composition or its <a class="reference internal" href="#psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.agent_rep" title="psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.agent_rep"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">agent_rep</span></code></a>. However, these must be added before the Composition is executed,
> and must appear in the list in the same position that the InputPorts to which they pertain are listed in
> the <a class="reference internal" href="#psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.agent_rep" title="psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.agent_rep"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">agent_rep</span></code></a>'s <a class="reference internal" href="Composition.html#psyneulink.core.compositions.composition.Composition.external_input_ports_of_all_input_nodes" title="psyneulink.core.compositions.composition.Composition.external_input_ports_of_all_input_nodes"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">external_input_ports_of_all_input_nodes</span></code></a> attribute, once construction of the <a class="reference internal" href="#psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.agent_rep" title="psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.agent_rep"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">agent_rep</span></code></a> is complete.</p></li>
494,498c497,505
< <li><p><em>Set</em> – a set of <a class="reference internal" href="Composition.html#psyneulink.core.compositions.composition.NodeRole.INPUT" title="psyneulink.core.compositions.composition.NodeRole.INPUT"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">INPUT</span></code></a> <a class="reference internal" href="Composition.html#composition-nodes"><span class="std std-ref">Nodes</span></a> of the <a class="reference internal" href="#psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.agent_rep" title="psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.agent_rep"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">agent_rep</span></code></a> that are assigned <em>SHADOW_INPUTS</em> as their state_feature (see <code class="xref any docutils literal notranslate"><span class="pre">below</span></code>); that is, that should receive the same inputs
< during evaluation as when the Composition of which the OptimizationControlMechanism is the <a class="reference internal" href="Composition.html#composition-controller"><span class="std std-ref">controller</span></a> is fully executed. The order of their specification does not matter;  however, any of
< the <a class="reference internal" href="#psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.agent_rep" title="psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.agent_rep"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">agent_rep</span></code></a>'s <a class="reference internal" href="Composition.html#psyneulink.core.compositions.composition.NodeRole.INPUT" title="psyneulink.core.compositions.composition.NodeRole.INPUT"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">INPUT</span></code></a> Nodes that are <em>not</em> included
< in the set are assigned <a class="reference internal" href="#psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.state_feature_default" title="psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.state_feature_default"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">state_feature_default</span></code></a> as their
< state_feature specification.</p></li>
---
> <li><p><em>Set</em> – a set of <a class="reference internal" href="Composition.html#psyneulink.core.compositions.composition.NodeRole.INPUT" title="psyneulink.core.compositions.composition.NodeRole.INPUT"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">INPUT</span></code></a> <a class="reference internal" href="Composition.html#composition-nodes"><span class="std std-ref">Nodes</span></a> of the <a class="reference internal" href="#psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.agent_rep" title="psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.agent_rep"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">agent_rep</span></code></a> that are assigned <em>SHADOW_INPUTS</em> as their state_feature
> – that is, that should receive the same inputs during evaluation as when the Composition of which
> the OptimizationControlMechanism is the <a class="reference internal" href="Composition.html#composition-controller"><span class="std std-ref">controller</span></a> is fully executed
> (see <code class="xref any docutils literal notranslate"><span class="pre">below</span></code>). The order of their specification
> does not matter;  however, any of the <a class="reference internal" href="#psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.agent_rep" title="psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.agent_rep"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">agent_rep</span></code></a>'s <a class="reference internal" href="Composition.html#psyneulink.core.compositions.composition.NodeRole.INPUT" title="psyneulink.core.compositions.composition.NodeRole.INPUT"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">INPUT</span></code></a> Nodes that are <em>not</em> included in the set are assigned <a class="reference internal" href="#psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.state_feature_default" title="psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.state_feature_default"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">state_feature_default</span></code></a> as their state_feature specification.  Note that,
> since the default for <a class="reference internal" href="#psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.state_feature_default" title="psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.state_feature_default"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">state_feature_default</span></code></a> is
> <em>SHADOW_INPUTS</em>, unless this is specified otherwise omitting items from a set has no effect (i.e., they
> too are assigned <em>SHADOW_INPUTS</em>);  for omitted items to be treated differently, <a class="reference internal" href="#psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.state_feature_default" title="psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.state_feature_default"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">state_feature_default</span></code></a> must be specified; for example by assigning it
> <code class="docutils literal notranslate"><span class="pre">None</span></code> so that items omitted from the set are assigned their default input value (see <a class="reference internal" href="#optimizationcontrolmechanism-none-state-feature"><span class="std std-ref">below</span></a>.</p></li>
505,507c512,514
< <li><p><em>None</em> – no <a class="reference internal" href="#psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.state_input_ports" title="psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.state_input_ports"><code class="xref any py py-attr docutils literal notranslate"><span class="pr
...

See CI logs for the full diff.

@lgtm-com
Copy link
Contributor

lgtm-com bot commented Mar 25, 2022

This pull request fixes 1 alert when merging d36d573 into f8130b4 - view on LGTM.com

fixed alerts:

  • 1 for Unused import

@jdcpni jdcpni merged commit 138a291 into devel Mar 25, 2022
@jdcpni jdcpni deleted the refactor/ocm/state_features_all_as_input_ports branch March 25, 2022 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants