LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
ld_joint_dependence.m
1clear node jobclass
2
3% Joint-dependent (LJD) model example
4% Service rate scaling depends on per-class population vector (n1, n2)
5% Scaling table is stored as linearized lookup table
6
7N1 = 3; % number of class-1 jobs
8N2 = 2; % number of class-2 jobs
9
10%% Create model
11model = Network('JointDependenceModel');
12node{1} = Delay(model, 'Delay');
13node{2} = Queue(model, 'Queue1', SchedStrategy.PS);
14
15jobclass{1} = ClosedClass(model, 'Class1', N1, node{1}, 0);
16jobclass{2} = ClosedClass(model, 'Class2', N2, node{1}, 0);
17
18node{1}.setService(jobclass{1}, Exp.fitMean(1.0));
19node{1}.setService(jobclass{2}, Exp.fitMean(2.0));
20node{2}.setService(jobclass{1}, Exp.fitMean(1.5));
21node{2}.setService(jobclass{2}, Exp.fitMean(2.5));
22
23% Define cutoffs for per-class population
24cutoffs = [N1, N2]; % max population per class
25
26% Create scaling table for joint dependence
27% Table size = (N1+1) * (N2+1) = 4 * 3 = 12
28% Linearized index: idx = 1 + n1 + n2*(N1+1) (MATLAB 1-indexed)
29
30% Example scaling: more jobs of either class -> lower scaling (higher congestion)
31% Row-major order would be: (0,0), (1,0), (2,0), (3,0), (0,1), ...
32% But we use column-major linearization for the lookup
33scalingTable = zeros(1, prod(cutoffs + 1));
34for n1 = 0:N1
35 for n2 = 0:N2
36 idx = ljd_linearize([n1, n2], cutoffs);
37 % Example: scaling decreases as total population increases
38 totalN = n1 + n2;
39 if totalN == 0
40 scalingTable(idx) = 1.0;
41 elseif totalN <= 2
42 scalingTable(idx) = 1.0 / totalN; % slower service with more jobs
43 else
44 scalingTable(idx) = 0.5 / totalN; % even slower at high load
45 end
46 end
47end
48
49% Set joint dependence on Queue1
50node{2}.setJointDependence(scalingTable, cutoffs);
51
52% Routing
53P = model.initRoutingMatrix();
54P{1,1} = model.serialRouting(node);
55P{2,2} = model.serialRouting(node);
56model.link(P);
57
58%% Solve with MVA (qd method supports LJD)
59fprintf('Solving joint-dependent model with MVA (qd):\n');
60AvgTableMVA = MVA(model, 'method', 'qd').getAvgTable;
61disp(AvgTableMVA);
62
63%% For comparison, solve an equivalent load-dependent model
64% This is just for validation - not exact equivalence
65fprintf('\nNote: Joint dependence allows class-specific scaling.\n');
66fprintf('This example uses total population scaling as a simpler illustration.\n');