PROPT Temperature Control

From TomWiki
Jump to navigationJump to search

Notice.png

This page is part of the PROPT Manual. See PROPT Manual.

Optimal Control CY3H2, Lecture notes by Victor M. Becerra, School of Systems Engineering, University of Reading

Heating a room using the least possible energy.

Problem Description

Find u over t in [0; 1] to minimize:


subject to:



% Copyright (c) 2009-2009 by Tomlab Optimization Inc.

Problem setup

toms t
p = tomPhase('p', t, 0, 1, 20);
setPhase(p);

tomStates x
tomControls u

% Initial guess
x0 = {icollocate(x == 10*t)
    collocate(u == 1)};

% Box constraints
cbox = collocate(0 <= u);

% Boundary constraints
cbnd = {initial(x == 0)
    final(x == 10)};

% ODEs and path constraints
ceq = collocate(dot(x) == -2*x+u);

% Objective
objective = 0.5*integrate(u^2);

Solve the problem

options = struct;
options.name = 'Temperature Control';
solution = ezsolve(objective, {cbox, cbnd, ceq}, x0, options);
t = subs(collocate(t),solution);
x = subs(collocate(x),solution);
u = subs(collocate(u),solution);
Problem type appears to be: qp
Time for symbolic processing: 0.030845 seconds
Starting numeric solver
===== * * * =================================================================== * * *
TOMLAB - TOMLAB Development license  999007. Valid to 2011-12-31
=====================================================================================
Problem:  1: Temperature Control                f_k     203.731472072683000000
                                       sum(|constr|)      0.000000000059135659
                              f(x_k) + sum(|constr|)    203.731472072742150000
                                              f(x_0)      0.000000000000000000

Solver: CPLEX.  EXIT=0.  INFORM=1.
CPLEX Barrier QP solver
Optimal solution found

FuncEv    9 GradEv    9 ConstrEv    9 Iter    9 
Elapsed time: 0.003000 sec. 

Plot result

figure(1);
subplot(2,1,1)
plot(t,x,'*-');
legend('Temperature');
subplot(2,1,2)
plot(t,u,'*-');
legend('Energy');

TemperatureControl 01.png