版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、排隊(duì)系統(tǒng)仿真實(shí)驗(yàn)1. 實(shí)驗(yàn)?zāi)康碾x散事件系統(tǒng)大量存在于現(xiàn)實(shí)生活中。離散事件系統(tǒng)往往是隨機(jī)的,具有復(fù)雜的變化關(guān)系,難以用常規(guī)的微分方程、差分方程等模型來(lái)描述,計(jì)算機(jī)仿真技術(shù)是解決這類問題的有效手段。排隊(duì)系統(tǒng)是一種非常重要的離散事件系統(tǒng),也是最早研究的離散事件系統(tǒng)。本實(shí)驗(yàn)通過設(shè)計(jì)一種最簡(jiǎn)單的單服務(wù)臺(tái)排隊(duì)系統(tǒng)仿真程序,深入理解排隊(duì)系統(tǒng)的建模與仿真方法,掌握排隊(duì)系統(tǒng)仿真的基本步驟和程序設(shè)計(jì)技術(shù),了解離散事件系統(tǒng)仿真的一般原理。2. 排隊(duì)系統(tǒng)仿真程序功能模擬一個(gè)單服務(wù)臺(tái)單隊(duì)列排隊(duì)系統(tǒng)的運(yùn)行過程,完成一定數(shù)量活動(dòng)實(shí)體的服務(wù)過程,輸出排隊(duì)系統(tǒng)的常用統(tǒng)計(jì)指標(biāo)。仿真運(yùn)行時(shí)間(可由活動(dòng)實(shí)體數(shù)確定)、活動(dòng)實(shí)體到達(dá)平均
2、時(shí)間間隔、平均服務(wù)時(shí)間作為參數(shù)在程序運(yùn)行時(shí)輸入。3. 關(guān)鍵技術(shù)(1)隨機(jī)數(shù)發(fā)生器乘同余法遞推公式:程序中采用:(2)隨機(jī)變量的產(chǎn)生變換抽樣法指數(shù)分布隨機(jī)變量的產(chǎn)生:其中,為到達(dá)(或服務(wù))速率,1/到達(dá)時(shí)間平均間隔(或平均服務(wù)時(shí)間),u為隨機(jī)數(shù)。(3)排隊(duì)、到達(dá)、服務(wù)模式排隊(duì)規(guī)則:先到先服務(wù)(fifo);到達(dá)模式:泊松到達(dá),即相鄰兩個(gè)顧客到達(dá)的時(shí)間間隔服從指數(shù)分布;服務(wù)模式:服務(wù)臺(tái)為活動(dòng)實(shí)體提供服務(wù)的時(shí)間是隨機(jī)的,服從指數(shù)分布。(4)常用統(tǒng)計(jì)性能指標(biāo)計(jì)算平均延誤時(shí)間:其中,di為第i個(gè)活動(dòng)實(shí)體在隊(duì)列中耽誤的時(shí)間。平均滯留時(shí)間:其中,wi為第i個(gè)活動(dòng)實(shí)體在系統(tǒng)中滯留的時(shí)間,si為第i個(gè)活動(dòng)實(shí)體接受
3、服務(wù)臺(tái)服務(wù)的時(shí)間。平均隊(duì)長(zhǎng):其中,q(t)為t時(shí)刻系統(tǒng)中隊(duì)列的長(zhǎng)度。平均實(shí)體數(shù):其中,l(t)為t時(shí)刻系統(tǒng)中的活動(dòng)實(shí)體數(shù),q(t)為t時(shí)刻隊(duì)列的長(zhǎng)度,s(t)為t時(shí)刻接受服務(wù)臺(tái)服務(wù)的活動(dòng)實(shí)體數(shù)。4. 程序架構(gòu)(1)基本模塊void initialize(void); /*變量初始化*/void timing(void);/*時(shí)間調(diào)度*/void arrive(void);/*到達(dá)事件處理*/void depart(void);/*離開事件處理*/void report(void);/*統(tǒng)計(jì)量輸出*/void update_time_avg_stats(void);/*統(tǒng)計(jì)量的更新*/float
4、 expon(float mean);/*指數(shù)分布隨機(jī)變量的變換抽樣法*/(2)程序流程(main()函數(shù))(3)到達(dá)事件處理流程(arrive()函數(shù))(4)離開事件處理流程(depart()函數(shù))5. 程序設(shè)計(jì)(1)定義#include #include /*#include lcgrand.h header file for random-number generator. */#define q_limit 100 /* limit on queue length. */#define busy 1 /* mnemonics for servers being busy */#defi
5、ne idle 0 /* and idle. */int next_event_type, num_custs_delayed, num_delays_required, num_events, num_in_q, server_status;float area_num_in_q, area_server_status, mean_interarrival, mean_service, sim_time, time_arrivalq_limit + 1, time_last_event, time_next_event3, total_of_delays;file *infile, *out
6、file;float lcgrand(int stream);void initialize(void);void timing(void);void arrive(void);void depart(void);void report(void);void update_time_avg_stats(void);float expon(float mean);(2)主程序main() /* main function. */ /* open input and output files. */ infile = fopen(mm1.in, r); outfile = fopen(mm1.ou
7、t, w); /* specify the number of events for the timing function. */ num_events = 2; /* read input parameters. */ fscanf(infile, %f %f %d, &mean_interarrival, &mean_service, &num_delays_required); /* write report heading and input parameters. */ fprintf(outfile, single-server queueing systemnn); fprin
8、tf(outfile, mean interarrival time%11.3f minutesnn, mean_interarrival); fprintf(outfile, mean service time%16.3f minutesnn, mean_service); fprintf(outfile, number of customers%14dnn, num_delays_required); /* initialize the simulation. */ initialize(); /* run the simulation while more delays are stil
9、l needed. */ while (num_custs_delayed num_delays_required) /* determine the next event. */ timing(); /* update time-average statistical accumulators. */ update_time_avg_stats(); /* invoke the appropriate event function. */ switch (next_event_type) case 1: arrive(); break; case 2: depart(); break; /*
10、 invoke the report generator and end the simulation. */ report(); fclose(infile); fclose(outfile); return 0;(3)初始化函數(shù)void initialize(void) /* initialization function. */ /* initialize the simulation clock. */ sim_time = 0.0; /* initialize the state variables. */ server_status = idle; num_in_q = 0; ti
11、me_last_event = 0.0; /* initialize the statistical counters. */ num_custs_delayed = 0; total_of_delays = 0.0; area_num_in_q = 0.0; area_server_status = 0.0; /* initialize event list. since no customers are present, the departure (service completion) event is eliminated from consideration. */ time_ne
12、xt_event1 = sim_time + expon(mean_interarrival); time_next_event2 = 1.0e+30;(4)時(shí)間調(diào)度函數(shù)void timing(void) /* timing function. */ int i; float min_time_next_event = 1.0e+29; next_event_type = 0; /* determine the event type of the next event to occur. */ for (i = 1; i = num_events; +i) if (time_next_even
13、ti q_limit) /* the queue has overflowed, so stop the simulation. */ fprintf(outfile, noverflow of the array time_arrival at); fprintf(outfile, time %f, sim_time); exit(2); /* there is still room in the queue, so store the time of arrival of the arriving customer at the (new) end of time_arrival. */
14、time_arrivalnum_in_q = sim_time; else /* server is idle, so arriving customer has a delay of zero. (the following two statements are for program clarity and do not affect the results of the simulation.) */ delay = 0.0; total_of_delays += delay; /* increment the number of customers delayed, and make
15、server busy. */ +num_custs_delayed; server_status = busy; /* schedule a departure (service completion). */ time_next_event2 = sim_time + expon(mean_service); (6)離開事件處理函數(shù)void depart(void) /* departure event function. */ int i; float delay; /* check to see whether the queue is empty. */ if (num_in_q =
16、 0) /* the queue is empty so make the server idle and eliminate the departure (service completion) event from consideration. */ server_status = idle; time_next_event2 = 1.0e+30; else /* the queue is nonempty, so decrement the number of customers in queue. */ -num_in_q; /* compute the delay of the customer who is beginning service and update the total delay accumulator. */ delay = sim_time - time_arrival1; total_of_delays += delay; /* increment the number of customers delayed, and schedule departure. */ +num_custs_delayed; time_next_event2 = sim_time + expon(mean_service);
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 初二數(shù)學(xué)學(xué)習(xí)法模板
- 夜間照明專項(xiàng)施工方案
- 鞋面制作課程設(shè)計(jì)
- 運(yùn)輸機(jī)器人課程設(shè)計(jì)
- 2024年醫(yī)院設(shè)備采購(gòu)管理制度
- 2025年度智能建筑打樁施工技術(shù)服務(wù)合同4篇
- 2025年度租賃住宅用電安全保障合同樣本4篇
- 2025年消防應(yīng)急照明與疏散指示系統(tǒng)三方合同范文3篇
- 二零二五版離婚協(xié)議書起草與子女撫養(yǎng)權(quán)變更執(zhí)行監(jiān)督協(xié)議書4篇
- 銷售部培訓(xùn)課程設(shè)計(jì)
- GB/T 14600-2009電子工業(yè)用氣體氧化亞氮
- 小學(xué)道德與法治學(xué)科高級(jí)(一級(jí))教師職稱考試試題(有答案)
- 申請(qǐng)使用物業(yè)專項(xiàng)維修資金征求業(yè)主意見表
- 河北省承德市各縣區(qū)鄉(xiāng)鎮(zhèn)行政村村莊村名居民村民委員會(huì)明細(xì)
- 實(shí)用性閱讀與交流任務(wù)群設(shè)計(jì)思路與教學(xué)建議
- 應(yīng)急柜檢查表
- 通風(fēng)設(shè)施標(biāo)準(zhǔn)
- 酒店市場(chǎng)營(yíng)銷教案
- 房屋買賣合同簡(jiǎn)單范本 房屋買賣合同簡(jiǎn)易范本
- 無(wú)抽搐電休克治療規(guī)范
- 環(huán)保有限公司營(yíng)銷策劃方案
評(píng)論
0/150
提交評(píng)論