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

tutorials: Import SOS tutorial from colab #12642

Conversation

EricCousineau-TRI
Copy link
Contributor

@EricCousineau-TRI EricCousineau-TRI commented Jan 27, 2020

Resolves #12634

This is just a quick import.


This change is Reviewable

Copy link
Contributor Author

@EricCousineau-TRI EricCousineau-TRI left a comment

Choose a reason for hiding this comment

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

+@hongkai-dai for feature review, please.
+@RussTedrake for platform review, please.

Reviewable status: LGTM missing from assignees hongkai-dai,RussTedrake(platform) (waiting on @hongkai-dai and @RussTedrake)

Copy link
Contributor

@hongkai-dai hongkai-dai left a comment

Choose a reason for hiding this comment

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

:LGTM: thanks for bringing it into Drake.

Reviewed 3 of 3 files at r1.
Reviewable status: LGTM missing from assignee RussTedrake(platform) (waiting on @RussTedrake)

@jwnimmer-tri
Copy link
Collaborator

I suggest amending the commit message to use Co-authored-by.

Copy link
Contributor Author

@EricCousineau-TRI EricCousineau-TRI left a comment

Choose a reason for hiding this comment

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

Done!

Reviewable status: LGTM missing from assignee RussTedrake(platform) (waiting on @RussTedrake)

Copy link
Contributor

@RussTedrake RussTedrake left a comment

Choose a reason for hiding this comment

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

Reviewable status: 6 unresolved discussions, LGTM missing from assignee RussTedrake(platform) (waiting on @EricCousineau-TRI)


tutorials/sum_of_squares_optimization.ipynb, line 25 at r2 (raw file):

    "p(x) = \\sum_i q_i(x)^2\n",
    "\\end{align}\n",
    "where each $q_i(x)$ is also a polynomial of the indeterminates $x$. Apparently $p(x)$ being sum-of-squares is a *sufficient* condition for $p(x)$ being non-negative for all $x$. In some cases it is also a necessary and sufficient condition. For more details on the relationship between sum-of-squares and non-negativity of a polynomial, you could refer to Chapter 3 of [Semidefinite Optimization and Convex Algebraic Geometry](http://www.mit.edu/~parrilo/sdocag/).\n",

Remove "Apparently"


tutorials/sum_of_squares_optimization.ipynb, line 55 at r2 (raw file):

    "In sum-of-squares problem, often we want to find a sum-of-squares polynomial that satisfies certain additional properties. Note that there are two different types of variables in sum-of-squares problems, the *indeterminates* and *decision variables*.\n",
    "* Decision variables: the coefficients of the polynomial are affine functions of our decision variables. We are optimizing over the decision variables.\n",
    "* Indeterminates: \"dummy variables\", in the sense that we are *not* optimizing over them.\n",

I would replace this definition... perhaps with:
variables that can take any value. In the example above, $x$ is an indeterminate -- the constraints that we write must hold $\forall x$. We are not optimizing over these variables.


tutorials/sum_of_squares_optimization.ipynb, line 102 at r2 (raw file):

    "in this case, $x$ is the indeterminate, and $a$ is the decision variables.\n",
    "\n",
    "The code below shows how to model and solve this sos problem in drake's MathematicalProgram."

SOS


tutorials/sum_of_squares_optimization.ipynb, line 126 at r2 (raw file):

    "# Declare p2(x) = (a0 - a1 + 1) * pow(x, 2) + a1 * x + 1\n",
    "p2 = sym.Polynomial((a[0] - a[1] + 1) * x[0] * x[0] + a[1] * x[0] + 1, sym.Variables(x))\n",
    "# Add the constraint that p1(x) and p2(x) are sos\n",

SOS
(please search and replace through the doc?)


tutorials/sum_of_squares_optimization.ipynb, line 152 at r2 (raw file):

    "To solve this problem, we use the following theorem:\n",
    "\n",
    "**Theorem**: An even degree univariate polynomial $p(x)$ is nonnegative on interval $[0, 1]$ if and only if it can be written as\n",

I would probably not call this version the theorem. The theorem is for the more general S-procedure, and using it for the interval [0,1] is a special case...?


tutorials/sum_of_squares_optimization.ipynb, line 192 at r2 (raw file):

    "# Declares sos polynomial t(x), such that s(x) = p(x) - x(1-x) * t(x) is sos.\n",
    "# The second return argument of NewSosPolynomial is the positive-semidefinite\n",
    "# Hessian matrix of poly_s. We ignore this matrix here.\n",

