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

Adding objects that can replay completed scenarios #54

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

ameesh-shah
Copy link
Collaborator

This is a working PR that is not to be immediately merged. Feedback will be gathered and used in future commits.

The intention of this PR is to add the capability to "reconstitute" completed Scenarios, and be able to replay through the completed scenarios in a pythonic object. Additionally, new behaviors can be added to a ReplaySimulation object, and compared against the actions taken in the completed simulation.

This PR does not yet support the transitioning from a ReplaySimulation object to a Simulation object, for the purposes of "picking up where you left off" and resuming an in-progress simulation.

Additional questions:

  • How will new behaviors be added to the ReplaySimulation object? Right now, my intention is for them to be provided in a scene, but this is making the assumption that the list of behaviors and objects provided will be the same as the number of behaviors and objects that existed in the original simulation. I can add error handling to provide for this.
  • Is it possible to save the 'scene' in the SimulationResult? Is this something we even want?
  • It's still not clear what parts of run() should or shouldn't exist in the ReplaySimulation version.

Added fixes and changes to come.
@dfremont @ek65 let me know your feedback. Thanks!

@ameesh-shah ameesh-shah marked this pull request as draft June 22, 2022 21:29
@ameesh-shah
Copy link
Collaborator Author

Note that the added test case is not final and will need adjustments to be pytest runnable.

"""
return tuple(obj.position for obj in self.objects)
return [self.getProperties(obj, obj.properties) for obj in self.objects]
Copy link
Collaborator

Choose a reason for hiding this comment

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

We don't want to call getProperties again since it may be slow (e.g. actually talking to the simulator). I would just return {prop: getattr(obj, prop) for prop in obj._dynamicProperties}. Also the docstring should clarify that it's only dynamic properties that are saved (you can link to the glossary by writing ":term:`dynamic properties`").

@ameesh-shah ameesh-shah marked this pull request as ready for review June 29, 2022 22:29
@ameesh-shah
Copy link
Collaborator Author

The PR is ready for review:

  • I've added an example implementation of ReplayScenarios for the NewtonianSimulator.
  • The implementation should not require any API changes for any other simulators.

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.

2 participants