PROPT Pendulum Gravity Estimation: Difference between revisions
No edit summary |
No edit summary |
||
| Line 10: | Line 10: | ||
<math> J = \frac{1}{2}*((x_{t_f}-x_{f_{meas}})^2 + (y_{t_f}-y_{f_{meas}})^2) </math> | <math> J = \frac{1}{2}*((x_{t_f}-x_{f_{meas}})^2 + (y_{t_f}-y_{f_{meas}})^2) </math> | ||
subject to: | subject to: | ||
<math> \frac{dx}{dt} = u </math> | <math> \frac{dx}{dt} = u </math> | ||
<math> \frac{dy}{dt} = v </math> | <math> \frac{dy}{dt} = v </math> | ||
<math> \frac{du}{dt} = lambda*x/m </math> | <math> \frac{du}{dt} = lambda*x/m </math> | ||
<math> \frac{dv}{dt} = lambda*y/m-g </math> | <math> \frac{dv}{dt} = lambda*y/m-g </math> | ||
<math> x^2 + y^2 - L^2 = 0 </math> | <math> x^2 + y^2 - L^2 = 0 </math> | ||
<math> [x_0 \ y_0 \ u_0 \ v_0] = [0.4 \ -0.3 \ 0 \ 0] </math> | <math> [x_0 \ y_0 \ u_0 \ v_0] = [0.4 \ -0.3 \ 0 \ 0] </math> | ||
<math> [x_{f_{meas}} \ y_{f_{meas}}] = [-0.231625 \ -0.443109] </math> | <math> [x_{f_{meas}} \ y_{f_{meas}}] = [-0.231625 \ -0.443109] </math> | ||
<math> L = 0.5 </math> | <math> L = 0.5 </math> | ||
<math> m = 0.3 </math> | <math> m = 0.3 </math> | ||
<source lang="matlab"> | <source lang="matlab"> | ||
Revision as of 07:11, 9 November 2011
|
This page is part of the PROPT Manual. See PROPT Manual. |
User's Guide for DIRCOL
Problem 2.5 Pendulum
Problem Formulation
Find u over t in [0; 2 ] to minimize
Failed to parse (SVG with PNG fallback (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle J = \frac{1}{2}*((x_{t_f}-x_{f_{meas}})^2 + (y_{t_f}-y_{f_{meas}})^2) }
subject to:
Failed to parse (SVG with PNG fallback (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle \frac{dx}{dt} = u }
Failed to parse (SVG with PNG fallback (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle \frac{dy}{dt} = v }
Failed to parse (SVG with PNG fallback (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle \frac{du}{dt} = lambda*x/m }
Failed to parse (SVG with PNG fallback (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle \frac{dv}{dt} = lambda*y/m-g }
Failed to parse (SVG with PNG fallback (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle x^2 + y^2 - L^2 = 0 }
Failed to parse (SVG with PNG fallback (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle [x_0 \ y_0 \ u_0 \ v_0] = [0.4 \ -0.3 \ 0 \ 0] }
Failed to parse (SVG with PNG fallback (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle [x_{f_{meas}} \ y_{f_{meas}}] = [-0.231625 \ -0.443109] }
Failed to parse (SVG with PNG fallback (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle L = 0.5 }
Failed to parse (SVG with PNG fallback (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle m = 0.3 }
% Copyright (c) 2007-2008 by Tomlab Optimization Inc.Problem setup
toms t g
% Initial guess
gopt = 20;
xopt = 0.4-(0.4+0.231625)*t/2;
yopt = -0.3-(-0.3+0.443109)*t/2;
uopt = 0;
vopt = 0;
lambdaopt = -5;
for n=[20 51]
p = tomPhase('p', t, 0, 2, n);
setPhase(p);
tomStates x y u v
tomControls lambda
% Initial guess
x0 = {g == gopt
icollocate({
x == xopt
y == yopt
u == uopt
v == vopt})
collocate(lambda == lambdaopt)};
% Box constraints
cbox = {1 <= g <= 100};
% Boundary constraints
cbnd = initial({x == 0.4; y == -0.3
u == 0; v == 0});
L = 0.5;
m = 0.3;
xmeas = -0.231625;
ymeas = -0.443109;
% ODEs and path constraints
ceq = collocate({
dot(x) == u
dot(y) == v
dot(u) == lambda.*x/m
dot(v) == lambda.*y/m-g
x.^2 + y.^2 - L^2 == 0});
% Objective
objective = 1/2*((final(x)-xmeas)^2+(final(y)-ymeas)^2);Solve the problem
options = struct;
options.name = 'Pendulum Gravity';
solution = ezsolve(objective, {cbox, cbnd, ceq}, x0, options);
gopt = subs(g, solution);
xopt = subs(x, solution);
yopt = subs(y, solution);
uopt = subs(u, solution);
vopt = subs(v, solution);
lambdaopt = subs(lambda, solution);Problem type appears to be: qpcon
Time for symbolic processing: 0.14939 seconds
Starting numeric solver
===== * * * =================================================================== * * *
TOMLAB - TOMLAB Development license 999007. Valid to 2011-12-31
=====================================================================================
Problem: --- 1: Pendulum Gravity f_k 0.000000017178935982
sum(|constr|) 0.000001384358823592
f(x_k) + sum(|constr|) 0.000001401537759574
f(x_0) -0.124997863253000020
Solver: snopt. EXIT=0. INFORM=1.
SNOPT 7.2-5 NLP code
Optimality conditions satisfied
FuncEv 1 ConstrEv 98 ConJacEv 98 Iter 43 MinorIter 96
CPU time: 0.078000 sec. Elapsed time: 0.088000 sec.
Problem type appears to be: qpcon
Time for symbolic processing: 0.15159 seconds
Starting numeric solver
===== * * * =================================================================== * * *
TOMLAB - TOMLAB Development license 999007. Valid to 2011-12-31
=====================================================================================
Problem: --- 1: Pendulum Gravity f_k 0.000000000017699578
sum(|constr|) 0.000000032138058518
f(x_k) + sum(|constr|) 0.000000032155758096
f(x_0) -0.124997846074064280
Solver: snopt. EXIT=0. INFORM=1.
SNOPT 7.2-5 NLP code
Optimality conditions satisfied
FuncEv 1 ConstrEv 13 ConJacEv 13 Iter 12 MinorIter 190
CPU time: 0.202801 sec. Elapsed time: 0.200000 sec.
endShow result
disp(sprintf('Gravity estimated to %g',gopt));Gravity estimated to 9.82655