GithubHelp home page GithubHelp logo

Comments (4)

RussTedrake avatar RussTedrake commented on August 22, 2024 1

There are multiple formulations possible. (I hope that the course notes are informative). The problem with your one line change is that if both lambda and rho are decision variables, then the new expression is bilinear in the decision variables (not a valid SOS constraint).

The code existing code is a clever way to search for both rho and lambda simultaneously. Instead of saying "for all x in which V < rho, Vdot must be < 0" -- which is what you wanted -- we can write "for all x in which Vdot >= 0, V must be > rho". This works everywhere except at the origin (because Vdot=0), so we have to multiply by x^2 to handle that case.

from underactuated.

Jingwen-Zhang-Aaron avatar Jingwen-Zhang-Aaron commented on August 22, 2024

Coool! I just read your online book and found that the code cannot match with what you have written in the chapter so that I got lost a little bit here. Thank you so much for your explanation. What a clever way!

from underactuated.

Jingwen-Zhang-Aaron avatar Jingwen-Zhang-Aaron commented on August 22, 2024

Hello, I wanna use SOS to do the lyapunov analysis of the simple pendulum. There's no bug for my code but I got V = 0 and lambda = 0 which indicates obviously that something goes wrong. Can you help me have a look at my code?
I just followed the following formulation to find the V.
screen shot 2018-09-26 at 1 14 54 pm

import math
import numpy as np

from pydrake.all import (Jacobian, MathematicalProgram, SolutionResult,
                         Variables)


def dynamics(x):
    return [x[1]*x[2], -x[0]*x[2], -(x[2] + 9.81*x[0])]


prog = MathematicalProgram()
x = prog.NewIndeterminates(3, "x")

# Define the Lyapunov function.
(V, constraint1) = prog.NewSosPolynomial(Variables(x), 2)
Vdot = Jacobian([V.ToExpression()], x).dot(dynamics(x))[0]

# Define the Lagrange multipliers.
(lambda_, constraint2) = prog.NewSosPolynomial(Variables(x), 4)

prog.AddSosConstraint(-Vdot - lambda_.ToExpression()*(pow(x[0],2) + pow(x[1],2) - 1))

result = prog.Solve()

assert(result == SolutionResult.kSolutionFound)

print(prog.SubstituteSolution(V.ToExpression()))
print(prog.SubstituteSolution(lambda_.ToExpression()))

from underactuated.

RussTedrake avatar RussTedrake commented on August 22, 2024

my version of this is here: https://github.com/RussTedrake/underactuated/blob/master/src/pendulum/global_sums_of_squares.py
i didn't check every line, but notice that i was careful to set the scaling by setting V(1) = 1. Otherwise V=0 is perfectly viable.

from underactuated.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.