Queue simulation of two parallel servers
Show older comments
I've got a problem where I need to simulate o production line which consists of 3 stations having 1 machine each. Each machine serving time follows a specific distribution. The products pass one station after the other in series, and the code I wrote is the below.
hours_day = 8;
days_year = 220;
arrival_rate = 4; %per hour
arrival_rate_m = 4/60; %per minute
minutes_year = 60 * hours_day * days_year;
for y=1:10000
inter_arrival_times(y) = exprnd(1/arrival_rate_m);
arrival_times(y) = sum(inter_arrival_times(1:end)); % generate the arrival times of products for a year
if arrival_times(y)>minutes_year
break
end
end
m1_start = arrival_times(1); % first product arriving at station 1
for i=1:length(arrival_times)-1
m1_serve_time(i) = unifrnd(m1_min,m1_max); % machine in station 1 serve time
m1_finish(i) = m1_start(i) + m1_serve_time(i); % machine in station 1 finish processing
m1_start(i+1) = max(arrival_times(i+1),m1_finish(i)); % machine in station 1 start processing of next
end
m2_start(1) = m1_finish(1); % first product arriving at station 2 (the first to finish from station 1)
for j=1:length(arrival_times)-2
m2_serve_time(j) = unifrnd(m2_min,m2_max); % machine in station 2 serve time
m2_finish(j) = m2_start(j) + m2_serve_time(j); % machine in station 2 finish processing
m2_start(j+1) = max(m1_finish(j+1),m2_finish(j)); % machine in station 2 start processing of next
end
m3_start(1) = m2_finish(1); % first product arriving at station 3 (the first to finish from station 2)
for k=1:length(arrival_times)-3
m3_serve_time(k) = normrnd(m3_mean,m3_std); % machine in station 3 serve time
m3_finish(k) = m3_start(k) + m3_serve_time(k); % machine in station 3 finish processing
m3_start(k+1) = max(m2_finish(k+1),m3_finish(k)); % machine in station 3 start processing of next
end
This is like an MM1 simulation but with 3 "servers" in series.
Now I want to simulate what would happen if we add a second machine in station 1 that has the same servning characteristics as the other one (same distribution and parameters), and so they can process products in parallel.
Is it possible to do that in the way I developed the code until now, and if so how can this be done?
Any helpful idea is really welcome.
Thank you in advance!
Accepted Answer
More Answers (0)
Categories
Find more on Desktop in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!