LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
kpcfit_auto.m
1function [MAP,fac,fbc,kpcMAPs,otherMAPs, otherFACs, otherFBCs, otherSubMAPs]=kpcfit_auto(trace, varargin)
2% [MAP,fac,fbc,kpcMAPs] = kpcfit_auto(T,'option1',val1,'option2',val2,...)
3%
4% DESCRIPTION
5% Automatic fitting of trace T into a Markovian Arrival Process based on
6% the Kronecker Product Composition (KPC) method.
7%
8% INPUT
9% T - data structure returned by kpcfit_init
10%
11% OUTPUT
12% MAP - fitted MAP
13% fac - best-found objective function value for autocorrelation fitting (smaller = better)
14% fbc - best-found objective function value for bicorrelation fitting (smaller = better)
15% kpcMAPs - MAP(2)s to were composed by Kronecker products to define MAP
16%
17% EXAMPLE
18% T = kpcfit_init(S)
19% MAP = kpcfit_auto(T,'NumMAPs',3,'MaxIterAC',10)
20%
21% OPTION LIST
22% 'OnlyAC' - if 1 fitting is performed on moments and autocorrelations
23% 'NumStates' - integer, equals log2(number of states of the final MAP), default: BIC heuristic
24% 'NumMAPs' - integer, equals log2(number of states of the final MAP), default: BIC heuristic
25% 'MaxRunsAC' - maximum number of autocorrelation fitting runs (run = optimization program execution)
26% 'MaxRunsBC' - maximum number of bicovariance fitting runs
27% 'MaxIterAC' - integer, maximum number of iterations for a single autocorrelation fitting run
28% 'MaxIterBC' - integer, maximum number of iterations for a single bicovariance fitting run
29% 'MaxResAC' - maximum number of autocorrelation fitting runs further considered in bicovariance fitting
30% 'ACLags' - autocorrelation lags to be fitted (e.g., 1:10)
31% 'BCGridLags' - lags defining bicovariance grid to be fitted (e.g., 1:5 gives a 25 points grid 1:5x1:5)
32% 'MaxRetMaps' - maximum number of MAPs returned
33% 'ParallelBC' - enable parallelization of BC runs
34%
35% REFERENCES
36% [1] G.Casale, E.Z.Zhang, E.Smirni. Trace Data Characterization and Fitting
37% for Markov Modeling, Elsevier Performance Evaluation, 67(2):61-79,
38% Feb 2010.
39%
40% [2] G.Casale, E.Z.Zhang, E.Smirni. KPC-Toolbox: Simple Yet Effective Trace
41% Fitting Using Markovian Arrival Processes. in Proc. of QEST 2008,
42% 83-92, St.Malo, France, IEEE Press, September 2008.
43%
44
45%% options
46OptionNames = [
47 'OnlyAC ';
48 'NumStates ';
49 'NumMAPs ';
50 'MaxIterAC ';
51 'MaxIterBC ';
52 'MaxRunsAC ';
53 'AnimateAC ';
54 'MaxRunsBC ';
55 'MaxResAC ';
56 'MaxRetMAPs';
57 'ParallelBC';
58 ];
59
60OptionTypes = [
61 'numeric';
62 'numeric';
63 'numeric';
64 'numeric';
65 'numeric';
66 'numeric';
67 'numeric';
68 'numeric';
69 'numeric';
70 'numeric';
71 'numeric'];
72
73OptionValues = [];
74for i = 1:size(OptionNames,1)
75 options.(deblank(OptionNames(i,:)))=[];
76end
77
78% Default settings
79options.OnlyAC = false;
80options.AnimateAC = false;
81options.NumMAPs = [];
82options.NumStates = [];
83options.MaxIterAC = 300; % iterate up to 300 times to fit autocorrelations
84options.MaxIterBC = 10; % iterate up to 10 times to fit bicorrelations
85options.MaxRunsAC = 50; % maximum number of runs for AC fitting
86options.MaxRunsBC = 30; % maximum number of runs for AC fitting
87options.MaxResAC = min([options.MaxRunsAC,10]); % maximum number of values returned for AC fitting
88options.MaxRetMAPs = 1; % maximum number of MAPs returned
89options.ParallelBC = 0; % parallelize BC runs
90
91% Parse Optional Parameters
92options=ParseOptPara(options,OptionNames,OptionTypes,OptionValues,varargin);
93if mod(options.NumStates,2) > 0
94 error('error: requested %d states, but kpc-toolbox can return only a number of states that is a power of 2');
95end
96if isempty(options.NumMAPs)
97 options.NumMAPs = ceil(log2(options.NumStates));
98end
99
100disp('** KPC fitting algorithm initialized **');
101%% fitting algorithm run parameterization
102% order
103if isempty(options.NumMAPs) % if MAP order not given, use automatic BIC selection
104 disp('init: performing order selection');
105 try
106 options.NumMAPs = kpcfit_sub_bic(trace.ACFull,[2 4 8 16 32 64 128]);
107 catch
108 fprintf(2, "BIC order selection failed. Using 3 MAPs\n");
109 options.NumMAPs = 3;
110 end
111end
112fprintf(1,'init: kpc-toolbox will search for a MAP with 2^%d=%d states\n',options.NumMAPs,2^options.NumMAPs);
113%% fitting
114disp('fitting: running KPC-based fitting script');
115[MAP,fac,fbc,kpcMAPs,otherMAPs, otherFACs, otherFBCs, otherSubMAPs]=kpcfit_manual(options.NumMAPs, ...
116 trace.E, ...
117 trace.AC, ...
118 trace.ACLags, ...
119 trace.BC, ...
120 trace.BCLags, ...
121 'MaxIterAC',options.MaxIterAC, ...
122 'MaxRunsAC',options.MaxRunsAC, ...
123 'MaxResAC',options.MaxResAC, ...
124 'MaxRunsBC',options.MaxRunsBC, ...
125 'MaxIterBC',options.MaxIterBC, ...
126 'OnlyAC',options.OnlyAC, ...
127 'AnimateAC',options.AnimateAC, ...
128 'MaxRetMAPs', options.MaxRetMAPs, ...
129 'ParallelBC', options.ParallelBC);
130
131%% display final moments and autocorrelations
132disp('** KPC fitting algorithm completed ** ');
133disp(' ');
134disp(' Moments Comparison ');
135disp(' Original Trace Fitted MAP');
136format long e
137for k=1:length(trace.E)
138 disp([trace.E(k) map_moment(MAP,k)]);
139end
140disp(' ');
141disp(' Autocorrelation Comparison ');
142disp(' Lag Original Trace Fitted MAP');
143format long e
144for k=1:min([10,length(trace.ACLags)])
145 disp([trace.ACLags(k) trace.AC(k) map_acf(MAP,k)]);
146end
147
148end