PROPT Linear Pendulum: Difference between revisions
From TomWiki
Jump to navigationJump to search
No edit summary |
No edit summary |
||
Line 64: | Line 64: | ||
<pre> | <pre> | ||
Problem type appears to be: lp | Problem type appears to be: lp | ||
Time for symbolic processing: 0. | Time for symbolic processing: 0.02984 seconds | ||
Starting numeric solver | Starting numeric solver | ||
===== * * * =================================================================== * * * | ===== * * * =================================================================== * * * | ||
Line 79: | Line 79: | ||
FuncEv 206 Iter 206 | FuncEv 206 Iter 206 | ||
CPU time: 0.031200 sec. Elapsed time: 0. | CPU time: 0.031200 sec. Elapsed time: 0.013000 sec. | ||
</pre> | </pre> |
Revision as of 09:06, 8 November 2011
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');