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/lccontrolmechanism_objectivemechanism #3134

Merged
merged 28 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
edbc9f3
-
jdcpni Oct 27, 2024
1b26697
Merge branch 'devel' of https://github.com/PrincetonUniversity/PsyNeu…
jdcpni Oct 27, 2024
dd0602a
Merge branch 'devel' of https://github.com/PrincetonUniversity/PsyNeu…
jdcpni Oct 28, 2024
1146c28
Merge branch 'devel' of https://github.com/PrincetonUniversity/PsyNeu…
jdcpni Nov 3, 2024
4081ae1
Merge branch 'devel' of https://github.com/PrincetonUniversity/PsyNeu…
jdcpni Nov 7, 2024
b68ed21
Merge branch 'devel' of https://github.com/PrincetonUniversity/PsyNeu…
jdcpni Nov 9, 2024
ea31161
[skip ci]
jdcpni Nov 9, 2024
bcb84c8
Merge branch 'devel' of https://github.com/PrincetonUniversity/PsyNeu…
jdcpni Nov 12, 2024
075ce0b
Merge branch 'devel' of https://github.com/PrincetonUniversity/PsyNeu…
jdcpni Nov 14, 2024
86fb71e
Merge branch 'devel' of https://github.com/PrincetonUniversity/PsyNeu…
jdcpni Nov 18, 2024
1c1470b
[skip ci]
jdcpni Nov 18, 2024
ee8fada
Merge branch 'devel' of https://github.com/PrincetonUniversity/PsyNeu…
jdcpni Nov 22, 2024
7a8a9c4
Merge branch 'devel' of https://github.com/PrincetonUniversity/PsyNeu…
jdcpni Nov 25, 2024
cb1e155
Merge branch 'devel' of https://github.com/PrincetonUniversity/PsyNeu…
jdcpni Nov 25, 2024
8ae27bb
Merge branch 'devel' of https://github.com/PrincetonUniversity/PsyNeu…
jdcpni Nov 26, 2024
0182315
Merge branch 'devel' of https://github.com/PrincetonUniversity/PsyNeu…
jdcpni Nov 26, 2024
57eb5af
• composition.py
jdcpni Nov 26, 2024
3012af2
-
jdcpni Nov 26, 2024
5284817
Merge branch 'devel' of https://github.com/PrincetonUniversity/PsyNeu…
jdcpni Nov 27, 2024
021e337
[skip ci]
jdcpni Nov 27, 2024
40e3a0a
[skip ci]]
jdcpni Nov 27, 2024
6b3d326
[skip ci]]
jdcpni Nov 27, 2024
0ebc7bb
[skip ci]]
jdcpni Nov 27, 2024
b3498c9
[skip ci]
jdcpni Nov 27, 2024
36461e4
Merge branch 'fix/lccontrolmechanism_objectivemechanism' of https://g…
jdcpni Nov 27, 2024
799078c
• test_control_mechanism.py
jdcpni Nov 27, 2024
bb8d903
-
jdcpni Nov 27, 2024
30f3445
-
jdcpni Nov 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1452,7 +1452,7 @@ def _instantiate_objective_mechanism(self, input_ports=None, context=None):
if not isinstance(monitor_for_control, list):
monitor_for_control = [monitor_for_control]

# If objective_mechanism is used to specify OutputPorts to be monitored (legacy feature)
# If objective_mechanism arg is used to specify OutputPorts to be monitored (legacy feature)
# move them to monitor_for_control
if isinstance(self.objective_mechanism, list):
monitor_for_control.extend(self.objective_mechanism)
Expand Down
23 changes: 16 additions & 7 deletions psyneulink/core/compositions/composition.py
Original file line number Diff line number Diff line change
Expand Up @@ -2912,7 +2912,7 @@
from psyneulink.core.components.mechanisms.modulatory.modulatorymechanism import ModulatoryMechanism_Base
from psyneulink.core.components.mechanisms.processing.compositioninterfacemechanism import CompositionInterfaceMechanism
from psyneulink.core.components.mechanisms.processing.objectivemechanism import ObjectiveMechanism
from psyneulink.core.components.mechanisms.processing.processingmechanism import ProcessingMechanism
from psyneulink.core.components.mechanisms.processing.processingmechanism import ProcessingMechanism, ProcessingMechanism_Base

Check notice

Code scanning / CodeQL

Cyclic import Note

