PROPT Second Order System
From TomWiki
Jump to navigationJump to search
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
subject to:
% 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');