-
Notifications
You must be signed in to change notification settings - Fork 21
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
Variable time support in create_objective_function. #205
Draft
moorepants
wants to merge
1
commit into
csu-hmc:master
Choose a base branch
from
moorepants:var-time-in-obj
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+37
−0
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 should take into account that this is backward Euler, so the first term falls out, see
test_backward_single_input
.If free is [x(t), v(t), f1(t), f2(t), c, k, m, h] then the objective should be
(f1_vals[1:]**2 + f2_vals[1:]**2).sum() * h_val
.Similarly, the gradient should be a stack of
zeros(2*N+1), 2*h_val*f1_vals[1:], [0] 2*h_val*f2_vals[1:], [0, 0, 0, (f1_vals[1:]**2 + f2_vals[1:]**2).sum()]
P.S. quickly wrote out the equations on my phone so would advise checking them.
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.
I don't think I assumed any specific integration routine in the manually created objective functions.
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.
I have a basic question:
In the current create_objective_function(...) there is a distinction in forming obj, obj_grad depending on the integration method.
But, for example, in the examples-gallery simulation plot_pendulum_swing_up_variable_duration, the gradient is formed as I would naively expect it to be formed.
Can the gradient always be formed as per the method used in plot_pendulum_swing_up_variable_duration, or is this only valid for midpoint euler or is this a (good) approximation, if I understood #30 #31 correctly?
Thanks for any explanations!
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.
The examples are a little loose, but it probably doesn't matter too much in the objective calc because both methods have about the same minima.
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.
Thanks!
This would mean one could calculate obj and obj_grad 'naively' without committing a large error?
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.
The gradient of the objective has to be the valid gradient within some numerical tolerance. But your choice of solving the integral in the objective does not really matter, as there are numerous integration methods.
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.
Thanks!
The gradient as calculated in the simulation plot_pendulum_swing_up_variable_duration surely is the valid gradient (?)