LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
lcq_threehosts.m
1clear solver AvgTable;
2% Example of Layered Network with a multi-level cache
3
4model = LayeredNetwork('LQNwithCaching');
5nusers = 1;
6ntokens = 1;
7%% client
8P1 = Processor(model, 'P1', 1, SchedStrategy.PS);
9T1 = Task(model, 'T1', nusers, SchedStrategy.REF).on(P1);
10E1 = Entry(model, 'E1').on(T1);
11
12%% cachetask
13totalitems = 4;
14cachecapacity = [1 1];
15pAccess = DiscreteSampler((1/totalitems)*ones(1,totalitems));
16PC = Processor(model, 'Pc', 1, SchedStrategy.PS);
17C2 = CacheTask(model, 'CT', totalitems, cachecapacity, ReplacementStrategy.RR, ntokens).on(PC);
18I2 = ItemEntry(model, 'IE', totalitems, pAccess).on(C2);
19
20P3 = Processor(model, 'P2', 1, SchedStrategy.PS);
21T3 = Task(model, 'T2', 1, SchedStrategy.FCFS).on(P3);
22E3 = Entry(model, 'E2').on(T3);
23A3 = Activity(model, 'A2', Exp(5.0)).on(T3).boundTo(E3).repliesTo(E3);
24
25%% definition of activities
26A1 = Activity(model, 'A1', Immediate()).on(T1).boundTo(E1).synchCall(I2,1);
27AC2 = Activity(model, 'Ac', Immediate()).on(C2).boundTo(I2);
28AC2h = Activity(model, 'Ac_hit', Exp(1.0)).on(C2).repliesTo(I2);
29AC2m = Activity(model, 'Ac_miss', Exp(0.5)).on(C2).synchCall(E3,1).repliesTo(I2);
30
31C2.addPrecedence(ActivityPrecedence.CacheAccess(AC2, {AC2h, AC2m}));
32
33lnoptions = LN.defaultOptions;
34lnoptions.verbose = 1;
35options = NC.defaultOptions;
36options.verbose = 0;
37solver{1} = LN(model, @(model) NC(model, options), lnoptions);
38AvgTable{1} = solver{1}.getAvgTable;
39AvgTable{1}
40
41options2 = MVA.defaultOptions;
42options2.verbose = 0;
43solver{2} = LN(model, @(model) MVA(model, options2), lnoptions);
44AvgTable{2} = solver{2}.getAvgTable;
45AvgTable{2}
46