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

Fix/ocm/state features for nested comps #2329

Merged
merged 285 commits into from
Feb 22, 2022

Conversation

jdcpni
Copy link
Collaborator

@jdcpni jdcpni commented Feb 22, 2022

• optimizationcontrolmechanism.py:

  • state_features, _update_state_feature_dicts():
    • enforce that all keys are mechanisms to standardize handling of nested comps
    • standardize names of deferred nodes
  • clean-up state features for CFA agent_rep
  • mods to docstring

jdcpni and others added 30 commits November 10, 2021 19:50
…rincetonUniversity/PsyNeuLink into refactor/ocm/state_input_ports

� Conflicts:
�	psyneulink/core/components/mechanisms/modulatory/control/optimizationcontrolmechanism.py
  - _gen_llvm_evaluate_function: num_estimates -> num_trials_per_estimate
…ut_ports

# Conflicts:
#	psyneulink/core/components/mechanisms/modulatory/control/optimizationcontrolmechanism.py
  - __init__: moved controller instantiation until after nodes, projections and pathways
  - __init__: restored add_controller position
…teger

Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
…ut_ports

# Conflicts:
#	psyneulink/core/llvm/builder_context.py
  - _update_controller: added
  - add_controller and _analyze_graph(): call _update_controller
  _update_controller:  fixed to loop through all input_ports of comp INPUT nodes
  - test_agent_rep_assignement_as_controller_and_replacement:
      updated to test that shadowing projections to state_input_ports
      are properly added and deleted
…Link into refactor/ocm/state_input_ports

� Conflicts:
�	tests/composition/test_control.py
  - _function: refactored to put use aggregation_function at end
  - _grid_evaluate:  still needs to return all_samples
…rincetonUniversity/PsyNeuLink into refactor/ocm/state_input_ports

� Conflicts:
�	psyneulink/core/components/mechanisms/modulatory/control/optimizationcontrolmechanism.py
  - added call to _update_controller to add_node
  - moved test for projections to controller.state_input_ports to run()
  moved calls to _update_controller to _complete_init_of_partially_initialized_nodes
  moved _update_controller to ocm._update_state_input_ports

• optimizationcontrolmechanism.py:
  added _update_state_input_ports [**still needed work**]
  moved calls to _update_controller to _complete_init_of_partially_initialized_nodes
  moved _update_controller to ocm._update_state_input_ports
  _instantiate_controller_shadow_projections [still needs to be implemented]

• optimizationcontrolmechanism.py:
  added _update_state_input_ports [**still needed work**]
  added needs_update_controller
  - add test_no_path_afferents()
  - add test_no_efferents()
  - clean-up of state features for CFA agent_rep
  - BEFORE ADDITIONAL MODIFICATION OF HANDLING OF DEFERRED INITS
  MODIFICATION OF HANDLING OF DEFERRED INITS:
  - _update_state_feature_dicts()
  - state_features
• optimizationcontrolmechanism.py:
  - state_features:  enforce that all keys are mechanisms, including ones in nest comps
