# TOMLAB  
# REGISTER (TOMLAB)
# LOGIN  
# myTOMLAB
TOMLAB LOGO

« Previous « Start » Next »

109  Temperature Control

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

Heating a room using the least possible energy.

109.1  Problem Description

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

J = 
1
2
 
1


0
 u2 dt 


subject to:

dx
dt
 = −2*x + u 


x(0) = 0, 
x(1) = 10 


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

109.3  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
Starting numeric solver
===== * * * =================================================================== * * *
TOMLAB - Tomlab Optimization Inc. Development license  999001. Valid to 2011-02-05
=====================================================================================
Problem:  1: Temperature Control                f_k     203.731472072763980000
                                       sum(|constr|)      0.000000000046672914
                              f(x_k) + sum(|constr|)    203.731472072810650000
                                              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
CPU time: 0.093750 sec. Elapsed time: 0.063000 sec.

109.4  Plot result

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

pngs/temperatureControl_01.png

« Previous « Start » Next »