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/control/bugs #2261

Merged
merged 242 commits into from
Dec 27, 2021
Merged

Fix/control/bugs #2261

merged 242 commits into from
Dec 27, 2021

Conversation

jdcpni
Copy link
Collaborator

@jdcpni jdcpni commented Dec 26, 2021

• composition.py:

  • add_controller: add test for num_estimates before calling
    _create_randomization_control_signal()
  • _add_node_aux_components(): fix bug in which ControlProjections were
          getting replaced by MappingProjections in composition.projections

• optimizationcontrolmechanism.py:

  • _create_randomization_control_signal():
    warn if num_estimates is >1 and there are no random_variables

• test_control

  • test_mode_based_num_estimates: add test for random variables (using DDM)

• show_graph.py
  - fix bug in check for name of RANDOMIZATION_CONTROL_SIGNAL

  docstring mod to **size**
  added feature_input_ports attribute and num_feature_input_ports property
  added feature_input_ports attribute and num_feature_input_ports property

• parameterestimationcomposition.py: fixed misplacement of its Parameters() attribute
  added feature_input_ports attribute and num_feature_input_ports property

• parameterestimationcomposition.py: fixed misplacement of its Parameters() attribute

• optimizationfunctions.py: made num_estimates a Parameter
  - _instantiate_control_signals: random_seeds -> random_seed_mod_values
  - _add_controller:  modifying to instantiate feature_input_ports if none are specified
  - add_controller:  now adds feature_input_ports for Compostion INPUT nodes if not state_features not specified
  - _add_controller:  modifying to instantiate feature_input_ports if none are specified
  - add_controller:  assign simulation_input_ports
  - feature_input_ports -> state_input_ports
  - _instantiate_input_ports():
      state_features only allowed to specifying state_input_ports if
      agent_rep is a CompositionFunctionApproximator (i.e., model-free optimization)

• composition.py:
  - add_controller: adds state_input_ports to shadow INPUT Nodes of Composition
    if controller.agent_rep is Composition (model-based optimziation)
    or state_features have not been specified (for model-free optimizaton)
  _instantiate_input_ports:
     reinstate allowance of state_features specification if agent_rep is a Composition
     (i.e., model-based optimization) as long as they are all INPUT Nodes of agent_rep
jdcpni and others added 20 commits December 11, 2021 20:30
  - add test_unnested_PROBE
  - add test_nested_PROBES
    TBD: test include_probes_in_output
  - add_node():  support tuple with required_role
  - _determine_node_roles:
     fix bug in which nested comp was prevented from being an OUTPUT Node if,
     in addition to Nodes that qualifed as OUTPUT, it also had nodes that projected
     to Nodes in an outer comp (making it look like it was INTERNAL)
…nUniversity/PsyNeuLink into feat/composition/probes

� Conflicts:
�	tests/composition/test_composition.py
  - add_node(): enforce include_probes_in_output = True for nested Compositions
  - execute():
    - replace return of output_value with get_output_value()
  - correct path ref

• compositioninterfacemechanism.py:
  - docstring fixes
…Link into devel

� Conflicts:
�	psyneulink/core/components/mechanisms/processing/compositioninterfacemechanism.py
  - _add_node_aux_components(): fix bug in which ControlProjections were
       getting replaced by MappingProjections in composition.projections
  - fix bug in check for name of RANDOMIZATION_CONTROL_SIGNAL
@coveralls
Copy link

coveralls commented Dec 26, 2021

Coverage Status

Coverage decreased (-0.001%) to 84.296% when pulling 4d25096 on fix/control/bugs into b383b90 on devel.

  - _create_randomization_control_signal():
      warn if num_estimates is >1 and there are no random_variables

• composition.py:
  - add_controller: add test for num_estimates before calling
                    _create_randomization_control_signal()

• test_control
  - test_mode_based_num_estimates: add test for random variables (using DDM)
@github-actions
Copy link

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

No differences!

...

See CI logs for the full diff.

@github-actions
Copy link

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

No differences!

...

See CI logs for the full diff.

