-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[solvers] Reformulate SolverOptions.SetOption to use our variant #22282
[solvers] Reformulate SolverOptions.SetOption to use our variant #22282
Conversation
+@hongkai-dai would you like to feature-review this? |
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.
Reviewed 4 of 5 files at r1.
Reviewable status: 1 unresolved discussion, LGTM missing from assignee hongkai-dai, needs platform reviewer assigned, needs at least two assigned reviewers
solvers/solver_options.cc
line 28 at r1 (raw file):
std::visit( overloaded{ [&](double& unboxed_value) {
Curious why we use a reference double&
instead of const reference here? And why we use std:move(key)
instead of const std::string_view& key
?
This means we need to deprecate the old kwarg names in pydrake (while also back-filling its missing test cases).
1bede16
to
5faa1fe
Compare
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.
Reviewable status: 1 unresolved discussion, LGTM missing from assignee hongkai-dai, needs platform reviewer assigned, needs at least two assigned reviewers
solvers/solver_options.cc
line 28 at r1 (raw file):
Previously, hongkai-dai (Hongkai Dai) wrote…
Curious why we use a reference
double&
instead of const reference here? And why we usestd:move(key)
instead ofconst std::string_view& key
?
The goal is to avoid move the value
into place when it's a string
. I've respelled the code a bit to hopefully make that more clear?
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.
Reviewed 1 of 5 files at r1.
Reviewable status: 1 unresolved discussion, LGTM missing from assignee hongkai-dai, needs platform reviewer assigned, needs at least two assigned reviewers
solvers/solver_options.cc
line 28 at r1 (raw file):
Previously, jwnimmer-tri (Jeremy Nimmer) wrote…
The goal is to avoid move the
value
into place when it's astring
. I've respelled the code a bit to hopefully make that more clear?
I see. Thanks! Let me rephrase it to make sure I understand
Since we just move value
into solver_options_str_
, we want to make sure that everything is rvalue, hence we use rvalue reference here.
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.
Reviewable status: 1 unresolved discussion, LGTM missing from assignee hongkai-dai, needs platform reviewer assigned, needs at least two assigned reviewers
solvers/solver_options.cc
line 28 at r1 (raw file):
Previously, hongkai-dai (Hongkai Dai) wrote…
I see. Thanks! Let me rephrase it to make sure I understand
Since we just move
value
intosolver_options_str_
, we want to make sure that everything is rvalue, hence we use rvalue reference here.
Yes, exactly.
(I believe using the lvalue reference and moving from it (as I did in r1) would also still avoid the copying, but is less clear to a person reading the code. Writing out the &&
in the signature here most clearly communicate the intention.)
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.
+@ggould-tri for platform review please, thanks!
Reviewable status: LGTM missing from assignee ggould-tri(platform)
solvers/solver_options.cc
line 28 at r1 (raw file):
Previously, jwnimmer-tri (Jeremy Nimmer) wrote…
Yes, exactly.
(I believe using the lvalue reference and moving from it (as I did in r1) would also still avoid the copying, but is less clear to a person reading the code. Writing out the
&&
in the signature here most clearly communicate the intention.)
Got it, thanks for the explanation!
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.
Reviewed 4 of 5 files at r1, 1 of 1 files at r2, all commit messages.
Reviewable status: complete! all discussions resolved, LGTM from assignees ggould-tri(platform),hongkai-dai
…otLocomotion#22282) This means we need to deprecate the old kwarg names in pydrake (while also back-filling its missing test cases).
This simplifies our API surface for users, and makes the implementation of #22078 easier.
Towards #22078.
This change is