Tracking an Oscillator#
This example involves a time-varying optimization algorithm (from Tracking). The optimal solution \(\{\beta^*_k\}\) orbits about a constant point \(\beta^*_{\text{center}}\) with a frequency of \(\omega = \frac{\pi}{8}\) radians per time step.
The optimization problem is to minimize the sum of four quadratics. Each quadratic \(f_{ik}\) shares the same shift,
The path of the optimal solution obeys known linear dynamics: there exists a state \(\eta\) such that
The algorithm is defined in terms of parameters \(b_0 \in \R^3, b_1 \in \R, b_2 \in \R\). An execution of this algorithm with \(\beta \in \R^{4}\) is plotted in Figure 1.
Figure 1: Algorithm with oscillating target#
Figure 1: Algorithm with oscillating target#
The subdifferentials \(w\) vectors approach at constant value. The iterates \(z\) oscillate according to the moving optimal solution.
1%tracking of optimal solution
2
3m = [1, 1, 1, 1];
4L = [2, 4, 6, 8];
5s = length(m);
6
7
8omega = pi/8;
9Sbeta = blkdiag(1, givens(cos(omega), sin(omega)));
10Rbeta = [1, 1, 0];
11
12
13d = 4; %dimensionality of the problem
14%low for illustration
15
16
17%tracking of the solution
18SA = kron(Sbeta, eye(d));
19SAy = kron(Rbeta, eye(d));
20eta0 = [randi(201, [d, 1]) - 100;
21 (randi(31, [2*d, 1]) + 60).*sign(2*rand(2*d, 1) - 1)];
22
23shift = @(k) SAy * (SA^k) * eta0;
24
25%% assign the quadratics
26M = cell(s, 1);
27bstar_center = cell(s, 1);
28bstar = cell(s, 1);
29op_list = cell(s, 1);
30
31
32for i = 1:s
33 M{i} = rand_quad(d, m(i), L(i));
34 bstar_center{i} = randi(21, [d, 1]) - 10;
35 bstar{i} = @(k) bstar_center{i} - shift(k);
36
37 op_list{i}= op_sim_quad(M{i}, bstar{i});
38end
39
40%static parameters
41b0 = [-0.05; -0.1; -0.05];
42b1 = -0.05;
43b2 = -0.1;
44
45AK = Sbeta;
46BK = b0 * ones(1, s);
47CK = ones(s, 1) * Rbeta;
48
49DK = zeros(s);
50DK(end, :)= DK(end, :) + b1;
51DK(:, 1)= DK(:, 1) + b2;
52
53
54K = ss(AK, BK, CK, DK, 1);
55
56
57sys = opt_system(op_list, [], K);
58
59%% execute the algorithm
60
61T = 80;
62sim = alg_sim(sys, d);
63ssim= sim.sim(T);
64
65%% plot the outputs
66plt = alg_plotter(ssim);
67plt.plot_6f();
See also
Analysis of the tracking algorithm.