PROPT A Linear Problem with Bang Bang Control: Difference between revisions

From TomWiki
Jump to navigationJump to search
No edit summary
No edit summary
 
(5 intermediate revisions by one other user not shown)
Line 6: Line 6:


EXAMPLE-1: A TEXTBOOK BANG-BANG OPTIMAL CONTROL PROBLEM
EXAMPLE-1: A TEXTBOOK BANG-BANG OPTIMAL CONTROL PROBLEM
[[File:]]


==Problem description==
==Problem description==
Line 14: Line 12:


<math> J = t_F </math>
<math> J = 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</math>
<math> \frac{dx_2}{dt} = u</math>


<math> x_1(0) = 0 </math>
<math> x_1(0) = 0 </math>
<math> x_1(t_F) = 300 </math>
<math> x_1(t_F) = 300 </math>
<math> x_2(0) = 0 </math>
<math> x_2(0) = 0 </math>
<math> x_2(t_F) = 0 </math>
<math> x_2(t_F) = 0 </math>


<math> -2 <= u <= 1 </math>
<math> -2 <= u <= 1 </math>


<source lang="matlab">
<source lang="matlab">
% Copyright (c) 2007-2008 by Tomlab Optimization Inc.
% Copyright (c) 2007-2008 by Tomlab Optimization Inc.
</source>
</source>
[[File:]]


==Problem setup==
==Problem setup==
Line 65: Line 69:
objective = t_f;
objective = t_f;
</source>
</source>
[[File:]]


==Solve the problem==
==Solve the problem==
Line 83: Line 85:
<pre>
<pre>
Problem type appears to be: lpcon
Problem type appears to be: lpcon
Time for symbolic processing: 0.089256 seconds
Time for symbolic processing: 0.077603 seconds
Starting numeric solver
Starting numeric solver
===== * * * =================================================================== * * *
===== * * * =================================================================== * * *
Line 98: Line 100:


FuncEv    1 ConstrEv  526 ConJacEv  526 Iter  136 MinorIter  185
FuncEv    1 ConstrEv  526 ConJacEv  526 Iter  136 MinorIter  185
CPU time: 0.249602 sec. Elapsed time: 0.243000 sec.  
CPU time: 0.234002 sec. Elapsed time: 0.234000 sec.  


</pre>
</pre>
[[File:]]


==Plot result==
==Plot result==
Line 118: Line 118:
</source>
</source>


[[File:]]
[[File:bangBangFreeTime_01.png]]
 
[[Category:PROPT Examples]]

Latest revision as of 04:42, 14 February 2012

Notice.png

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');

BangBangFreeTime 01.png