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

OCM: improve simulation context setup #2279

Merged
merged 1 commit into from
Jan 11, 2022

Conversation

kmantel
Copy link
Collaborator

@kmantel kmantel commented Jan 7, 2022

  • initialize context for when an agent_rep uses a controller other than
    its self.controller
    (ex. test_nested_composition_as_agent_rep)

  • add Composition._initialize_as_agent_rep and
    Composition._clean_up_as_agent_rep

@github-actions
Copy link

github-actions bot commented Jan 7, 2022

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

No differences!

...

See CI logs for the full diff.

# KDM 5/20/19: crudely using default here because it is a stateless parameter
# and there is a bug in setting parameter values on init, see TODO note above
# call to self._instantiate_defaults around component.py:1115
if self.defaults.search_statefulness:
new_context = self._set_up_simulation(context, control_allocation)
new_context = self._set_up_simulation(context, control_allocation, alt_controller)
else:
new_context = context
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldn't this pollute the 'value' parameters of components

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I'm not seeing what part you're referencing here. Is it a new change or something in general to simulation contexts?

(I do see the unintentional loss of check_simulation_storage=True arg to delete_contexts)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's not related to the change. the else branch just reuses the base context.
wouldn't the 'value' parameter now include results from simulations stored under the base context?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's the intended behavior if search_statefulness is set to False. I think @davidt0x had a use case for this

if self.agent_rep.controller is None:
try:
alt_controller = context.composition.controller
except AttributeError:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this supposed to catch both missing context.composition and context.composition.controller?
if it's only the latter.
alt_controller = getattr(context.composition, 'controller', None)
would be more readable.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was meant to catch both. I'm unsure if there's a case where this code would be run in a context with no composition set, but if that happened I think it should handle it.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the absence of composition in context legal in this situation? or is it punting the error to be reported later?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think in that case, it's ok and intended not to deal with it. alt_controller would just be one other possibility to try in the case that agent_rep has no controller. If it's not ok for context to have no composition, then I think that should be reported elsewhere.

@kmantel kmantel force-pushed the devel branch 2 times, most recently from 32d0deb to 1d07e8c Compare January 11, 2022 02:45
@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.

1 similar comment
@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):

No differences!

...

See CI logs for the full diff.

- initialize context for when an agent_rep uses a controller other than
its self.controller
	(ex. test_nested_composition_as_agent_rep)

- add Composition._initialize_as_agent_rep and
Composition._clean_up_as_agent_rep
@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.

@kmantel kmantel merged commit f7efbe5 into PrincetonUniversity:devel Jan 11, 2022
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