1function [D1B,d] = dmap_optim_dist(DMAPA,alA,D0B,alB,L)
2% [D1B,d]=dmap_optim_dist(DMAPA,alA,D0B,alB,L) - Find D1B minimizing the
3% lag-L joint PMF distance, given fixed D0B.
5% Reference (continuous-time formulation):
6% G. Horvath,
"Measuring the distance between MAPs and some
7% applications," in Proc. ASMTA 2015, LNCS 9081, pp. 95-109.
10% Discrete-time extension by QORE Lab (https:
13% DMAPA: reference D-MAP in the form of {D0,D1}
14% alA: stationary vector at arrivals for DMAPA
15% D0B: D0 matrix of the approximating D-MAP (fixed)
16% alB: stationary vector at arrivals for the approximating D-MAP
20% D1B: optimal D1 matrix
21% d: minimum distance achieved
23D0A=DMAPA{1}; D1A=DMAPA{2};
24NA = size(D0A,1); NB = size(D0B,1);
25IA = eye(NA); IB = eye(NB);
28Aeq = [kron(eye(NB),alB*inv(IB-D0B)) ; kron(ones(1,NB),eye(NB))];
31 function di = myfun(x)
32 D1Bx = reshape(x, NB, NB);
33 di = dmap_dist(DMAPA,{D0B,D1Bx},L,alA,alB);
38 Z_AB = dlyap(D0A', D0B, alA
'*alB);
39 Z_AA = dlyap(D0A', D0A, alA
'*alA);
40 Z_BB = dlyap(D0B', D0B, alB
'*alB);
41 X_AB = dlyap(D0A, D0B', a*b
');
42 X_AA = dlyap(D0A, D0A', a*a
');
43 X_BB = dlyap(D0B, D0B', b*b
');
44 vD1A = reshape(D1A,numel(D1A),1);
45 options = optimset('Display
','off
');
46 vD1B = quadprog(kron(X_BB,Z_BB), -vD1A'*kron(X_AB,Z_AB), [], [], Aeq, beq, 1e-6*ones(NB*NB,1), [], [], options);
47 D1B = reshape(vD1B, NB, NB);
48 d = vD1B
'*kron(X_BB,Z_BB)*vD1B + vD1A'*kron(X_AA,Z_AA)*vD1A - 2*vD1A
'*kron(X_AB,Z_AB)*vD1B;
50 options = optimset('Display
','off
');
51 [vD1B, d] = fmincon(@myfun, rand(NB*NB,1), [], [], Aeq, beq, 1e-6*ones(NB*NB,1), [], [], options);
52 D1B = reshape(vD1B, NB, NB);