Import of module
psyneulink.core.components.mechanisms.processing.processingmechanism
begins an import cycle.
from psyneulink.core.components.ports.inputport import InputPort, InputPortError
from psyneulink.core.components.ports.modulatorysignals.controlsignal import ControlSignal
from psyneulink.core.components.ports.modulatorysignals.learningsignal import LearningSignal
Expand All @@ -2934,17 +2934,18 @@
from psyneulink.core.compositions.showgraph import ShowGraph, INITIAL_FRAME, SHOW_CIM, EXECUTION_SET, SHOW_CONTROLLER
from psyneulink.core.globals.context import Context, ContextFlags, handle_external_context
from psyneulink.core.globals.keywords import \
AFTER, ALL, ALLOW_PROBES, ANY, BEFORE, COMPONENT, COMPOSITION, CONTROL, CONTROL_SIGNAL, CONTROLLER, CROSS_ENTROPY, \
(AFTER, ALL, ALLOW_PROBES, ANY, BEFORE, COMPONENT, COMPOSITION, CONTROL, CONTROL_SIGNAL, CONTROLLER, CROSS_ENTROPY, \
DEFAULT, DEFAULT_VARIABLE, DICT, FEEDBACK, FULL, FUNCTION, HARD_CLAMP, IDENTITY_MATRIX, \
INPUT, INPUT_PORTS, INPUTS, INPUT_CIM_NAME, \
LEARNABLE, LEARNED_PROJECTIONS, LEARNING_FUNCTION, LEARNING_MECHANISM, LEARNING_MECHANISMS, LEARNING_PATHWAY, \
LEARNING_SIGNAL, Loss, \
MATRIX, MAYBE, MODEL_SPEC_ID_METADATA, MONITOR, MONITOR_FOR_CONTROL, NAME, NESTED, NO_CLAMP, NODE, NODES, \
MATRIX, MAYBE, MODEL_SPEC_ID_METADATA, MONITOR, MONITOR_FOR_CONTROL, MULTIPLICATIVE_PARAM,
NAME, NESTED, NO_CLAMP, NODE, NODES, \
OBJECTIVE_MECHANISM, ONLINE, ONLY, OUTCOME, OUTPUT, OUTPUT_CIM_NAME, OUTPUT_MECHANISM, OUTPUT_PORTS, OWNER_VALUE, \
PARAMETER, PARAMETER_CIM_NAME, PORT, \
PROCESSING_PATHWAY, PROJECTION, PROJECTIONS, PROJECTION_TYPE, PROJECTION_PARAMS, PULSE_CLAMP, RECEIVER, \
SAMPLE, SENDER, SHADOW_INPUTS, SOFT_CLAMP, SUM, \
TARGET, TARGET_MECHANISM, TEXT, VARIABLE, WEIGHT, OWNER_MECH
TARGET, TARGET_MECHANISM, TEXT, VARIABLE, WEIGHT, OWNER_MECH)
from psyneulink.core.globals.log import CompositionLog, LogCondition
from psyneulink.core.globals.parameters import Parameter, ParametersBase, check_user_specified, copy_parameter_value
from psyneulink.core.globals.preferences.basepreferenceset import BasePreferenceSet
Expand Down Expand Up @@ -4368,8 +4369,7 @@
else:
self._pre_existing_pathway_components[NODES].append(node)

# Aux components are being added by Composition, even if main Node being added was from COMMAND_LINE
# (this suppresses warnings pertaining to illegal or ill-advised direct addition of some components)
# Aux components are being added by Composition, even if main Node is being added was from COMMAND_LINE
invalid_aux_components = self._add_node_aux_components(node, context=context)

# Implement required_roles
Expand Down Expand Up @@ -5114,7 +5114,7 @@
# ignore these for now and try to activate them again during every call to _analyze_graph
# and, at runtime, if there are still any invalid aux_components left, issue a warning
projections = []
# Add all "nodes" to the composition first (in case projections reference them)
# Add all Nodes to the Composition first (in case Projections reference them)
for i, component in enumerate(node.aux_components):
if isinstance(component, (Mechanism, Composition)):
if isinstance(component, Composition):
Expand Down Expand Up @@ -9801,6 +9801,15 @@

return total_cost

def _get_modulable_mechanisms(self):
modulated_mechanisms = []
for mech in [m for m in self.nodes if (isinstance(m, ProcessingMechanism_Base) and
not (isinstance(m, ObjectiveMechanism)
and self.get_roles_for_node(m) != NodeRole.CONTROL)
and hasattr(m.function, MULTIPLICATIVE_PARAM))]:
modulated_mechanisms.append(mech)
return modulated_mechanisms

# endregion CONTROL

# ******************************************************************************************************************
Expand Down
Loading
Loading