Optimal Control CY3H2, Lecture notes by Victor M. Becerra, School of Systems Engineering, University of Reading
Heating a room using the least possible energy.
Find u over t in [0; 1] to minimize:
| J = |
| ∫ |
| u2 dt |
subject to:
| = −2*x + u |
| x(0) = 0, |
| x(1) = 10 |
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);
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.
figure(1);
subplot(2,1,1)
plot(t,x,'*-');
legend('Temperature');
subplot(2,1,2)
plot(t,u,'*-');
legend('Energy');