PROPT Turbo Generator: Difference between revisions

From TomWiki
Jump to navigationJump to search
(Created page with "{{Part Of Manual|title=the PROPT Manual|link=PROPT Manual}} OCCAL - A Mixed symbolic-numeric Optimal Control CALcluator Section 4 Example 1 ==Problem Formulation== ...")
 
No edit summary
Line 10: Line 10:


<math> J = \int_0^{t} (alpha_1*( (x_1-x_1^{s})^2 + (x_4-x_4^{s})^2) + </math>
<math> J = \int_0^{t} (alpha_1*( (x_1-x_1^{s})^2 + (x_4-x_4^{s})^2) + </math>
<math> alpha_2*x_2^{2} + alpha_3*(x_3-x_3^{s})^{2} + </math>
<math> alpha_2*x_2^{2} + alpha_3*(x_3-x_3^{s})^{2} + </math>
<math> beta_1*(u_1-u_1^{s})^{2} + beta_2*(u_2-u_2^{s})^{2} ) \mathrm{d}t </math>
<math> beta_1*(u_1-u_1^{s})^{2} + beta_2*(u_2-u_2^{s})^{2} ) \mathrm{d}t </math>


subject to:
subject to:


<math> \frac{dx_1}{dt} = x_2*x_4 </math>
<math> \frac{dx_1}{dt} = x_2*x_4 </math>
<math> \frac{dx_2}{dt} = \frac{1}{M}*(u_1-s_4*x_1*x_4-s_5*x_1*x_3-kappa_d*x_2</math>
<math> \frac{dx_2}{dt} = \frac{1}{M}*(u_1-s_4*x_1*x_4-s_5*x_1*x_3-kappa_d*x_2</math>
<math> \frac{dx_3}{dt} = u_2-A*x_3+c*x_4 </math>
<math> \frac{dx_3}{dt} = u_2-A*x_3+c*x_4 </math>
<math> \frac{dx_4}{dt} = -x_1*x_2 </math>
<math> \frac{dx_4}{dt} = -x_1*x_2 </math>


The initial condition are:
The initial condition are:


<math> x(0)  = [x_1^{s} \ x_2^{s} \ x_3^{s} \ x_4^{s}] </math>
<math> x(0)  = [x_1^{s} \ x_2^{s} \ x_3^{s} \ x_4^{s}] </math>
<math> x_{1:4}^{s} = [0.60295 \ 0.0 \ 1.87243 \ 0.79778] </math>
<math> x_{1:4}^{s} = [0.60295 \ 0.0 \ 1.87243 \ 0.79778] </math>
<math> alpha = [2.5 \ 1.0 \ 0.1] </math>
<math> alpha = [2.5 \ 1.0 \ 0.1] </math>
<math> beta = [1.0 \ 1.0] </math>
<math> beta = [1.0 \ 1.0] </math>
<math> M = 0.04225 </math>
<math> M = 0.04225 </math>
<math> s_{4:5} = [0.0 \ 0.0] </math>
<math> s_{4:5} = [0.0 \ 0.0] </math>
<math> c = 0 </math>
<math> c = 0 </math>
<math> A = 0.17 </math>
<math> A = 0.17 </math>
<math> u_{1:2}^{s} = [0.80 \ 0.73962] </math>
<math> u_{1:2}^{s} = [0.80 \ 0.73962] </math>
<math> kappa_d = 0.02535 </math>
<math> kappa_d = 0.02535 </math>


<source lang="matlab">
<source lang="matlab">

Revision as of 08:13, 9 November 2011

Notice.png

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

TurboGenerator 01.png