@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
655c655
< <li><p>It must execute the OptimizationControlMechanism’s <a class="reference internal" href="#id0" title="psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.evaluate_agent_rep"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">evaluate_agent_rep</span></code></a> <a class="reference internal" href="#psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.num_estimates" title="psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.num_estimates"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">num_estimates</span></code></a>
---
> <li><p>It must be able to execute the OptimizationControlMechanism’s <a class="reference internal" href="#id0" title="psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.evaluate_agent_rep"><code class="xref any py py-meth docutils literal notranslate"><span class="pre">evaluate_agent_rep</span></code></a> <a class="reference internal" href="#psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.num_estimates" title="psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.num_estimates"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">num_estimates</span></code></a>
695,701c695,703
< <p>If <a class="reference internal" href="#psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.num_estimates" title="psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.num_estimates"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">num_estimates</span></code></a> is specified (that is, it is not None),
< a <a class="reference internal" href="ControlSignal.html"><span class="doc">ControlSignal</span></a> is automatically added to the OptimizationControlMechanism’s <a class="reference internal" href="#psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.control_signals" title="psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.control_signals"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">control_signals</span></code></a>, named <em>RANDOMIZATION_CONTROL_SIGNAL</em>, that randomizes
< the values of random variables 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> over estimates of its
< <a class="reference internal" href="ControlMechanism.html#psyneulink.core.components.mechanisms.modulatory.control.controlmechanism.ControlMechanism.net_outcome" title="psyneulink.core.components.mechanisms.modulatory.control.controlmechanism.ControlMechanism.net_outcome"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">net_outcome</span></code></a>. The <a class="reference internal" href="#psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.initial_seed" title="psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.initial_seed"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">initial_seed</span></code></a> and
< <a class="reference internal" href="#psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.same_seed_for_all_allocations" title="psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.same_seed_for_all_allocations"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">same_seed_for_all_allocations</span></code></a> Parameters can also be
< used to further refine randomization (see <a class="reference internal" href="#optimizationcontrolmechanism-estimation-randomization"><span class="std std-ref">Randomization of Estimation</span></a> for additional
< details).</p>
---
> <p>If <a class="reference internal" href="#psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.num_estimates" title="psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.num_estimates"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">num_estimates</span></code></a> is specified (that is, it is not None), and
> <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> has any <a class="reference internal" href="Component.html"><span class="doc">Components</span></a> with random variables
> (that is, that call a randomization function) specified in the OptimizationControlMechanism’s <a class="reference internal" href="#psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.random_variables" title="psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.random_variables"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">random_variables</span></code></a> attribute, then a <a class="reference internal" href="ControlSignal.html"><span class="doc">ControlSignal</span></a> is automatically added to the
> OptimizationControlMechanism’s <a class="reference internal" href="#psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.control_signals" title="psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.control_signals"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">control_signals</span></code></a>, named
> <em>RANDOMIZATION_CONTROL_SIGNAL</em>, that randomizes the values of the <a class="reference internal" href="#psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.random_variables" title="psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.random_variables"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">random</span> <span class="pre">variables</span></code></a> over estimates of its <a class="reference internal" href="ControlMechanism.html#psyneulink.core.components.mechanisms.modulatory.control.controlmechanism.ControlMechanism.net_outcome" title="psyneulink.core.components.mechanisms.modulatory.control.controlmechanism.ControlMechanism.net_outcome"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">net_outcome</span></code></a>
> for each <a class="reference internal" href="ControlMechanism.html#psyneulink.core.components.mechanisms.modulatory.control.controlmechanism.ControlMechanism.control_allocation" title="psyneulink.core.components.mechanisms.modulatory.control.controlmechanism.ControlMechanism.control_allocation"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">control_allocation</span></code></a> If <a class="reference internal" href="#psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.num_estimates" title="psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.num_estimates"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">num_estimates</span></code></a> is specified but <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>
> has not random variables, then a warning is issued and no <em>RANDOMIZATION_CONTROL_SIGNAL</em> is constructed. The
> <a class="reference internal" href="#psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.initial_seed" title="psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.initial_seed"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">initial_seed</span></code></a> and <a class="reference internal" href="#psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.same_seed_for_all_allocations" title="psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.same_seed_for_all_allocations"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">same_seed_for_all_allocations</span></code></a> Parameters can also be used to further refine
> randomization (see <a class="reference internal" href="#optimizationcontrolmechanism-estimation-randomization"><span class="std std-ref">Randomization of Estimation</span></a> for additional details).</p>
765c767
< The values of Components listed in the OptimizationControlMechanism’s <a class="reference internal" href="#psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.random_variables" title="psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.random_variables"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">random_variables</span></code></a> attribute are randomized over thoese estimates.  By default,
---
> The values of Components listed in the OptimizationControlMechanism’s <a class="reference internal" href="#psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.random_variables" title="psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.random_variables"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">random_variables</span></code></a> attribute are randomized over those estimates.  By default,
791c793,794
< (see <a class="reference internal" href="#optimizationcontrolmechanism-state-feature-functions-arg"><span class="std std-ref">state_feature_functions</span></a> for additional details).</p></li>
---
> (see <a class="reference internal" href="#optimizationcontrolmechanism-state-feature-functions-arg"><span class="std std-ref">state_feature_functions</span></a>
> for additional details).</p></li>
799,803c802,815
< <li><p><strong>num_estimates</strong> (<em>int : 1</em>) – specifies the number independent runs of <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> used
< to estimate its <a class="reference internal" href="ControlMechanism.html#psyneulink.core.components.mechanisms.modulatory.control.controlmechanism.ControlMechanism.net_outcome" title="psyneulink.core.components.mechanisms.modulatory.control.controlmechanism.ControlMechanism.net_outcome"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">net_outcome</span></code></a> for each <a class="reference internal" href="ControlMechanism.html#psyneulink.core.components.mechanisms.modulatory.control.controlmechanism.ControlMechanism.control_allocation" title="psyneulink.core.components.mechanisms.modulatory.control.controlmechanism.ControlMechanism.control_allocation"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">control_allocation</span></code></a> sampled (see <a class="reference internal" href="#psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.num_estimates" title="psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.OptimizationControlMechanism.num_estimates"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">num_estimates</span></code></a> for additional information).</p></li>
< <li><p><strong>random_variables</strong> (<a class="reference internal" href="Parameters.html#psyneulink.core.globals.parameters.Parameter" title="psyneulink.core.globals.parameters.Parameter"><em>Parameter</em></a><em> or </em><em>list</em><em>[</em><a class="reference internal" href="Parameters.html#psyneulink.core.globals.parameters.Parameter" title="psyneulink.core.globals.parameters.Parameter"><em>Parameter</em></a><em>] </em><em>: default ALL</em>) – specifies the Components with random variables to be randomized over different estimates
< of each <a class="reference internal" href="ControlMechanism.html#psyneulink.core.components.mechanisms.modulatory.control.controlmechanism.ControlMechanism.control_allocation" title="psyneulink.core.components.mechanisms.modulatory.control.controlmechanism.ControlMechanism.control_allocation"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">control_allocation</span></code></a>;  these must be 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> and have a <code class="xref any docutils literal notranslate"><span class="pre">seed</span></code> <a class="reference internal" href="Parameters.html#psyneulink.core.globals.parameters.Parameter" title="psyneulink.core.globals.parameters.Parameter"><code class="xref any py py-class docutils literal notranslate"><span class="pre">Parameter</span></code></a>. By default, all such Components 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> (listed in its <a class="reference internal" href="Composition.html#id17" title="psyneulink.core.compositions.composition.Composition.random_variables"><code class="xref any py py-attr docutils literal notranslate"><span class="pre">random_variables</span></code></a> attribute) are included (see <a class="reference internal" href="#psyneulink.core.components.mechanisms.modulatory.control.optimizationcontrolmechanism.Optim
...

See CI logs for the full diff.

@jdcpni jdcpni merged commit cb18e77 into devel Dec 27, 2021
@jdcpni jdcpni deleted the fix/control/bugs branch December 27, 2021 22:32
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