PROPT Linear Problem with Bang Bang Control: Difference between revisions
From TomWiki
Jump to navigationJump to search
(Created page with "{{Part Of Manual|title=the PROPT Manual|link=PROPT Manual}} Problem 5a: Miser3 manual ==Problem description== Find u over t in [0; 1 ] to minimize <math> J = \in...") |
|||
(3 intermediate revisions by one other user not shown) | |||
Line 1: | Line 1: | ||
{{Part Of Manual|title=the PROPT | {{Part Of Manual|title=the PROPT Manual|link=[[PROPT|PROPT Manual]]}} | ||
Problem 5a: Miser3 manual | Problem 5a: Miser3 manual | ||
Line 8: | Line 8: | ||
<math> J = \int_{0}^{1} -6*x_1-12*x_2+3*u_1+u_2 \mathrm{d}t </math> | <math> J = \int_{0}^{1} -6*x_1-12*x_2+3*u_1+u_2 \mathrm{d}t </math> | ||
subject to: | subject to: | ||
<math> \frac{dx_1}{dt} = u_2 </math> | <math> \frac{dx_1}{dt} = u_2 </math> | ||
<math> \frac{dx_2}{dt} = -x_1+u_1 </math> | <math> \frac{dx_2}{dt} = -x_1+u_1 </math> | ||
<math> x_1(0) = 1 </math> | <math> x_1(0) = 1 </math> | ||
<math> x_2(0) = 0 </math> | <math> x_2(0) = 0 </math> | ||
<math> |u| <= 10 </math> | <math> |u| <= 10 </math> | ||
<source lang="matlab"> | <source lang="matlab"> | ||
Line 68: | Line 74: | ||
<pre> | <pre> | ||
Problem type appears to be: mip | Problem type appears to be: mip | ||
Time for symbolic processing: 0. | Time for symbolic processing: 0.04476 seconds | ||
Starting numeric solver | Starting numeric solver | ||
===== * * * =================================================================== * * * | ===== * * * =================================================================== * * * | ||
Line 83: | Line 89: | ||
FuncEv 30 GradEv 27 HessEv 19 | FuncEv 30 GradEv 27 HessEv 19 | ||
CPU time: 0. | CPU time: 0.046800 sec. Elapsed time: 0.168000 sec. | ||
</pre> | </pre> | ||
Line 100: | Line 106: | ||
title('Linear Problem Bang control'); | title('Linear Problem Bang control'); | ||
</source> | </source> | ||
[[File:linearProblemBang_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. |
Problem 5a: Miser3 manual
Problem description
Find u over t in [0; 1 ] to minimize
subject to:
% Copyright (c) 2007-2010 by Tomlab Optimization Inc.
Problem setup
toms t
p = tomPhase('p', t, 0, 1, 30);
setPhase(p);
tomStates x1 x2
tomControls -integer u1 u2
% Initial guess
x0 = {icollocate({x1 == 1; x2 == 0})
collocate({u1 == 0; u2 == 0})};
% Box constraints
cbox = {-10 <= icollocate(x1) <= 10
-10 <= icollocate(x2) <= 10
-10 <= collocate(u1) <= 10
-10 <= collocate(u2) <= 10};
% Boundary constraints
cbnd = initial({x1 == 1; x2 == 0});
% ODEs and path constraints
ceq = collocate({dot(x1) == u2
dot(x2) == -x1+u1});
% Objective
objective = integrate(-6*x1-12*x2+3*u1+u2);
Solve the problem
options = struct;
options.name = 'Linear Problem Bang';
options.solver = 'knitro';
solution = ezsolve(objective, {cbox, cbnd, ceq}, x0, options);
t = subs(collocate(t),solution);
x1 = subs(collocate(x1),solution);
x2 = subs(collocate(x2),solution);
u1 = subs(collocate(u1),solution);
u2 = subs(collocate(u2),solution);
Problem type appears to be: mip Time for symbolic processing: 0.04476 seconds Starting numeric solver ===== * * * =================================================================== * * * TOMLAB - TOMLAB Development license 999007. Valid to 2011-12-31 ===================================================================================== Problem: --- 1: Linear Problem Bang f_k -41.377652164326122000 sum(|constr|) 0.000000200077248423 f(x_k) + sum(|constr|) -41.377651964248876000 f(x_0) -5.999999999999976900 Solver: KNITRO. EXIT=0. INFORM=0. Default MINLP KNITRO Locally optimal solution found FuncEv 30 GradEv 27 HessEv 19 CPU time: 0.046800 sec. Elapsed time: 0.168000 sec.
Plot result
subplot(2,1,1)
plot(t,x1,'*-',t,x2,'*-');
legend('x1','x2');
title('Linear Problem Bang state variables');
subplot(2,1,2)
plot(t,u1,'+-',t,u2,'+-');
legend('u1','u2');
title('Linear Problem Bang control');