PROPT A Linear Problem with Bang Bang Control
From TomWiki
Jump to navigationJump to search
This page is part of the PROPT Manual. See PROPT Manual. |
Paper: Solving Tough Optimal Control Problems by Network Enabled Optimization Server (NEOS)
Jinsong Liang, YangQuan Chen, Max Q.-H. Meng, Rees Fullmer Utah State University and Chinese University of Hong Kong (Meng)
EXAMPLE-1: A TEXTBOOK BANG-BANG OPTIMAL CONTROL PROBLEM
Problem description
Find u over t in [0; t_F ] to minimize
subject to:
% Copyright (c) 2007-2008 by Tomlab Optimization Inc.
Problem setup
toms t
toms t_f
p = tomPhase('p', t, 0, t_f, 30);
setPhase(p);
tomStates x1 x2
tomControls u
% Initial guess
% Note: The guess for t_f must appear in the list before expression involving t.
x0 = {t_f == 20
icollocate({x1 == 300*t/t_f; x2 == 0})
collocate(u==1-2*t/t_f)};
% Box constraints
cbox = {10 <= t_f <= 40
-2 <= collocate(u) <= 1};
% Boundary constraints
cbnd = {initial({x1 == 0; x2 == 0})
final({x1 == 300; x2 == 0})};
% ODEs and path constraints
ceq = collocate({dot(x1) == x2; dot(x2) == u});
% Objective
objective = t_f;
Solve the problem
options = struct;
options.name = 'Bang-Bang Free Time';
options.prilev = 1;
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: lpcon Time for symbolic processing: 0.077603 seconds Starting numeric solver ===== * * * =================================================================== * * * TOMLAB - TOMLAB Development license 999007. Valid to 2011-12-31 ===================================================================================== Problem: --- 1: Bang-Bang Free Time f_k 30.019823270451951000 sum(|constr|) 0.000028878815331636 f(x_k) + sum(|constr|) 30.019852149267283000 f(x_0) 20.000000000000000000 Solver: snopt. EXIT=0. INFORM=1. SNOPT 7.2-5 NLP code Optimality conditions satisfied FuncEv 1 ConstrEv 526 ConJacEv 526 Iter 136 MinorIter 185 CPU time: 0.234002 sec. Elapsed time: 0.234000 sec.
Plot result
subplot(2,1,1)
plot(t,x1,'*-',t,x2,'*-');
legend('x1','x2');
title('Bang-Bang Free Time state variables');
subplot(2,1,2)
plot(t,u,'+-');
legend('u');
title('Bang-Bang Free Time control');