-
Notifications
You must be signed in to change notification settings - Fork 67
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
Interim continuous-adjoint shooting implementation #885
Conversation
…pute_partials need to be computed
…ding parameter, control, and polynomial control
…id muddying the line between distributions and transcriptions. DirectShootingPhase is solving the brachistochrone problem when the output grid is the same as the input grid, but fails if they are different.
…thin their respective control groups.
…n tests that are covered by the DirectShootingPhase tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great changes here, Rob. I have minor suggestions, mostly docstring related. I'm excited to use this for the Aviary work later on!
dymos/phase/direct_shooting_phase.py
Outdated
self.options.declare('propagate_derivs', types=bool, default=True, | ||
desc='If True, propagate the state and derivatives of the state and time with respect to ' | ||
'the integration parameters. If False, only propagate the primal states. If only ' | ||
'using this transcription to propagate an ODE and derivatives are needed, setting ' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe it should be "and derivatives are not needed"? Might be missing a word or I'm misunderstanding
If a string, the file to which the result of the simulation will be saved. | ||
If None, no record of the simulation will be saved. | ||
|
||
Returns |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor detail: does this return problem if an error is just raised? I'm not sure if this docstring should be different
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Understood, the NotImplementedError should be overridden ultimately.
|
||
Returns | ||
------- | ||
problem |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same minor detail comment about the return docstring as above
dymos/transcriptions/grid_data.py
Outdated
""" | ||
Provides a dict of node info and locations for a uniformly distributed set of n nodes on the range [-1, 1]. | ||
|
||
This distribution is not to be used to define polynomials, since equally space nodes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
space -> spaced
self.options.declare('propagate_derivs', types=bool, default=True, | ||
desc='If True, propagate the state and derivatives of the state and time with respect to ' | ||
'the integration parameters. If False, only propagate the primal states. If only ' | ||
'using this transcription to propagate an ODE and derivatives are needed, setting ' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"are" -> "are not"?
elif var_type == 'control_rate': | ||
control_name = var[:-5] | ||
path = f'control_rates:{control_name}_rate' | ||
control_name = var[:-5] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
second control_name definition unnecessary?
|
||
def setup(self): | ||
""" | ||
Add the necessary I/O and storage for the RKIntegrationComp. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RKIntegrationComp -> ODEIntegrationComp
|
||
return f, f_x, f_t, f_theta | ||
|
||
def _f_augmented(self, t, y, theta, dtheta_dz): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You know, this is just really neat stuff!
A component which interpolates control values in 1D using Vandermonde interpolation. | ||
|
||
Takes training values for control variables at given _input_ nodes, | ||
broadcaasts them to _discretization_ nodes, and then interpolates the discretization values |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
broadcaasts -> broadcasts
|
||
def compute_partials(self, inputs, partials, discrete_inputs=None): | ||
""" | ||
Compute derivatives interpolated control values and rates wrt the inputs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"derivatives" -> "derivatives of"?
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
Summary
This is an interim implementation of a continuous-adjoint direct shooting implementation for Dymos.
Ultimately, this implementation will replace the current ExplicitShooting transcription but that will come in a following PR since this one is already massive.
DirectShootingPhase
, a temporary name that will ultimately beExplicitShootingPhase
.AnalyticPhase
,DirectShootingPhase
automatically assumes a particular transcription (DirectShooting
, which will be renamedExplicitShooting
in a future PR).DirectShooting
has a few key differences with the existingExplicitShooting
implementation.SolveIVP
implementation in a future PR, making for easier maintenance.The Concept of Grids
Dymos currently conflates the notion of Grids and Transcriptions a bit.
With this DirectShootingPhase, the points at which output are desired do not necessarily line up with the grid on which the control variables are defined.
Allowing the user to specify a whole transcription object at which outputs are desired seems overkill, so this PR introduces
GaussLobattoGrid
,RadauGrid
, andUniformGrid
. These define node placement without all of the extra setup bloat.In a future PR, these will be used to specify output points for simulate and timeseries output points.
Some rework was done on
ControlGroup
andPolynomialControlGroup
to allow control outputs to be provided on different grids, with the requirement that the segment spacing in the grids remains the same (otherwise control rate interpolation would be nonsense).Other things handled along the way.
pep8
dependency withpycodestyle
. Note there was a significant amount of reformatting to satisfy pycodestyle.Related Issues
Backwards incompatibilities
None
New Dependencies
Replaced pep8 testing dependency with pycodestyle.