1function [B1,d] = map_optim_dist(MAPA,alA,B0,alB,L)
2% [B1,d]=map_optim_dist(MAPA,alA,B0,alB,L) - Find B1 minimizing the
3% lag-L joint density distance, given fixed B0.
6% G. Horvath,
"Measuring the distance between MAPs and some
7% applications," in Proc. ASMTA 2015, LNCS 9081, pp. 95-109.
11% MAPA: reference MAP in the form of {D0,D1}
12% alA: stationary vector at arrivals
for MAPA
13% B0: D0 matrix of the approximating MAP (fixed)
14% alB: stationary vector at arrivals
for the approximating MAP
18% B1: optimal D1 matrix
19% d: minimum distance achieved
21A0=MAPA{1}; A1=MAPA{2};
25Aeq = [kron(eye(NB),alB*inv(-B0)) ; kron(ones(1,NB),eye(NB))];
28 function di = myfun(x)
29 B1x = reshape(x, NB, NB);
30 di = map_dist(MAPA,{B0,B1x},L,alA,alB);
35 Z_AB = lyap(A0', B0, alA
'*alB);
36 Z_AA = lyap(A0', A0, alA
'*alA);
37 Z_BB = lyap(B0', B0, alB
'*alB);
38 X_AB = lyap(A0, B0', a*b
');
39 X_AA = lyap(A0, A0', a*a
');
40 X_BB = lyap(B0, B0', b*b
');
41 vA1 = reshape(A1,numel(A1),1);
42 options = optimset('Display
','off
');
43 vB1 = quadprog(kron(X_BB,Z_BB), -vA1'*kron(X_AB,Z_AB), [], [], Aeq, beq, 1e-6*ones(NB*NB,1), [], [], options);
44 B1 = reshape(vB1, NB, NB);
45 d = vB1
'*kron(X_BB,Z_BB)*vB1 + vA1'*kron(X_AA,Z_AA)*vA1 - 2*vA1
'*kron(X_AB,Z_AB)*vB1;
47 options = optimset('Display
','off
');
48 [vB1, d] = fmincon(@myfun, rand(NB*NB,1), [], [], Aeq, beq, 1e-6*ones(NB*NB,1), [], [], options);
49 B1 = reshape(vB1, NB, NB);