convex optimization - ihmc
TRANSCRIPT
![Page 1: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/1.jpg)
Convex OptimizationMay 25, 2012
Dynamic Walking 2012
![Page 2: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/2.jpg)
Convex OptimizationMay 25, 2012
Dynamic Walking 2012
![Page 3: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/3.jpg)
Examples from Dynamic Walking
● Fit return maps with linear model despite noisy sensors / animals
● Approximate inverse dynamics (w/ constraints)○ Find muscle activations to match data in
musculoskeletal model○ Linear optimal control○ Nonlinear stability analysis○ Region of attraction○ Nonlinear control design
![Page 4: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/4.jpg)
Tools● Linear programming● Quadratic programming● Semidefinite programming
○ Sum of squares Optimization
Software● SeDuMi: Solver of semidefinite programs
○ SDP○ LP, QP, etc.
● YALMIP○ Matlab wrapper for many solvers
Referenceshttp://www.stanford.edu/~boyd/cvxbook/
![Page 5: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/5.jpg)
Optimization
Problemsf(x) has local minimaslow convergence
Decision Variables
Scalar Objective
![Page 6: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/6.jpg)
Convex programming
No local minima (only 1 global minimum)
Definition of convex functions
Examples: linear function, quadratic, etc.x
f(x)
![Page 7: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/7.jpg)
Convex programming
Constraints from a convex set
Linear half-space also a convex setCombinations of linear constraints result in convex sets
x1
x2any straight line intersecting set always has only one contiguous region inside set, never crosses out and then back in
Convex Optimization, Stephen BoydConvex Analysis, Rockafellar
![Page 8: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/8.jpg)
Example: Fit model to data
t
y
trip
noisy data of recovery from trip
Quadratic Objectives
Linear Constraints
![Page 9: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/9.jpg)
Example: linear_guassian.m [sic]sdpvar Ahat % defines the unknown variableerr = ...objective = err'*err;constraints = [Ahat<=1, Ahat>=-1]; % defines allowable bounds on Ahat% yalmip is pretty smart and allows all sorts of convex constraintssolvesdp(constraints, objectives) % picks an appropriate solver and runs it% returns a structure showing how well it did
Very noisy data being fit with a first-order model
![Page 10: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/10.jpg)
Dynamics
Approximate inverse dynamics as QP
inertial matrixCoriolis, gravity Applied
torqueq1
q2
q3
![Page 11: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/11.jpg)
Example: approximate inverse dynamics
ground reaction forces
Quadratic program
![Page 12: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/12.jpg)
Solve arm muscle forces
muscle model based on:http://www.springerlink.com/content/j750t73548076000/?MUD=MP
![Page 13: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/13.jpg)
Solve arm muscle forcesload meas_arm_data; % previously provided data, including q_meas, qd_meas, etc.
n=length(t);
ahat = sdpvar(6,n); % define 6 x n matrix to be solved for
A = MuscleMapping; % matrix of moment arms of muscles
con =[];
for i=1:n
[H,C,B] = ArmDynamics(q_meas(:,i),qd_meas(:,i));
% ArmDynamics returns mass matrix, other terms numerically
con = [con; H*qdd_meas(:,i) + C - B*A*ahat(:,i) == 0];
end
obj = norm (ahat(:),2); % define quadratic objective
con = [con;ahat(:)>=0]; % with non-negativity constraints
solvesdp(con,obj) % puts soln in ahat
load true_arm_data;
plot(t,double(ahat(1,:)),t,a(1,:));
% note ahat is an object that can be cast into a
% double matrix
legend('ahat','a')
![Page 14: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/14.jpg)
Example: min max problem
convert to
Turn into a convex program by introducing new variable cThere are many ways to convert particular optimization problems (that don't necessarily look convex) into convex programs
This often arises when we have a piecewise linear objective function. We can write it like:
![Page 15: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/15.jpg)
Semidefinite programming
The set of semidefinite matrices is convex.Semidefinite matrix:
Convex combination of semidefinite matrices:
![Page 16: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/16.jpg)
Stability
Another option: Lyapunov stability
Convert into an SDP by optimizing a positive semi-definite matrix S that defines a Lyapunov function.Hard to check eigenvalues of A, but easier to find an S
meaning that we need an S such that
suggestion: use ^{\top} instead of ^T for transpose
Could check stability using
![Page 17: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/17.jpg)
Robust stabilitySuppose A is not known precisely, but that it has possible perturbations that can be expressed as a weighted sum of matrices.Now find an S (i.e. Lyapunov function) that yields a stable closed-loop system despite any weights/perturbations within defined allowable bounds.
Robust stability via Common-Lyapunov function
![Page 18: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/18.jpg)
Polynomial dynamics
Approximate ODE's state-derivative function with a polynomial in xAlso make V a polynomial in xWrite polynomial as sum of squares
![Page 19: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/19.jpg)
![Page 20: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/20.jpg)
Example: Test stability of a simple system%% Example 1
%% prove that \dot{x} = -x^3 is globally stable
sdpvar x;
f = -x^3;
V = x^2;
constraint = sos(-jacobian(V,x)*f);
sol = solvesos(constraint)
%% Example 2
%% prove that \dot(X) = -x + x^3 is stable for x in (-1,1)
sdpvar x;
f = -x + x^3;
V = x^2;
[lambda,c] = polynomial(x,2);
constraint = [sos(-jacobian(V,x)*f + lambda*(V-1)), sos(lambda)];
sol = solvesos(constraint,[],[],c)
x
xdot
1-1
![Page 21: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/21.jpg)
![Page 22: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/22.jpg)
S-procedure
To write as a SOS program, replace positivity with SOS where lambda is a polynomial in x of a specified degree
![Page 23: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/23.jpg)
Example: van der Pol Oscillator
Find region of attraction represented as a sum of squares
![Page 24: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/24.jpg)
Polynomial representation of equations of motion
H(s,c) sines and cosinesH(s,c) qddot - ... = B us^2 + c^2 = 1
Apply as a constraint!
![Page 26: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/26.jpg)
Examples from Dynamic Walking
● Fit return maps with linear model despite noisy sensors / animals
● Approximate inverse dynamics (w/ constraints)○ Find muscle activations to match data in
musculoskeletal model○ Linear optimal control○ Nonlinear stability analysis○ Region of attraction○ Nonlinear control design
![Page 27: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/27.jpg)
Tools● Linear programming● Quadratic programming● Semidefinite programming
○ Sum of squares Optimization
Software● SeDuMi: Solver of semidefinite programs
○ SDP○ LP, QP, etc.
● YALMIP○ Matlab wrapper for many solvers
Referenceshttp://www.stanford.edu/~boyd/cvxbook/
![Page 28: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/28.jpg)
Optimization
Problemsf(x) has local minimaslow convergence
Decision Variables
Scalar Objective
![Page 29: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/29.jpg)
Convex programming
No local minima (only 1 global minimum)
Definition of convex functions
Examples: linear function, quadratic, etc.x
f(x)
![Page 30: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/30.jpg)
Convex programming
Constraints from a convex set
Linear half-space also a convex setCombinations of linear constraints result in convex sets
x1
x2any straight line intersecting set always has only one contiguous region inside set, never crosses out and then back in
Convex Optimization, Stephen BoydConvex Analysis, Rockafellar
![Page 31: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/31.jpg)
Example: Fit model to data
t
y
trip
noisy data of recovery from trip
Quadratic Objectives
Linear Constraints
![Page 32: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/32.jpg)
Example: linear_guassian.m [sic]sdpvar Ahat % defines the unknown variableerr = ...objective = err'*err;constraints = [Ahat<=1, Ahat>=-1]; % defines allowable bounds on Ahat% yalmip is pretty smart and allows all sorts of convex constraintssolvesdp(constraints, objectives) % picks an appropriate solver and runs it% returns a structure showing how well it did
Very noisy data being fit with a first-order model
![Page 33: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/33.jpg)
Dynamics
Approximate inverse dynamics as QP
inertial matrixCoriolis, gravity Applied
torqueq1
q2
q3
![Page 34: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/34.jpg)
Example: approximate inverse dynamics
ground reaction forces
Quadratic program
![Page 35: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/35.jpg)
Solve arm muscle forces
muscle model based on:http://www.springerlink.com/content/j750t73548076000/?MUD=MP
![Page 36: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/36.jpg)
Solve arm muscle forcesload meas_arm_data; % previously provided data, including q_meas, qd_meas, etc.
n=length(t);
ahat = sdpvar(6,n); % define 6 x n matrix to be solved for
A = MuscleMapping; % matrix of moment arms of muscles
con =[];
for i=1:n
[H,C,B] = ArmDynamics(q_meas(:,i),qd_meas(:,i));
% ArmDynamics returns mass matrix, other terms numerically
con = [con; H*qdd_meas(:,i) + C - B*A*ahat(:,i) == 0];
end
obj = norm (ahat(:),2); % define quadratic objective
con = [con;ahat(:)>=0]; % with non-negativity constraints
solvesdp(con,obj) % puts soln in ahat
load true_arm_data;
plot(t,double(ahat(1,:)),t,a(1,:));
% note ahat is an object that can be cast into a
% double matrix
legend('ahat','a')
![Page 37: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/37.jpg)
Example: min max problem
convert to
Turn into a convex program by introducing new variable cThere are many ways to convert particular optimization problems (that don't necessarily look convex) into convex programs
This often arises when we have a piecewise linear objective function. We can write it like:
![Page 38: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/38.jpg)
Semidefinite programming
The set of semidefinite matrices is convex.Semidefinite matrix:
Convex combination of semidefinite matrices:
![Page 39: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/39.jpg)
Stability
Another option: Lyapunov stability
Convert into an SDP by optimizing a positive semi-definite matrix S that defines a Lyapunov function.Hard to check eigenvalues of A, but easier to find an S
meaning that we need an S such that
suggestion: use ^{\top} instead of ^T for transpose
Could check stability using
![Page 40: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/40.jpg)
Robust stabilitySuppose A is not known precisely, but that it has possible perturbations that can be expressed as a weighted sum of matrices.Now find an S (i.e. Lyapunov function) that yields a stable closed-loop system despite any weights/perturbations within defined allowable bounds.
Robust stability via Common-Lyapunov function
![Page 41: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/41.jpg)
Polynomial dynamics
Approximate ODE's state-derivative function with a polynomial in xAlso make V a polynomial in xWrite polynomial as sum of squares
![Page 42: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/42.jpg)
![Page 43: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/43.jpg)
Example: Test stability of a simple system%% Example 1
%% prove that \dot{x} = -x^3 is globally stable
sdpvar x;
f = -x^3;
V = x^2;
constraint = sos(-jacobian(V,x)*f);
sol = solvesos(constraint)
%% Example 2
%% prove that \dot(X) = -x + x^3 is stable for x in (-1,1)
sdpvar x;
f = -x + x^3;
V = x^2;
[lambda,c] = polynomial(x,2);
constraint = [sos(-jacobian(V,x)*f + lambda*(V-1)), sos(lambda)];
sol = solvesos(constraint,[],[],c)
x
xdot
1-1
![Page 44: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/44.jpg)
![Page 45: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/45.jpg)
S-procedure
To write as a SOS program, replace positivity with SOS where lambda is a polynomial in x of a specified degree
![Page 46: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/46.jpg)
Example: van der Pol Oscillator
Find region of attraction represented as a sum of squares
![Page 47: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/47.jpg)
Polynomial representation of equations of motion
H(s,c) sines and cosinesH(s,c) qddot - ... = B us^2 + c^2 = 1
Apply as a constraint!
![Page 49: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/49.jpg)
Examples from Dynamic Walking
● Fit return maps with linear model despite noisy sensors / animals
● Approximate inverse dynamics (w/ constraints)○ Find muscle activations to match data in
musculoskeletal model○ Linear optimal control○ Nonlinear stability analysis○ Region of attraction○ Nonlinear control design
![Page 50: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/50.jpg)
Tools● Linear programming● Quadratic programming● Semidefinite programming
○ Sum of squares Optimization
Software● SeDuMi: Solver of semidefinite programs
○ SDP○ LP, QP, etc.
● YALMIP○ Matlab wrapper for many solvers
Referenceshttp://www.stanford.edu/~boyd/cvxbook/
![Page 51: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/51.jpg)
Optimization
Problemsf(x) has local minimaslow convergence
Decision Variables
Scalar Objective
![Page 52: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/52.jpg)
Convex programming
No local minima (only 1 global minimum)
Definition of convex functions
Examples: linear function, quadratic, etc.x
f(x)
![Page 53: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/53.jpg)
Convex programming
Constraints from a convex set
Linear half-space also a convex setCombinations of linear constraints result in convex sets
x1
x2any straight line intersecting set always has only one contiguous region inside set, never crosses out and then back in
Convex Optimization, Stephen BoydConvex Analysis, Rockafellar
![Page 54: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/54.jpg)
Example: Fit model to data
t
y
trip
noisy data of recovery from trip
Quadratic Objectives
Linear Constraints
![Page 55: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/55.jpg)
Example: linear_guassian.m [sic]sdpvar Ahat % defines the unknown variableerr = ...objective = err'*err;constraints = [Ahat<=1, Ahat>=-1]; % defines allowable bounds on Ahat% yalmip is pretty smart and allows all sorts of convex constraintssolvesdp(constraints, objectives) % picks an appropriate solver and runs it% returns a structure showing how well it did
Very noisy data being fit with a first-order model
![Page 56: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/56.jpg)
Dynamics
Approximate inverse dynamics as QP
inertial matrixCoriolis, gravity Applied
torqueq1
q2
q3
![Page 57: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/57.jpg)
Example: approximate inverse dynamics
ground reaction forces
Quadratic program
![Page 58: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/58.jpg)
Solve arm muscle forces
muscle model based on:http://www.springerlink.com/content/j750t73548076000/?MUD=MP
![Page 59: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/59.jpg)
Solve arm muscle forcesload meas_arm_data; % previously provided data, including q_meas, qd_meas, etc.
n=length(t);
ahat = sdpvar(6,n); % define 6 x n matrix to be solved for
A = MuscleMapping; % matrix of moment arms of muscles
con =[];
for i=1:n
[H,C,B] = ArmDynamics(q_meas(:,i),qd_meas(:,i));
% ArmDynamics returns mass matrix, other terms numerically
con = [con; H*qdd_meas(:,i) + C - B*A*ahat(:,i) == 0];
end
obj = norm (ahat(:),2); % define quadratic objective
con = [con;ahat(:)>=0]; % with non-negativity constraints
solvesdp(con,obj) % puts soln in ahat
load true_arm_data;
plot(t,double(ahat(1,:)),t,a(1,:));
% note ahat is an object that can be cast into a
% double matrix
legend('ahat','a')
![Page 60: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/60.jpg)
Example: min max problem
convert to
Turn into a convex program by introducing new variable cThere are many ways to convert particular optimization problems (that don't necessarily look convex) into convex programs
This often arises when we have a piecewise linear objective function. We can write it like:
![Page 61: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/61.jpg)
Semidefinite programming
The set of semidefinite matrices is convex.Semidefinite matrix:
Convex combination of semidefinite matrices:
![Page 62: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/62.jpg)
Stability
Another option: Lyapunov stability
Convert into an SDP by optimizing a positive semi-definite matrix S that defines a Lyapunov function.Hard to check eigenvalues of A, but easier to find an S
meaning that we need an S such that
suggestion: use ^{\top} instead of ^T for transpose
Could check stability using
![Page 63: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/63.jpg)
Robust stabilitySuppose A is not known precisely, but that it has possible perturbations that can be expressed as a weighted sum of matrices.Now find an S (i.e. Lyapunov function) that yields a stable closed-loop system despite any weights/perturbations within defined allowable bounds.
Robust stability via Common-Lyapunov function
![Page 64: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/64.jpg)
Polynomial dynamics
Approximate ODE's state-derivative function with a polynomial in xAlso make V a polynomial in xWrite polynomial as sum of squares
![Page 65: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/65.jpg)
![Page 66: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/66.jpg)
Example: Test stability of a simple system%% Example 1
%% prove that \dot{x} = -x^3 is globally stable
sdpvar x;
f = -x^3;
V = x^2;
constraint = sos(-jacobian(V,x)*f);
sol = solvesos(constraint)
%% Example 2
%% prove that \dot(X) = -x + x^3 is stable for x in (-1,1)
sdpvar x;
f = -x + x^3;
V = x^2;
[lambda,c] = polynomial(x,2);
constraint = [sos(-jacobian(V,x)*f + lambda*(V-1)), sos(lambda)];
sol = solvesos(constraint,[],[],c)
x
xdot
1-1
![Page 67: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/67.jpg)
![Page 68: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/68.jpg)
S-procedure
To write as a SOS program, replace positivity with SOS where lambda is a polynomial in x of a specified degree
![Page 69: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/69.jpg)
Example: van der Pol Oscillator
Find region of attraction represented as a sum of squares
![Page 70: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/70.jpg)
Polynomial representation of equations of motion
H(s,c) sines and cosinesH(s,c) qddot - ... = B us^2 + c^2 = 1
Apply as a constraint!
![Page 72: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/72.jpg)
Examples from Dynamic Walking
● Fit return maps with linear model despite noisy sensors / animals
● Approximate inverse dynamics (w/ constraints)○ Find muscle activations to match data in
musculoskeletal model○ Linear optimal control○ Nonlinear stability analysis○ Region of attraction○ Nonlinear control design
![Page 73: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/73.jpg)
Tools● Linear programming● Quadratic programming● Semidefinite programming
○ Sum of squares Optimization
Software● SeDuMi: Solver of semidefinite programs
○ SDP○ LP, QP, etc.
● YALMIP○ Matlab wrapper for many solvers
Referenceshttp://www.stanford.edu/~boyd/cvxbook/
![Page 74: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/74.jpg)
Optimization
Problemsf(x) has local minimaslow convergence
Decision Variables
Scalar Objective
![Page 75: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/75.jpg)
Convex programming
No local minima (only 1 global minimum)
Definition of convex functions
Examples: linear function, quadratic, etc.x
f(x)
![Page 76: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/76.jpg)
Convex programming
Constraints from a convex set
Linear half-space also a convex setCombinations of linear constraints result in convex sets
x1
x2any straight line intersecting set always has only one contiguous region inside set, never crosses out and then back in
Convex Optimization, Stephen BoydConvex Analysis, Rockafellar
![Page 77: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/77.jpg)
Example: Fit model to data
t
y
trip
noisy data of recovery from trip
Quadratic Objectives
Linear Constraints
![Page 78: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/78.jpg)
Example: linear_guassian.m [sic]sdpvar Ahat % defines the unknown variableerr = ...objective = err'*err;constraints = [Ahat<=1, Ahat>=-1]; % defines allowable bounds on Ahat% yalmip is pretty smart and allows all sorts of convex constraintssolvesdp(constraints, objectives) % picks an appropriate solver and runs it% returns a structure showing how well it did
Very noisy data being fit with a first-order model
![Page 79: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/79.jpg)
Dynamics
Approximate inverse dynamics as QP
inertial matrixCoriolis, gravity Applied
torqueq1
q2
q3
![Page 80: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/80.jpg)
Example: approximate inverse dynamics
ground reaction forces
Quadratic program
![Page 81: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/81.jpg)
Solve arm muscle forces
muscle model based on:http://www.springerlink.com/content/j750t73548076000/?MUD=MP
![Page 82: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/82.jpg)
Solve arm muscle forcesload meas_arm_data; % previously provided data, including q_meas, qd_meas, etc.
n=length(t);
ahat = sdpvar(6,n); % define 6 x n matrix to be solved for
A = MuscleMapping; % matrix of moment arms of muscles
con =[];
for i=1:n
[H,C,B] = ArmDynamics(q_meas(:,i),qd_meas(:,i));
% ArmDynamics returns mass matrix, other terms numerically
con = [con; H*qdd_meas(:,i) + C - B*A*ahat(:,i) == 0];
end
obj = norm (ahat(:),2); % define quadratic objective
con = [con;ahat(:)>=0]; % with non-negativity constraints
solvesdp(con,obj) % puts soln in ahat
load true_arm_data;
plot(t,double(ahat(1,:)),t,a(1,:));
% note ahat is an object that can be cast into a
% double matrix
legend('ahat','a')
![Page 83: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/83.jpg)
Example: min max problem
convert to
Turn into a convex program by introducing new variable cThere are many ways to convert particular optimization problems (that don't necessarily look convex) into convex programs
This often arises when we have a piecewise linear objective function. We can write it like:
![Page 84: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/84.jpg)
Semidefinite programming
The set of semidefinite matrices is convex.Semidefinite matrix:
Convex combination of semidefinite matrices:
![Page 85: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/85.jpg)
Stability
Another option: Lyapunov stability
Convert into an SDP by optimizing a positive semi-definite matrix S that defines a Lyapunov function.Hard to check eigenvalues of A, but easier to find an S
meaning that we need an S such that
suggestion: use ^{\top} instead of ^T for transpose
Could check stability using
![Page 86: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/86.jpg)
Robust stabilitySuppose A is not known precisely, but that it has possible perturbations that can be expressed as a weighted sum of matrices.Now find an S (i.e. Lyapunov function) that yields a stable closed-loop system despite any weights/perturbations within defined allowable bounds.
Robust stability via Common-Lyapunov function
![Page 87: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/87.jpg)
Polynomial dynamics
Approximate ODE's state-derivative function with a polynomial in xAlso make V a polynomial in xWrite polynomial as sum of squares
![Page 88: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/88.jpg)
![Page 89: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/89.jpg)
Example: Test stability of a simple system%% Example 1
%% prove that \dot{x} = -x^3 is globally stable
sdpvar x;
f = -x^3;
V = x^2;
constraint = sos(-jacobian(V,x)*f);
sol = solvesos(constraint)
%% Example 2
%% prove that \dot(X) = -x + x^3 is stable for x in (-1,1)
sdpvar x;
f = -x + x^3;
V = x^2;
[lambda,c] = polynomial(x,2);
constraint = [sos(-jacobian(V,x)*f + lambda*(V-1)), sos(lambda)];
sol = solvesos(constraint,[],[],c)
x
xdot
1-1
![Page 90: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/90.jpg)
![Page 91: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/91.jpg)
S-procedure
To write as a SOS program, replace positivity with SOS where lambda is a polynomial in x of a specified degree
![Page 92: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/92.jpg)
Example: van der Pol Oscillator
Find region of attraction represented as a sum of squares
![Page 93: Convex Optimization - IHMC](https://reader030.vdocuments.us/reader030/viewer/2022012211/61df16e3c6323c3aaa4bc034/html5/thumbnails/93.jpg)
Polynomial representation of equations of motion
H(s,c) sines and cosinesH(s,c) qddot - ... = B us^2 + c^2 = 1
Apply as a constraint!