• optimizationcontrolmechanism.py: update docstring
@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
428c428
< <p id="optimizationcontrolmechanism-agent-rep-composition"><strong>state_features</strong> for an agent_rep that is a* <strong>Composition</strong></p>
---
> <p id="optimizationcontrolmechanism-agent-rep-composition"><strong>state_features</strong> <em>for an agent_rep that is a</em> <strong>Composition</strong></p>
432c432
< <p>The <strong>state_features</strong> specify the inputs to the  Composition assigned as 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> when it is executed by the OptimizationControlMechanism to
---
> <p id="optimizationcontrolmechanism-state-features-automatic-assignment"><em>Automatic assignment.</em> The <strong>state_features</strong> specify the inputs to the  Composition assigned as 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> when it is executed by the OptimizationControlMechanism to
442,449c442,450
< <p>The <strong>state_features</strong> argument can also be specified explicitly, using the formats described below.  This is
< useful if values other than the <a class="reference internal" href="Composition.html#composition-execution-inputs"><span class="std std-ref">external inputs</span></a> to 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> Composition are to be used to evaluate it, to restrict evaluation
< This allows values other than the <a class="reference internal" href="Composition.html#composition-execution-inputs"><span class="std std-ref">external inputs</span></a> to 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> Composition to be used to evaluate it; to restrict evaluation to a
< subset of inputs (while others are held constant); and/or to assign specific functions to one or more
< <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="pre">state_input_ports</span></code></a> that allow them to process inputs
< (e.g., modulate and/or intergrate them) before them as <a class="reference internal" href="#psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.state_feature_values" title="psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.state_feature_values"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">state_feature_values</span> <span class="pre">state_feature_values</span></code></a> (see <a class="reference internal" href="#optimizationcontrolmechanism-state-feature-function-arg"><span class="std std-ref">below</span></a>). Note that assigning <strong>state_features</strong> explicitly
< overrides their automatic assignment, so that all required values must be specified, and this must be done
< accurate, as described below.</p>
---
> <p id="optimizationcontrolmechanism-state-features-explicit-specification"><em>Explicit specificaiont.</em> The <strong>state_features</strong> argument can also be specified explicitly, using the formats
> described below.  This is useful if values other than the <a class="reference internal" href="Composition.html#composition-execution-inputs"><span class="std std-ref">external inputs</span></a> to
> 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> Composition are to be used to evaluate it, to restrict
> evaluation This allows values other than the <a class="reference internal" href="Composition.html#composition-execution-inputs"><span class="std std-ref">external inputs</span></a> to 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> Composition to be used to evaluate it; to restrict evaluation to a subset
> of inputs (while others are held constant); and/or to assign specific functions to one or more <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="pre">state_input_ports</span></code></a> that allow them to process inputs (e.g., modulate and/or integrate
> them) before them as <a class="reference internal" href="#psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.state_feature_values" title="psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.state_feature_values"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">state_feature_values</span> <span class="pre">state_feature_values</span></code></a>
> (see <a class="reference internal" href="#optimizationcontrolmechanism-state-feature-function-arg"><span class="std std-ref">below</span></a>). Note that assigning <strong>state_features</strong>
> explicitly overrides their automatic assignment, so that all required values must be specified, and this must be
> done accurate, as described below.</p>
472c473
< specifications listed <a class="reference internal" href="#optimization-control-mechanism-state-feature-individual-inputs"><span class="std std-ref">below</span></a>.  The items
---
> specifications listed <a class="reference internal" href="#optimization-control-mechanism-state-feature-individual-inputs"><span class="std std-ref">below</span></a>. The items
475,476c476,482
< the remaining INPUT Nodes are assigned their <a class="reference internal" href="Component.html#psyneulink.core.components.component.Component.defaults" title="psyneulink.core.components.component.Component.defaults"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">default</span> <span class="pre">variable</span></code></a> as input when 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.evaluate" title="psyneulink.core.compositions.composition.Composition.evaluate"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">evaluate</span></code></a> method is called;  <code class="docutils literal notranslate"><span class="pre">None</span></code> can
< be used as an entry to “skip” items in the list (i.e., specify that they receive their <a class="reference internal" href="Component.html#psyneulink.core.components.component.Component.defaults" title="psyneulink.core.components.component.Component.defaults"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">default</span> <span class="pre">variable</span></code></a> as input).</p></li>
---
> the remaining INPUT Nodes are assigned their <a class="reference internal" href="Component.html#psyneulink.core.components.component.Component.defaults" title="psyneulink.core.components.component.Component.defaults"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">default</span> <span class="pre">variable</span></code></a> as input when 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.evaluate" title="psyneulink.core.compositions.composition.Composition.evaluate"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">evaluate</span></code></a> method is called; <code class="docutils literal notranslate"><span class="pre">None</span></code> can
> be used as an entry to “skip” items in the list (i.e., specify that they receive their <a class="reference internal" href="Component.html#psyneulink.core.components.component.Component.defaults" title="psyneulink.core.components.component.Component.defaults"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">default</span> <span class="pre">variable</span></code></a> as input). Items can be specified 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>, that are
> either sources of input to <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>
> <a class="reference internal" href="Composition.html#composition-nodes"><span class="std std-ref">Nodes</span></a>, or those Nodes themselves.  However, these must be added before Composition is
> executed, and must appear in the list in the same position that 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">INPUT</span> <span class="pre">Nodes</span> <span class="pre">to</span> <span class="pre">which</span> <span class="pre">they</span> <span class="pre">pertain</span> <span class="pre">are</span>
> <span class="pre">list</span> <span class="pre">in</span> <span class="pre">the</span> <span class="pre">`agent_rep</span></code></a>'s <a class="reference internal" href="Composition.html#psyneulink.core.compositions.composition.Composition.nodes" title="psyneulink.core.compositions.composition.Composition.nodes"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">nodes</span></code></a> attribute.</p></li>
501c507
< <ul class="simple">
---
> <ul class="simple" id="optimization-control-mechanism-numeric-state-feature">
506c512
< <ul class="simple">
---
> <ul class="simple" id="optimization-control-mechanism-tuple-state-feature">
514c520
< <ul class="simple">
---
> <ul class="simple" id="optimization-control-mechanism-input-port-dict-state-feature">
519c525
< <ul>
---
> <ul id="optimization-control-mechanism-input-port-state-feature">
544c550
< <ul class="simple">
---
> <ul class="simple" id="optimization-control-mechanism-output-port-state-feature">
557,561c563
< specified explicitly (as described <a class="reference internal" href="#optimization-control-mechanism-output-port-state-feature"><span class="std std-ref">above</span></a>).  In
< contrast, if 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 a <a class="reference internal" href="CompositionFunctionApproximator.html"><span class="doc">CompositionFunctionApproximator</span></a>,
< then the Mechanism’s <a class="reference internal" href="OutputPort.html#outputport-primary"><span class="std std-ref">primary OutputPort</span></a> is used (since that is typical usage, and there
< are no assumptions made about the state features of a <a class="reference internal" href="CompositionFunctionApproximator.html"><span class="doc">CompositionFunctionApproximator</span></a>); if the input to the
< Mechanism <em>is</em> to be shadowed, then its InputPort must be specified explicitly (as described <a class="reference internal" href="#optimization-control-mechanism-input-port-state-feature"><span class="std std-ref">above</span></a>).</p></li>
---
> specified explicitly (as described <a class="reference internal" href="#optimization-control-mechanism-output-port-state-feature"><span class="std std-ref">above</span></a>).</p></li>
572,576c574,578
< <p><strong>state_features</strong> specify the <strong>feature_values</strong>
< argument to the CompositionFunctionApproximator’s <a class="reference internal" href="CompositionFunctionApproximator.html#psyneulink.core.compositions.compositionfunctionapproximator.CompositionFunctionApproximator.evaluate" title="psyneulink.core.compositions.compositionfunctionapproximator.CompositionFunctionApproximator.evaluate"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">evalu
...

See CI logs for the full diff.

1 similar comment
@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
428c428
< <p id="optimizationcontrolmechanism-agent-rep-composition"><strong>state_features</strong> for an agent_rep that is a* <strong>Composition</strong></p>
---
> <p id="optimizationcontrolmechanism-agent-rep-composition"><strong>state_features</strong> <em>for an agent_rep that is a</em> <strong>Composition</strong></p>
432c432
< <p>The <strong>state_features</strong> specify the inputs to the  Composition assigned as 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> when it is executed by the OptimizationControlMechanism to
---
> <p id="optimizationcontrolmechanism-state-features-automatic-assignment"><em>Automatic assignment.</em> The <strong>state_features</strong> specify the inputs to the  Composition assigned as 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> when it is executed by the OptimizationControlMechanism to
442,449c442,450
< <p>The <strong>state_features</strong> argument can also be specified explicitly, using the formats described below.  This is
< useful if values other than the <a class="reference internal" href="Composition.html#composition-execution-inputs"><span class="std std-ref">external inputs</span></a> to 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> Composition are to be used to evaluate it, to restrict evaluation
< This allows values other than the <a class="reference internal" href="Composition.html#composition-execution-inputs"><span class="std std-ref">external inputs</span></a> to 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> Composition to be used to evaluate it; to restrict evaluation to a
< subset of inputs (while others are held constant); and/or to assign specific functions to one or more
< <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="pre">state_input_ports</span></code></a> that allow them to process inputs
< (e.g., modulate and/or intergrate them) before them as <a class="reference internal" href="#psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.state_feature_values" title="psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.state_feature_values"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">state_feature_values</span> <span class="pre">state_feature_values</span></code></a> (see <a class="reference internal" href="#optimizationcontrolmechanism-state-feature-function-arg"><span class="std std-ref">below</span></a>). Note that assigning <strong>state_features</strong> explicitly
< overrides their automatic assignment, so that all required values must be specified, and this must be done
< accurate, as described below.</p>
---
> <p id="optimizationcontrolmechanism-state-features-explicit-specification"><em>Explicit specificaiont.</em> The <strong>state_features</strong> argument can also be specified explicitly, using the formats
> described below.  This is useful if values other than the <a class="reference internal" href="Composition.html#composition-execution-inputs"><span class="std std-ref">external inputs</span></a> to
> 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> Composition are to be used to evaluate it, to restrict
> evaluation This allows values other than the <a class="reference internal" href="Composition.html#composition-execution-inputs"><span class="std std-ref">external inputs</span></a> to 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> Composition to be used to evaluate it; to restrict evaluation to a subset
> of inputs (while others are held constant); and/or to assign specific functions to one or more <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="pre">state_input_ports</span></code></a> that allow them to process inputs (e.g., modulate and/or integrate
> them) before them as <a class="reference internal" href="#psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.state_feature_values" title="psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.state_feature_values"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">state_feature_values</span> <span class="pre">state_feature_values</span></code></a>
> (see <a class="reference internal" href="#optimizationcontrolmechanism-state-feature-function-arg"><span class="std std-ref">below</span></a>). Note that assigning <strong>state_features</strong>
> explicitly overrides their automatic assignment, so that all required values must be specified, and this must be
> done accurate, as described below.</p>
472c473
< specifications listed <a class="reference internal" href="#optimization-control-mechanism-state-feature-individual-inputs"><span class="std std-ref">below</span></a>.  The items
---
> specifications listed <a class="reference internal" href="#optimization-control-mechanism-state-feature-individual-inputs"><span class="std std-ref">below</span></a>. The items
475,476c476,482
< the remaining INPUT Nodes are assigned their <a class="reference internal" href="Component.html#psyneulink.core.components.component.Component.defaults" title="psyneulink.core.components.component.Component.defaults"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">default</span> <span class="pre">variable</span></code></a> as input when 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.evaluate" title="psyneulink.core.compositions.composition.Composition.evaluate"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">evaluate</span></code></a> method is called;  <code class="docutils literal notranslate"><span class="pre">None</span></code> can
< be used as an entry to “skip” items in the list (i.e., specify that they receive their <a class="reference internal" href="Component.html#psyneulink.core.components.component.Component.defaults" title="psyneulink.core.components.component.Component.defaults"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">default</span> <span class="pre">variable</span></code></a> as input).</p></li>
---
> the remaining INPUT Nodes are assigned their <a class="reference internal" href="Component.html#psyneulink.core.components.component.Component.defaults" title="psyneulink.core.components.component.Component.defaults"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">default</span> <span class="pre">variable</span></code></a> as input when 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.evaluate" title="psyneulink.core.compositions.composition.Composition.evaluate"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">evaluate</span></code></a> method is called; <code class="docutils literal notranslate"><span class="pre">None</span></code> can
> be used as an entry to “skip” items in the list (i.e., specify that they receive their <a class="reference internal" href="Component.html#psyneulink.core.components.component.Component.defaults" title="psyneulink.core.components.component.Component.defaults"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">default</span> <span class="pre">variable</span></code></a> as input). Items can be specified 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>, that are
> either sources of input to <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>
> <a class="reference internal" href="Composition.html#composition-nodes"><span class="std std-ref">Nodes</span></a>, or those Nodes themselves.  However, these must be added before Composition is
> executed, and must appear in the list in the same position that 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">INPUT</span> <span class="pre">Nodes</span> <span class="pre">to</span> <span class="pre">which</span> <span class="pre">they</span> <span class="pre">pertain</span> <span class="pre">are</span>
> <span class="pre">list</span> <span class="pre">in</span> <span class="pre">the</span> <span class="pre">`agent_rep</span></code></a>'s <a class="reference internal" href="Composition.html#psyneulink.core.compositions.composition.Composition.nodes" title="psyneulink.core.compositions.composition.Composition.nodes"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">nodes</span></code></a> attribute.</p></li>
501c507
< <ul class="simple">
---
> <ul class="simple" id="optimization-control-mechanism-numeric-state-feature">
506c512
< <ul class="simple">
---
> <ul class="simple" id="optimization-control-mechanism-tuple-state-feature">
514c520
< <ul class="simple">
---
> <ul class="simple" id="optimization-control-mechanism-input-port-dict-state-feature">
519c525
< <ul>
---
> <ul id="optimization-control-mechanism-input-port-state-feature">
544c550
< <ul class="simple">
---
> <ul class="simple" id="optimization-control-mechanism-output-port-state-feature">
557,561c563
< specified explicitly (as described <a class="reference internal" href="#optimization-control-mechanism-output-port-state-feature"><span class="std std-ref">above</span></a>).  In
< contrast, if 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 a <a class="reference internal" href="CompositionFunctionApproximator.html"><span class="doc">CompositionFunctionApproximator</span></a>,
< then the Mechanism’s <a class="reference internal" href="OutputPort.html#outputport-primary"><span class="std std-ref">primary OutputPort</span></a> is used (since that is typical usage, and there
< are no assumptions made about the state features of a <a class="reference internal" href="CompositionFunctionApproximator.html"><span class="doc">CompositionFunctionApproximator</span></a>); if the input to the
< Mechanism <em>is</em> to be shadowed, then its InputPort must be specified explicitly (as described <a class="reference internal" href="#optimization-control-mechanism-input-port-state-feature"><span class="std std-ref">above</span></a>).</p></li>
---
> specified explicitly (as described <a class="reference internal" href="#optimization-control-mechanism-output-port-state-feature"><span class="std std-ref">above</span></a>).</p></li>
572,576c574,578
< <p><strong>state_features</strong> specify the <strong>feature_values</strong>
< argument to the CompositionFunctionApproximator’s <a class="reference internal" href="CompositionFunctionApproximator.html#psyneulink.core.compositions.compositionfunctionapproximator.CompositionFunctionApproximator.evaluate" title="psyneulink.core.compositions.compositionfunctionapproximator.CompositionFunctionApproximator.evaluate"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">evalu
...

See CI logs for the full diff.

@lgtm-com
Copy link
Contributor

lgtm-com bot commented Feb 22, 2022

This pull request introduces 3 alerts when merging 1a1ecec into 31c15ce - view on LGTM.com

new alerts:

  • 2 for Unused local variable
  • 1 for Variable defined multiple times

@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
428c428
< <p id="optimizationcontrolmechanism-agent-rep-composition"><strong>state_features</strong> for an agent_rep that is a* <strong>Composition</strong></p>
---
> <p id="optimizationcontrolmechanism-agent-rep-composition"><strong>state_features</strong> <em>for an agent_rep that is a</em> <strong>Composition</strong></p>
432c432
< <p>The <strong>state_features</strong> specify the inputs to the  Composition assigned as 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> when it is executed by the OptimizationControlMechanism to
---
> <p id="optimizationcontrolmechanism-state-features-automatic-assignment"><em>Automatic assignment.</em> The <strong>state_features</strong> specify the inputs to the  Composition assigned as 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> when it is executed by the OptimizationControlMechanism to
442,449c442,450
< <p>The <strong>state_features</strong> argument can also be specified explicitly, using the formats described below.  This is
< useful if values other than the <a class="reference internal" href="Composition.html#composition-execution-inputs"><span class="std std-ref">external inputs</span></a> to 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> Composition are to be used to evaluate it, to restrict evaluation
< This allows values other than the <a class="reference internal" href="Composition.html#composition-execution-inputs"><span class="std std-ref">external inputs</span></a> to 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> Composition to be used to evaluate it; to restrict evaluation to a
< subset of inputs (while others are held constant); and/or to assign specific functions to one or more
< <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="pre">state_input_ports</span></code></a> that allow them to process inputs
< (e.g., modulate and/or intergrate them) before them as <a class="reference internal" href="#psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.state_feature_values" title="psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.state_feature_values"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">state_feature_values</span> <span class="pre">state_feature_values</span></code></a> (see <a class="reference internal" href="#optimizationcontrolmechanism-state-feature-function-arg"><span class="std std-ref">below</span></a>). Note that assigning <strong>state_features</strong> explicitly
< overrides their automatic assignment, so that all required values must be specified, and this must be done
< accurate, as described below.</p>
---
> <p id="optimizationcontrolmechanism-state-features-explicit-specification"><em>Explicit specificaiont.</em> The <strong>state_features</strong> argument can also be specified explicitly, using the formats
> described below.  This is useful if values other than the <a class="reference internal" href="Composition.html#composition-execution-inputs"><span class="std std-ref">external inputs</span></a> to
> 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> Composition are to be used to evaluate it, to restrict
> evaluation This allows values other than the <a class="reference internal" href="Composition.html#composition-execution-inputs"><span class="std std-ref">external inputs</span></a> to 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> Composition to be used to evaluate it; to restrict evaluation to a subset
> of inputs (while others are held constant); and/or to assign specific functions to one or more <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="pre">state_input_ports</span></code></a> that allow them to process inputs (e.g., modulate and/or integrate
> them) before them as <a class="reference internal" href="#psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.state_feature_values" title="psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.state_feature_values"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">state_feature_values</span> <span class="pre">state_feature_values</span></code></a>
> (see <a class="reference internal" href="#optimizationcontrolmechanism-state-feature-function-arg"><span class="std std-ref">below</span></a>). Note that assigning <strong>state_features</strong>
> explicitly overrides their automatic assignment, so that all required values must be specified, and this must be
> done accurate, as described below.</p>
472c473
< specifications listed <a class="reference internal" href="#optimization-control-mechanism-state-feature-individual-inputs"><span class="std std-ref">below</span></a>.  The items
---
> specifications listed <a class="reference internal" href="#optimization-control-mechanism-state-feature-individual-inputs"><span class="std std-ref">below</span></a>. The items
475,476c476,482
< the remaining INPUT Nodes are assigned their <a class="reference internal" href="Component.html#psyneulink.core.components.component.Component.defaults" title="psyneulink.core.components.component.Component.defaults"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">default</span> <span class="pre">variable</span></code></a> as input when 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.evaluate" title="psyneulink.core.compositions.composition.Composition.evaluate"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">evaluate</span></code></a> method is called;  <code class="docutils literal notranslate"><span class="pre">None</span></code> can
< be used as an entry to “skip” items in the list (i.e., specify that they receive their <a class="reference internal" href="Component.html#psyneulink.core.components.component.Component.defaults" title="psyneulink.core.components.component.Component.defaults"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">default</span> <span class="pre">variable</span></code></a> as input).</p></li>
---
> the remaining INPUT Nodes are assigned their <a class="reference internal" href="Component.html#psyneulink.core.components.component.Component.defaults" title="psyneulink.core.components.component.Component.defaults"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">default</span> <span class="pre">variable</span></code></a> as input when 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.evaluate" title="psyneulink.core.compositions.composition.Composition.evaluate"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">evaluate</span></code></a> method is called; <code class="docutils literal notranslate"><span class="pre">None</span></code> can
> be used as an entry to “skip” items in the list (i.e., specify that they receive their <a class="reference internal" href="Component.html#psyneulink.core.components.component.Component.defaults" title="psyneulink.core.components.component.Component.defaults"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">default</span> <span class="pre">variable</span></code></a> as input). Items can be specified 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>, that are
> either sources of input to <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>
> <a class="reference internal" href="Composition.html#composition-nodes"><span class="std std-ref">Nodes</span></a>, or those Nodes themselves.  However, these must be added before Composition is
> executed, and must appear in the list in the same position that 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">INPUT</span> <span class="pre">Nodes</span> <span class="pre">to</span> <span class="pre">which</span> <span class="pre">they</span> <span class="pre">pertain</span> <span class="pre">are</span>
> <span class="pre">list</span> <span class="pre">in</span> <span class="pre">the</span> <span class="pre">`agent_rep</span></code></a>'s <a class="reference internal" href="Composition.html#psyneulink.core.compositions.composition.Composition.nodes" title="psyneulink.core.compositions.composition.Composition.nodes"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">nodes</span></code></a> attribute.</p></li>
501c507
< <ul class="simple">
---
> <ul class="simple" id="optimization-control-mechanism-numeric-state-feature">
506c512
< <ul class="simple">
---
> <ul class="simple" id="optimization-control-mechanism-tuple-state-feature">
514c520
< <ul class="simple">
---
> <ul class="simple" id="optimization-control-mechanism-input-port-dict-state-feature">
519c525
< <ul>
---
> <ul id="optimization-control-mechanism-input-port-state-feature">
544c550
< <ul class="simple">
---
> <ul class="simple" id="optimization-control-mechanism-output-port-state-feature">
557,561c563
< specified explicitly (as described <a class="reference internal" href="#optimization-control-mechanism-output-port-state-feature"><span class="std std-ref">above</span></a>).  In
< contrast, if 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 a <a class="reference internal" href="CompositionFunctionApproximator.html"><span class="doc">CompositionFunctionApproximator</span></a>,
< then the Mechanism’s <a class="reference internal" href="OutputPort.html#outputport-primary"><span class="std std-ref">primary OutputPort</span></a> is used (since that is typical usage, and there
< are no assumptions made about the state features of a <a class="reference internal" href="CompositionFunctionApproximator.html"><span class="doc">CompositionFunctionApproximator</span></a>); if the input to the
< Mechanism <em>is</em> to be shadowed, then its InputPort must be specified explicitly (as described <a class="reference internal" href="#optimization-control-mechanism-input-port-state-feature"><span class="std std-ref">above</span></a>).</p></li>
---
> specified explicitly (as described <a class="reference internal" href="#optimization-control-mechanism-output-port-state-feature"><span class="std std-ref">above</span></a>).</p></li>
572,576c574,578
< <p><strong>state_features</strong> specify the <strong>feature_values</strong>
< argument to the CompositionFunctionApproximator’s <a class="reference internal" href="CompositionFunctionApproximator.html#psyneulink.core.compositions.compositionfunctionapproximator.CompositionFunctionApproximator.evaluate" title="psyneulink.core.compositions.compositionfunctionapproximator.CompositionFunctionApproximator.evaluate"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">evalu
...

See CI logs for the full diff.

@lgtm-com
Copy link
Contributor

lgtm-com bot commented Feb 22, 2022

This pull request introduces 1 alert when merging b67f617 into 31c15ce - view on LGTM.com

new alerts:

  • 1 for Variable defined multiple times

@jdcpni jdcpni merged commit 7b4abd2 into devel Feb 22, 2022
@jdcpni jdcpni deleted the fix/ocm/state_features_for_nested_comps branch February 22, 2022 16:16
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.002%) to 84.389% when pulling b67f617 on fix/ocm/state_features_for_nested_comps into 31c15ce on devel.

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

4 participants