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.

Contents

Problem Description

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

$$ J = \frac{1}{2} \int_0^{1} u^2 \mathrm{d}t $$

subject to:

$$ \frac{dx}{dt} = -2*x + u $$

$$ x(0) = 0, $$

$$ x(1) = 10 $$

% 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
===== * * * =================================================================== * * *
TOMLAB - Tomlab Optimization Inc. Development license  999001. Valid to 2010-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 

Plot result

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