%% Discrete-time LQ-optimal control on a fixed horizong with fixed final state %% % Based on Example 2.2.2 from the second edition of Lewis's book. The latest % (3rd) edition % Lewis, Frank L., Draguna Vrabie, and Vassilis L. Syrmo. Optimal Control. 3rd ed. John Wiley & Sons, 2012, freely downloadable at the author's web page https://lewisgroup.uta.edu/FL%20books/Lewis%20optimal%20control%203rd%20edition%202012.pdf % no longer contains the example. %% Model of the system and parameterization of the cost function rN = 3000000; % The reference value at the end. N = 30; % The length of the time horizon. x0= 0; % The initial state. A = 1.07; % The state-space model "matrix". B = 1; % --//-- R = 1; % The penalty on control. Not needed in the scalar case. %% Computing the weighted finite-time Gramian and computing the optimal control sequence k = 0:N-1; G = sum(A.^(2*(N-1-k))); % The finite-time reachability gramian. Simplified for the scalar case. u = A.^(N-1-k)/G*(rN-A^N); %% Plotting the responses figure(1) stem(u) set(gca,'FontSize',12) xlabel('Year','FontSize',12) ylabel('Anual investment [CZK]','FontSize',12) % print -depsc2 ../lectures/figures/saving_strategy.eps % !epstopdf ../lectures/figures/saving_strategy.eps