"Hessian" => "Gramian"
btw -- in the NewSosPolynomial method doc string, "Grammian" => "Gramian"

Copy link
Contributor Author

@EricCousineau-TRI EricCousineau-TRI left a comment

Choose a reason for hiding this comment

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

Pulling in Hongkai's review responses.

Reviewable status: 6 unresolved discussions, LGTM missing from assignee RussTedrake(platform), commits need curation (https://drake.mit.edu/reviewable.html#curated-commits) (waiting on @EricCousineau-TRI, @hongkai-dai, and @RussTedrake)


tutorials/sum_of_squares_optimization.ipynb, line 25 at r2 (raw file):

Previously, RussTedrake (Russ Tedrake) wrote…

Remove "Apparently"

Done.


tutorials/sum_of_squares_optimization.ipynb, line 55 at r2 (raw file):

Previously, RussTedrake (Russ Tedrake) wrote…

I would replace this definition... perhaps with:
variables that can take any value. In the example above, $x$ is an indeterminate -- the constraints that we write must hold $\forall x$. We are not optimizing over these variables.

Done.


tutorials/sum_of_squares_optimization.ipynb, line 102 at r2 (raw file):

Previously, RussTedrake (Russ Tedrake) wrote…

SOS

Done.


tutorials/sum_of_squares_optimization.ipynb, line 126 at r2 (raw file):

Previously, RussTedrake (Russ Tedrake) wrote…

SOS
(please search and replace through the doc?)

Done.


tutorials/sum_of_squares_optimization.ipynb, line 192 at r2 (raw file):

Previously, RussTedrake (Russ Tedrake) wrote…

"Hessian" => "Gramian"
btw -- in the NewSosPolynomial method doc string, "Grammian" => "Gramian"

Done.

Copy link
Contributor Author

@EricCousineau-TRI EricCousineau-TRI left a comment

Choose a reason for hiding this comment

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

Reviewable status: 6 unresolved discussions, LGTM missing from assignee RussTedrake(platform), commits need curation (https://drake.mit.edu/reviewable.html#curated-commits) (waiting on @hongkai-dai and @RussTedrake)


tutorials/sum_of_squares_optimization.ipynb, line 152 at r2 (raw file):

Previously, RussTedrake (Russ Tedrake) wrote…

I would probably not call this version the theorem. The theorem is for the more general S-procedure, and using it for the interval [0,1] is a special case...?

Done.

Copy link
Contributor

@hongkai-dai hongkai-dai left a comment

Choose a reason for hiding this comment

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

Reviewable status: 6 unresolved discussions, LGTM missing from assignee RussTedrake(platform), commits need curation (https://drake.mit.edu/reviewable.html#curated-commits) (waiting on @hongkai-dai and @RussTedrake)


tutorials/sum_of_squares_optimization.ipynb, line 25 at r2 (raw file):

Previously, RussTedrake (Russ Tedrake) wrote…

Remove "Apparently"

Done.


tutorials/sum_of_squares_optimization.ipynb, line 55 at r2 (raw file):

Previously, RussTedrake (Russ Tedrake) wrote…

I would replace this definition... perhaps with:
variables that can take any value. In the example above, $x$ is an indeterminate -- the constraints that we write must hold $\forall x$. We are not optimizing over these variables.

Done.


tutorials/sum_of_squares_optimization.ipynb, line 102 at r2 (raw file):

Previously, RussTedrake (Russ Tedrake) wrote…

SOS

Done.


tutorials/sum_of_squares_optimization.ipynb, line 126 at r2 (raw file):

Previously, RussTedrake (Russ Tedrake) wrote…

SOS
(please search and replace through the doc?)

Done.


tutorials/sum_of_squares_optimization.ipynb, line 152 at r2 (raw file):

Previously, RussTedrake (Russ Tedrake) wrote…

I would probably not call this version the theorem. The theorem is for the more general S-procedure, and using it for the interval [0,1] is a special case...?

I think this is stronger than S-procedure. S-procedure is a sufficient condition, this is a necessary and sufficient condition. In the book "Semidefinite Optimization and Convex Algebraic Geometry" it is also stated as a theorem.


tutorials/sum_of_squares_optimization.ipynb, line 192 at r2 (raw file):

Previously, RussTedrake (Russ Tedrake) wrote…

"Hessian" => "Gramian"
btw -- in the NewSosPolynomial method doc string, "Grammian" => "Gramian"

Done. I will fix the NewSosPolynomial doc string in a separate PR.

Copy link
Contributor Author

@EricCousineau-TRI EricCousineau-TRI left a 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.

(If you have a chance to review this first, I may unassign Russ since he may be busy - we can always file follow-up fixes!)

Reviewable status: 6 unresolved discussions, LGTM missing from assignees RussTedrake(platform),ggould-tri(platform), commits need curation (https://drake.mit.edu/reviewable.html#curated-commits) (waiting on @ggould-tri, @hongkai-dai, and @RussTedrake)


tutorials/sum_of_squares_optimization.ipynb, line 152 at r2 (raw file):

Previously, hongkai-dai (Hongkai Dai) wrote…

I think this is stronger than S-procedure. S-procedure is a sufficient condition, this is a necessary and sufficient condition. In the book "Semidefinite Optimization and Convex Algebraic Geometry" it is also stated as a theorem.

Would you like the current wording to be reverted, or is it OK with you?

Taken from the following notebook on 2020-01-27:
https://drive.google.com/file/d/1vBkNigMecvz7lGEF_9jyD0FuzYY_iTTf

Co-Authored-By: Hongkai Dai <daihongkai@gmail.com>
Copy link
Contributor

@ggould-tri ggould-tri left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 2 of 3 files at r1, 1 of 1 files at r3.
Reviewable status: 8 unresolved discussions, LGTM missing from assignee RussTedrake(platform) (waiting on @EricCousineau-TRI and @RussTedrake)


tutorials/sum_of_squares_optimization.ipynb, line 54 at r3 (raw file):

    "## Solving sum-of-squares problem\n",
    "In sum-of-squares problem, often we want to find a sum-of-squares polynomial that satisfies certain additional properties. Note that there are two different types of variables in sum-of-squares problems, the *indeterminates* and *decision variables*.\n",
    "* Decision variables: the coefficients of the polynomial are affine functions of our decision variables. We are optimizing over the decision variables.\n",

minor: Affine? I would have thought linear.
Dismiss this comment if I'm wrong about that.


tutorials/sum_of_squares_optimization.ipynb, line 235 at r3 (raw file):

    "#### System control theory\n",
    "* [Structured Semidefinite Programs and Semialgebraic Geometry Methods in Robustness and Optimization](http://www.mit.edu/~parrilo/pubs/files/thesis.pdf) Pablo Parrilo's PhD thesis\n",
    "* [Robust Region-of-Attraction Estimation](https://ieeexplore.ieee.org/abstract/document/5337881) Ufuk Topcu, Andrew Packard, Peter Seiler, Gary Balas, IEEE Transactions on Automatic Control, 2009\n",

minor: This link appears to be paywalled. Consider noting that.

Copy link
Contributor Author

@EricCousineau-TRI EricCousineau-TRI left a comment

Choose a reason for hiding this comment

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

Dismissed @RussTedrake from 5 discussions.
Reviewable status: 1 unresolved discussion, LGTM missing from assignee RussTedrake(platform) (waiting on @RussTedrake)


tutorials/sum_of_squares_optimization.ipynb, line 54 at r3 (raw file):

Previously, ggould-tri wrote…

minor: Affine? I would have thought linear.
Dismiss this comment if I'm wrong about that.

OK Not entirely sure; will defer to future fix.


tutorials/sum_of_squares_optimization.ipynb, line 235 at r3 (raw file):

Previously, ggould-tri wrote…

minor: This link appears to be paywalled. Consider noting that.

OK Will defer to future fix.

Copy link
Contributor Author

@EricCousineau-TRI EricCousineau-TRI left a comment

Choose a reason for hiding this comment

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

-@RussTedrake

Reviewable status: 1 unresolved discussion (waiting on @RussTedrake)

Copy link
Contributor Author

@EricCousineau-TRI EricCousineau-TRI left a comment

Choose a reason for hiding this comment

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

Dismissed @RussTedrake from a discussion.
Reviewable status: :shipit: complete! all discussions resolved, LGTM from assignees ggould-tri(platform),hongkai-dai

@EricCousineau-TRI EricCousineau-TRI merged commit d4672d9 into RobotLocomotion:master Jan 30, 2020
Copy link
Contributor

@hongkai-dai hongkai-dai left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! all discussions resolved, LGTM from assignees ggould-tri(platform),hongkai-dai


tutorials/sum_of_squares_optimization.ipynb, line 152 at r2 (raw file):

Previously, EricCousineau-TRI (Eric Cousineau) wrote…

Would you like the current wording to be reverted, or is it OK with you?

The wording is good, thanks!

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.

broken link to SOS tutorial from mathematical_program.ipynb
5 participants