LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
generateService.m
1function [ T, newdim, dim_notbusy ] = generateService( services, service_h, C, S )
2
3% C: limit in the difference between the shortest and longest queue lengths;
4%
5% For example: for the case K = 2 servers, C = 2, phases are ordered as
6% (2,(1,0,1)), (2,(1,1,0)), (2,(2,0,0)), (1,(0,0,1)) (1,(0,1,0))
7% (1,(1,0,0)), S
8
9dim = length(service_h.beta);
10m = length(services.tau_st);
11
12indexes_notbusy = build_index(m,1);
13dim_NB = size(indexes_notbusy,1);
14
15dim_C = C+1;
16
17newdim = dim_C*dim;
18dim_notbusy = dim_C*dim_NB;
19
20T = zeros(newdim+dim_notbusy,newdim+dim_notbusy);
21t = zeros(newdim+dim_notbusy,1);
22
23t(end-dim_NB+1:end) = services.St;
24
25T(1:newdim,1:newdim) = S;
26
27%% S_long: the job in the shorter queue completes service
28S_long = zeros(dim,dim_NB);
29
30for row = 1 : dim
31
32 countvect = service_h.service_phases(row,:);
33
34 for i = m+1:2*m % the starting phase
35 if countvect(i) > 0
36
37 tovect = countvect(1:m);
38
39 col = vectmatch(tovect,indexes_notbusy);
40
41 % the job in the shorter queue completes service
42 S_long(row,col) = S_long(row,col)+countvect(i)*services.St(i-m);
43
44 end
45 end
46end
47
48for row = 1 : dim_C-1
49 T((row-1)*dim+1:row*dim,newdim+(row-1)*dim_NB+1:newdim+row*dim_NB) = S_long;
50end
51
52%% S_last: all queues have the same length
53S_last = zeros(dim,dim_NB);
54
55for row = 1 : dim
56
57 countvect = service_h.service_phases(row,:);
58
59 for k = 1 : 2
60 for i = (k-1)*m+1:k*m
61 if countvect(i) > 0
62
63 tovect = countvect((2-k)*m+1:(2-k+1)*m);
64
65 col = vectmatch(tovect,indexes_notbusy);
66
67 S_last(row,col) = S_last(row,col)+countvect(i)*services.St(i-(k-1)*m);
68
69 end
70 end
71 end
72end
73
74T((dim_C-1)*dim+1:dim_C*dim,newdim+(dim_C-1)*dim_NB+1:newdim+dim_C*dim_NB) = S_last;
75
76%% only one subtask in service
77
78for row = 1 : dim_C
79 T(newdim+(row-1)*dim_NB+1:newdim+row*dim_NB,newdim+(row-1)*dim_NB+1:newdim+row*dim_NB) = services.ST;
80end
81
82A = -sum(services.ST,2)*services.tau_st;
83
84for row = 1 : dim_C-1
85 T(newdim+(row-1)*dim_NB+1:newdim+row*dim_NB,newdim+row*dim_NB+1:newdim+(row+1)*dim_NB) = A;
86end
87
88for row = newdim+1 : newdim+dim_notbusy
89 T(row,row) = 0;
90 T(row,row) = -sum(T(row,:))-t(row);
91end
92