PROPT Linear Pendulum: Difference between revisions
From TomWiki
Jump to navigationJump to search
No edit summary |
|||
(One intermediate revision by one other user not shown) | |||
Line 10: | Line 10: | ||
<math> J = x_1(t_f) </math> | <math> J = x_1(t_f) </math> | ||
subject to: | subject to: | ||
<math> \frac{dx_1}{dt} = x_2 </math> | <math> \frac{dx_1}{dt} = x_2 </math> | ||
<math> \frac{dx_2}{dt} = u-x_1 </math> | <math> \frac{dx_2}{dt} = u-x_1 </math> | ||
<math> x(t_0) = [0 \ 0] </math> | <math> x(t_0) = [0 \ 0] </math> | ||
<math> |u| <= 1 </math> | <math> |u| <= 1 </math> | ||
<source lang="matlab"> | <source lang="matlab"> | ||
Line 103: | Line 108: | ||
[[File:linearPendulum_01.png]] | [[File:linearPendulum_01.png]] | ||
[[Category:PROPT Examples]] |
Latest revision as of 05:22, 14 February 2012
This page is part of the PROPT Manual. See PROPT Manual. |
Viscocity Solutions of Hamilton-Jacobi Equations and Optimal Control Problems. Alberto Bressan, S.I.S.S.A, Trieste, Italy.
A linear pendulum problem controlled by an external force.
Problem Description
Find u over t in [0; 20 ] to maximize:
subject to:
% Copyright (c) 2007-2008 by Tomlab Optimization Inc.
Problem setup
toms t
t_f = 20;
p = tomPhase('p', t, 0, t_f, 60);
setPhase(p);
tomStates x1 x2
tomControls u
% Initial guess
x0 = {icollocate({x1 == 0; x2 == 0})
collocate(u == 0)};
% Box constraints and bounds
cb = {-1 <= collocate(u) <= 1
initial(x1 == 0)
initial(x2 == 0)};
% ODEs and path constraints
ceq = collocate({dot(x1) == x2
dot(x2) == u-x1});
% Objective
objective = -final(x1);
Solve the problem
options = struct;
options.name = 'Linear Pendulum';
solution = ezsolve(objective, {cb, 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: lp Time for symbolic processing: 0.02984 seconds Starting numeric solver ===== * * * =================================================================== * * * TOMLAB - TOMLAB Development license 999007. Valid to 2011-12-31 ===================================================================================== Problem: --- 1: Linear Pendulum f_k -12.612222977985969000 sum(|constr|) 0.000000000002757663 f(x_k) + sum(|constr|) -12.612222977983212000 f(x_0) 0.000000000000000000 Solver: CPLEX. EXIT=0. INFORM=1. CPLEX Dual Simplex LP solver Optimal solution found FuncEv 206 Iter 206 CPU time: 0.031200 sec. Elapsed time: 0.013000 sec.
Plot result
subplot(3,1,1)
plot(t,x1,'*-',t,x2,'*-');
legend('x1','x2');
title('Linear Pendulum state variables');
subplot(3,1,2)
plot(t,u,'+-');
legend('u');
title('Linear Pendulum control');
subplot(3,1,3)
plot(t,sign(sin(t_f-t)),'*-');
legend('Known u');
title('Linear Pendulum known solution');