PROPT Turbo Generator
From TomWiki
Jump to navigationJump to search
This page is part of the PROPT Manual. See PROPT Manual. |
OCCAL - A Mixed symbolic-numeric Optimal Control CALcluator
Section 4 Example 1
Problem Formulation
Find u over t in [0; t ] to minimize
subject to:
The initial condition are:
% Copyright (c) 2007-2008 by Tomlab Optimization Inc.
Problem setup
toms t
p = tomPhase('p', t, 0, 20, 30);
setPhase(p);
tomStates x1 x2 x3 x4
tomControls u1 u2
% Initial guess
x0i = [0.60295;0;1.87243;0.79778];
x0 = {icollocate({x1 == x0i(1); x2 == x0i(2)
x3 == x0i(3); x4 == x0i(4)})
collocate({u1 == 0; u2 == 0})};
% Boundary constraints
cbnd = initial({x1 == x0i(1); x2 == x0i(2)
x3 == x0i(3); x4 == x0i(4)});
% ODEs and path constraints
u1s = 0.80; u2s = 0.73962;
A = 0.17; c = 0;
s4 = 0; s5 = 0;
M = 0.04225; alpha1 = 2.5;
alpha2 = 1.0; alpha3 = 0.1;
beta1 = 1.0; beta2 = 1.0;
kappa_d = 0.02535;
ceq = collocate({dot(x1) == x2.*x4
dot(x2) == 1/M.*(u1-s4*x1.*x4-s5*x1.*x3-kappa_d*x2)
dot(x3) == u2-A*x3+c*x4; dot(x4) == -x1.*x2});
% Objective
objective = integrate(alpha1*( (x1-x0i(1)).^2 + ...
(x4-x0i(4)).^2) + alpha2*x2.^2 + alpha3*(x3-x0i(3)).^2 + ...
beta1*(u1-u1s).^2 + beta2*(u2-u2s).^2);
Solve the problem
options = struct;
options.name = 'Turbo Generator';
solution = ezsolve(objective, {cbnd, ceq}, x0, options);
t = subs(collocate(t),solution);
x1 = subs(collocate(x1),solution);
x2 = subs(collocate(x2),solution);
x3 = subs(collocate(x3),solution);
x4 = subs(collocate(x4),solution);
u1 = subs(collocate(u1),solution);
u2 = subs(collocate(u2),solution);
Problem type appears to be: qpcon Time for symbolic processing: 0.17864 seconds Starting numeric solver ===== * * * =================================================================== * * * TOMLAB - TOMLAB Development license 999007. Valid to 2011-12-31 ===================================================================================== Problem: --- 1: Turbo Generator f_k 15.019841547670794000 sum(|constr|) 0.000000000046608960 f(x_k) + sum(|constr|) 15.019841547717403000 f(x_0) -57.012069754799789000 Solver: snopt. EXIT=0. INFORM=1. SNOPT 7.2-5 NLP code Optimality conditions satisfied FuncEv 1 ConstrEv 35 ConJacEv 35 Iter 23 MinorIter 119 CPU time: 0.046800 sec. Elapsed time: 0.048000 sec.
Plot result
subplot(2,1,1)
plot(t,x1,'*-',t,x2,'*-',t,x3,'*-',t,x4,'*-');
legend('x1','x2','x3','x4');
title('Turbo Generator state variables');
subplot(2,1,2)
plot(t,u1,'+-',t,u2,'+-');
legend('u1','u2');
title('Turbo Generator control');