lambda = 0.2:0.1:0.9;
mu = 1;
numEvents = 10000;
avgQueueLength = zeros(length(lambda), 1);
avgResponseTime = zeros(length(lambda), 1);
for i = 1:length(lambda)
arrivalTimes = cumsum(exprnd(1/lambda(i), numEvents, 1));
serviceTimes = exprnd(1/mu, numEvents, 1);
departureTimes = zeros(numEvents, 1);
for j = 1:numEvents
if j == 1
departureTimes(j) = arrivalTimes(j) + serviceTimes(j);
else
departureTimes(j) = max(arrivalTimes(j), departureTimes(j-1)) + serviceTimes(j);
end
end
responseTimes = departureTimes - arrivalTimes;
avgResponseTime(i) = mean(responseTimes);
avgQueueLength(i) = lambda(i) * avgResponseTime(i);
end
% Analytical model
rho = lambda / mu;
analyticalResponseTime = 1 ./ (mu - lambda);
analyticalQueueLength = rho .^ 2 ./ (1 - rho);
% Plot
figure;
subplot(2, 1, 1);
plot(lambda, avgResponseTime, 'o-', lambda, analyticalResponseTime, 'x-');
xlabel('λ');
ylabel('Average Response Time');
legend('Simulation', 'Analytical', 'Location', 'Best');
subplot(2, 1, 2);
plot(lambda, avgQueueLength, 'o-', lambda, analyticalQueueLength, 'x-');
xlabel('λ');
ylabel('Average Queue Length');
legend('Simulation', 'Analytical', 'Location', 'Best');
海神之光
- 粉丝: 5w+
- 资源: 6476
最新资源
- 5A90铝锂合金电子束焊接接头显微分析 - .pdf
- 5E83铝合金TIG焊接头残余应力分布研究 - .pdf
- 5万m-3LNG储罐9 Ni钢内罐焊接技术.pdf
- 6mm不锈钢对接焊接接头超声检测探讨.pdf
- 07MnNiVDR钢焊接热影响区再热脆化研究 - .pdf
- 07钢管相贯节点焊接缺陷类型及对极限承载力的影响.pdf
- 7A05铝合金激光-MIG复合焊接头组织分析 - .pdf
- 08Cr2AIMoSi板材焊接冷裂纹敏感性及焊后热处理试验.pdf
- 7N01-T4铝合金搅拌摩擦焊接头的组织和耐应力腐蚀性能 - .pdf
- 7N01铝合金焊接接头力学性能及静/动态失效分析 - .pdf
- 08采用冷轧带肋钢筋焊接网的抗震墙性能研究.pdf
- 8轴激光焊接实验平台的有限元分析及优化设计.pdf
- 09CrCuSb钢焊接材料选定及其焊接工艺 - .pdf
- 09MnNiDR低温钢的焊接工艺评定.pdf
- 09MnNiDR低温容器的焊接及热处理研究 - .pdf
- 09MnNiDR低温钢焊接性分析 - .pdf
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