# Increase optimization processing speed

As you know, sometimes numerically solving of optimization problems takes several minutes. For this reason 2 question came up to me:

1 - When one is abort the optimization procedure, how it is possible to obtain latest updated variables? For example, consider the code below: (get data matrices from here)

      imp = Import["data_matrices.mat", "LabeledData"];
Atilt = "A0" /. imp;
Btilt = "M1" /. imp;
Ctilt = "M2" /. imp;

T = 0.01;

Xp = {{x + y*(T/2), y*T}, {1, 1}};
Arbar = Atilt + Btilt.Xp.Ctilt;

Ghat = Ctilt.Inverse[(IdentityMatrix[102] /. 1 -> z) - Arbar].Btilt;

(* Ghat = {{g11, g12},{g21, g22}} *)
g11 = Part[Ghat, 1, 1] /. z -> Exp[I w];
g12 = Part[Ghat, 1, 2] /. z -> Exp[I w];
g21 = Part[Ghat, 2, 1] /. z -> Exp[I w];
g22 = Part[Ghat, 2, 2] /. z -> Exp[I w];

(* find H_infty norm of Ghat *)
f[x_, y_, w_] := Max[{Abs[g11] + Abs[g12], Abs[g21] + Abs[g22]}];

g[x_?NumberQ, y_?NumberQ] := NMaximize[{Evaluate[f[x, y, w]], 0 <= w <= 2.Pi}, {w, 0, 2.Pi}][[1]];

FindMinimum[{g[x, y], 0.5 <= x <= 1.7, 0.7 <= y <= 1.3}, {x, 1}, {y, 1}]


If I abort the optimization, how can I find the latest x and y? (Is this a correct question?!)

2 - How can I change the code above to increase optimization processing speed?

Any ideas would be appreciated.

Data matrices: As it's obvious the data_matrices.mat(A0,M1,M2) created in MATLAB environment.

  del = 1;
h = 0.01;   % Obtain discrete-time system; transfer function and state-space realization

numG = 1; denG = conv([1 1],1);
G = tf(numG,denG);
Gd = c2d(G,h,'zoh');
[numGd,den] = tfdata(Gd,'v');
k = del/h;
denGd = conv(den,[1 zeros(1,k)]);
Gd = tf(numGd,denGd,h);

ssGd = canon(Gd,'companion');
A = ssGd.A; B = ssGd.B; C = ssGd.C;
m = size(A);

A0 = cell(2,2); Ar{1,1} = A; Ar{1,2} = zeros(m(1),1); Ar{2,1} = zeros(1,m(1)); Ar{2,2} = zeros(1,1);
Br = cell(2,2); Br{1,1} = -B; Br{1,2} = zeros(m(1),1); Br{2,1} = zeros(1,1); Br{2,2} = ones(1);
Cr = cell(2,2); Cr{1,1} = C; Cr{2,1} = zeros(1,m(1)); Cr{1,2} = zeros(1,1); Cr{2,2} = ones(1);
M1 = cell2mat(Br);
M2 = cell2mat(Cr);

-
For your first question, you can collect the latest used x and y with the StepMonitor option of FindMinimum. – halirutan Mar 2 '14 at 16:08
Btw, it would be incredible helpful if you could provide a way to create a data_matrices.mat which can be used to run and test the code. Otherwise, it will be hard to give you help for optimization. – halirutan Mar 2 '14 at 16:11
@halirutan Thanks for StepMonitor. I added details about data matrices.mat file. – user2667048 Mar 2 '14 at 16:42