LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
map_optim_dist.m
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.
4%
5% Reference:
6% G. Horvath, "Measuring the distance between MAPs and some
7% applications," in Proc. ASMTA 2015, LNCS 9081, pp. 95-109.
8% https://link.springer.com/chapter/10.1007/978-3-319-18579-8_8
9%
10% Input:
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
15% L: number of lags
16%
17% Output:
18% B1: optimal D1 matrix
19% d: minimum distance achieved
20
21A0=MAPA{1}; A1=MAPA{2};
22NB = size(B0,1);
23a = sum(-A0,2);
24b = sum(-B0,2);
25Aeq = [kron(eye(NB),alB*inv(-B0)) ; kron(ones(1,NB),eye(NB))];
26beq = [alB';b];
27
28 function di = myfun(x)
29 B1x = reshape(x, NB, NB);
30 di = map_dist(MAPA,{B0,B1x},L,alA,alB);
31 end
32
33warning off;
34if L==1
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;
46else
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);
50end
51warning on;
52end