1function [ T, newdim, dim_notbusy ] = generateService( services, service_h, C, S )
3% C: limit in the difference between the shortest and longest queue lengths;
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))
9dim = length(service_h.beta);
10m = length(services.tau_st);
12indexes_notbusy = build_index(m,1);
13dim_NB = size(indexes_notbusy,1);
18dim_notbusy = dim_C*dim_NB;
20T = zeros(newdim+dim_notbusy,newdim+dim_notbusy);
21t = zeros(newdim+dim_notbusy,1);
23t(end-dim_NB+1:end) = services.St;
25T(1:newdim,1:newdim) = S;
27%% S_long: the job in the shorter queue completes service
28S_long = zeros(dim,dim_NB);
32 countvect = service_h.service_phases(row,:);
34 for i = m+1:2*m % the starting phase
37 tovect = countvect(1:m);
39 col = vectmatch(tovect,indexes_notbusy);
41 % the job in the shorter queue completes service
42 S_long(row,col) = S_long(row,col)+countvect(i)*services.St(i-m);
49 T((row-1)*dim+1:row*dim,newdim+(row-1)*dim_NB+1:newdim+row*dim_NB) = S_long;
52%% S_last: all queues have the same length
53S_last = zeros(dim,dim_NB);
57 countvect = service_h.service_phases(row,:);
63 tovect = countvect((2-k)*m+1:(2-k+1)*m);
65 col = vectmatch(tovect,indexes_notbusy);
67 S_last(row,col) = S_last(row,col)+countvect(i)*services.St(i-(k-1)*m);
74T((dim_C-1)*dim+1:dim_C*dim,newdim+(dim_C-1)*dim_NB+1:newdim+dim_C*dim_NB) = S_last;
76%% only one subtask in service
79 T(newdim+(row-1)*dim_NB+1:newdim+row*dim_NB,newdim+(row-1)*dim_NB+1:newdim+row*dim_NB) = services.ST;
82A = -sum(services.ST,2)*services.tau_st;
85 T(newdim+(row-1)*dim_NB+1:newdim+row*dim_NB,newdim+row*dim_NB+1:newdim+(row+1)*dim_NB) = A;
88for row = newdim+1 : newdim+dim_notbusy
90 T(row,row) = -sum(T(row,:))-t(row);