PROPT Second Order System: Difference between revisions
No edit summary |
|||
| Line 113: | Line 113: | ||
[[File:secondOrderSystem_01.png]] | [[File:secondOrderSystem_01.png]] | ||
[[Category:PROPT Examples]] | |||
Latest revision as of 05:30, 14 February 2012
|
This page is part of the PROPT Manual. See PROPT Manual. |
Users Guide for dyn.Opt, Example 1
Optimal control of a second order system
End time says 1 in problem text.
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 = \int_0^{2} u^2/2 \mathrm{d}t }
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_1}{dt} = x_2 }
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_2}{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 x_1(0) = 1 }
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_1(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_2(0) = 1 }
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(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 -100 <= u <= 100 }
% Copyright (c) 2007-2008 by Tomlab Optimization Inc.Problem setup
toms t
p = tomPhase('p', t, 0, 2, 30);
setPhase(p);
tomStates x1 x2
tomControls u
% Initial guess
x0 = {icollocate({x1 == 1-t/2; x2 == -1+t/2})
collocate(u == -3.5+6*t/2)};
% Box constraints
cbox = {-100 <= icollocate(x1) <= 100
-100 <= icollocate(x2) <= 100
-100 <= collocate(u) <= 100};
% Boundary constraints
cbnd = {initial({x1 == 1; x2 == 1})
final({x1 == 0; x2 == 0})};
% ODEs and path constraints
ceq = collocate({dot(x1) == x2; dot(x2) == u});
% Objective
objective = integrate(u.^2/2);Solve the problem
options = struct;
options.name = 'Second Order System';
solution = ezsolve(objective, {cbox, cbnd, ceq}, x0, options);
t = subs(collocate(t),solution);
x1 = subs(collocate(x1),solution);
x2 = subs(collocate(x2),solution);
u = subs(collocate(u),solution);Problem type appears to be: qp
Time for symbolic processing: 0.050283 seconds
Starting numeric solver
===== * * * =================================================================== * * *
TOMLAB - TOMLAB Development license 999007. Valid to 2011-12-31
=====================================================================================
Problem: 1: Second Order System f_k 3.249999999994048800
sum(|constr|) 0.000000000461823724
f(x_k) + sum(|constr|) 3.250000000455872700
f(x_0) 0.000000000000000000
Solver: CPLEX. EXIT=0. INFORM=1.
CPLEX Barrier QP solver
Optimal solution found
FuncEv 6 GradEv 6 ConstrEv 6 Iter 6
Elapsed time: 0.004000 sec.
Plot result
subplot(2,1,1)
plot(t,x1,'*-',t,x2,'*-');
legend('x1','x2');
title('Second Order System state variables');
subplot(2,1,2)
plot(t,u,'+-');
legend('u');
title('Second Order System control');