Second Order System
Users Guide for dyn.Opt, Example 1
Optimal control of a second order system
End time says 1 in problem text.
Contents
Problem Formulation
Find u over t in [0; 2 ] to minimize
subject to:
% Copyright (c) 2007-2008 by Tomlab Optimization Inc.
Problem setup
toms t p = tomPhase('p', t, 0, 2, 30); setPhase(p); tomStates x1 x2 tomControls u % Initial guess x0 = {icollocate({x1 == 1-t/2; x2 == -1+t/2}) collocate(u == -3.5+6*t/2)}; % Box constraints cbox = {-100 <= icollocate(x1) <= 100 -100 <= icollocate(x2) <= 100 -100 <= collocate(u) <= 100}; % Boundary constraints cbnd = {initial({x1 == 1; x2 == 1}) final({x1 == 0; x2 == 0})}; % ODEs and path constraints ceq = collocate({dot(x1) == x2; dot(x2) == u}); % Objective objective = integrate(u.^2/2);
Solve the problem
options = struct;
options.name = 'Second Order System';
solution = ezsolve(objective, {cbox, cbnd, ceq}, x0, options);
t = subs(collocate(t),solution);
x1 = subs(collocate(x1),solution);
x2 = subs(collocate(x2),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: Second Order System f_k 3.249999999999416500 sum(|constr|) 0.000000000379195508 f(x_k) + sum(|constr|) 3.250000000378611800 f(x_0) 0.000000000000000000 Solver: CPLEX. EXIT=0. INFORM=1. CPLEX Barrier QP solver Optimal solution found FuncEv 6 GradEv 6 ConstrEv 6 Iter 6
Plot result
subplot(2,1,1) plot(t,x1,'*-',t,x2,'*-'); legend('x1','x2'); title('Second Order System state variables'); subplot(2,1,2) plot(t,u,'+-'); legend('u'); title('Second Order System control');