Assgmet 4 Thomas Adam Stepha Brumme Ha Lorez Jue th master st semester 57 7544 757 Problem Istall the OMet dscrete evet smulato pacage the latest verso o your computer ad ru the test smulatos. You ca fd the software at http://whale.ht.bme.hu/ometpp/. Read the Maual. Set up a M/M/ smulato. Vary the load as.;.;.;.4;.5;.6;.7;.8 (assume a servce rate of oe customer per secod ad vary accordgly). For each create customers (the tal umber of customers the system s zero). determe the mea system respose tme for all the customers (sample mea) loo every. secods at the system observe the umber of customers the system at each samplg pot ad cout how ofte exactly customers are foud ( ). Plot the relatve frequeces a hstogram. Compare your smulato results wth aalytcal results. Submt your code (C) your smulato results ad the correct aalytcal results. Eve though OMet was orgally desged for Ux/Lux systems the ew staller (latest verso s.b dated March 7 th ) set up the system flawlessly o our Wdows ad XP maches. The relatoshp whle ad m e.g. we have to evaluate eght dfferet systems. m leads to.;.4;.6;.8;.;.;.4;.6 Frst we aalyze the problem a mathematcal maer to get a dealzed result. The so-called probablty of queueg better ow as Erlag s C formula turs out to be: σ P P ( m jobs) ( jobs) m 4 ( ) m ( m) ( ) Performace Evaluato Techques summer term
Assgmet 4 Thomas Adam Stepha Brumme Ha Lorez Jue th master st semester 57 7544 757 We eed to ow before performg ay further calculatos. Accordg to lterature: m ( m) ( ) m m 4 ( ) ( m) Usg the gve sequece of we obta: 9 σ.89.667.58.49..5.76. 55 Lttle s Law gves: E [ r] 5 7 9 65 7 8 5 4 7 9 9 49 85 45.8.67.8.9..45.576.7 σ m σ 99 ( ) 5 4 ( ) 9 5 4 5 5 6 5 9..4.99.9..56.96.778 The pcture below shows the steady-state queue legth as computed by Excel: Aalytcal steady-state queue legth Probablty 9 8 7 6 5 4 w w w 6 w 9 w w 5 w 8 w w 4 w 7 w w w 6 Legth of Queue 5 Performace Evaluato Techques summer term
Assgmet 4 Thomas Adam Stepha Brumme Ha Lorez Jue th master st semester 57 7544 757 The OMet sute comes alog wth a few comprehesve demos explag a M/M/ queue detal ( the subdrectory samples/ffo). We used the provded code ad modfed t to a M/M/ queue. Most of the source code fles have bee geerated so we avod to prt all of them. evertheless the core fuctoalty ca be foud ffo.cpp: //------------------------------------------------------------- // fle: ffo.cc // (part of Ffo - a OMeT demo smulato) //------------------------------------------------------------- #clude "ffo.h" #clude <fstream> usg amespace std; vod FFAbstractFfo::actvty() msgservced ULL; msgservced ULL; edservcemsg ew cmessage("ed-servce-server-"); edservcemsg ew cmessage("ed-servce-server-"); recordhstogram ew cmessage("record-hstogram"); queue.setame("queue"); hst.setrage(. 5.); hst.setumcells(5); // sed record request scheduleat( smtme() recordhstogram ); for(;;) cmessage *msg receve(); f (msgedservcemsg) // server has fshed a job edservce( msgservced ); f (queue.empty()) msgservced ULL; else // ew job avalable > catch t msgservced (cmessage *) queue.pop(); smtme_t servcetme startservce( msgservced ); scheduleat( smtme()servcetme edservcemsg ); else f (msgedservcemsg) // server has fshed a job edservce( msgservced ); f (queue.empty()) msgservced ULL; else // ew job avalable > catch t msgservced (cmessage *) queue.pop(); smtme_t servcetme startservce( msgservced ); scheduleat( smtme()servcetme edservcemsg ); else f (msgrecordhstogram) // record curret queue legth hst.collect(queue.legth()); // resubmt message for ext record.s later scheduleat( smtme(). recordhstogram ); else f (msgservced) // ew job arrval ad server s dle > start there arrval( msg ); Performace Evaluato Techques summer term
Assgmet 4 Thomas Adam Stepha Brumme Ha Lorez Jue th master st semester 57 7544 757 msgservced msg; smtme_t servcetme startservce( msgservced ); scheduleat( smtme()servcetme edservcemsg ); else f (msgservced) // ew job arrval ad server s actve server s dle > start o server arrval( msg ); msgservced msg; smtme_t servcetme startservce( msgservced ); scheduleat( smtme()servcetme edservcemsg ); else // ew arrval but o dlle server > queue t arrval( msg ); queue.sert( msg ); vod FFAbstractFfo::fsh() ev << "*** Module: " << fullpath() << "***" << edl; ev << "Stac allocated: " << stacsze() << " bytes"; ev << " (cludes " << ev.extrastacforevr() << " bytes for evromet)" << edl; ev << "Stac actually used: " << stacusage() << " bytes" << edl; ofstream of(par("hst_fle") os::app); t samples hst.samples(); t ; t s ; of << edl << edl << "*********** ew ru ***********" << edl << edl << "cout: " << samples << edl << "bucet cout rel. perc" << edl; whle ((s<samples) && (<hst.cells())) of << << " " << (t) hst.cell() << " " << hst.cell()/samples << edl; shst.cell(); ; /* FILE *f; ffope(par("hst_fle")"a"); hst.savetofle(f); fclose(f);*/ //------------------------------------------------ Defe_Module( FFPacetFfo ); smtme_t FFPacetFfo::startServce(cMessage *msg) ev << "Startg servce of " << msg->ame() << edl; retur par("servce_tme"); vod FFPacetFfo::edServce(cMessage *msg) ev << "Completed servce of " << msg->ame() << edl; sed( msg "out" ); Remar: The complete program s cluded the accompaed Zp archve cl. a Wdows bary. Performace Evaluato Techques 4 summer term
Assgmet 4 Thomas Adam Stepha Brumme Ha Lorez Jue th master st semester 57 7544 757 The aalyss of the data geerated by our OMet program was doe usg Mcrosoft Excel for a secod tme: Lambda. 8 Probablty 6 4 w w w w w4 w5 w6 Legth of Queue 4 5 calculated ru 4 5 calculated av. SRT 4 54 48 85 9999 w 9984 9986 9985 9985 99866 9988 w 47 7 74 54 74 66 w 7 9 9 64 w 47E-5 6E-6 64E-5 w4 64E-6 w5 64E-7 w6 64E-8 Lambda. 8 Probablty 6 4 w w w w w4 w5 w6 w7 w8 Legth of Queue 4 5 calculated ru 4 5 calculated av. SRT 44 8 46 457 48 4667 w 987497 9876 98784 987 98854 986667 w 6 8 974 4 944 667 w 966 99 98 87 97 w 44 566E-4 7 4 85 47 w4 95E-5 855E-5 4 567E-5 9E-5 85E-5 w5 9E-5 E-5 E-5 64E-5 785E-6 7E-5 w6 4E-6 w7 68E-7 w8 7E-7 Performace Evaluato Techques 5 summer term
Assgmet 4 Thomas Adam Stepha Brumme Ha Lorez Jue th master st semester 57 7544 757 Lambda. 8 Probablty 6 4 w w w w w4 w5 w6 w7 w8 w9 w w Legth of Queue 4 5 calculated ru 4 5 calculated av. SRT 878 959 64 85 965 989 w 969 9598 95869 957746 9578 95846 w 76 8887 884 99 7 977 w 7599 7985 8574 8587 97 87 w 4 E- 4 94 875 67 w4 497 75 5 6 775 785 w5 7 44 74 467 6 w6 89E-5 474E-5 79E-5 85 77E-5 w7 585E-6 768E-5 7E-5 E-5 w8 6E-5 66E-6 w9 9E-6 w 57E-7 w 7E-7 Performace Evaluato Techques 6 summer term
Assgmet 4 Thomas Adam Stepha Brumme Ha Lorez Jue th master st semester 57 7544 757 Lambda.4 9 8 7 Probablty 6 5 4 w w w w w4 w5 w6 w7 w8 w9 w w w w w4 w5 Legth of Queue 4 5 calculated ru 4 5 calculated av. SRT 5899 96 58 6 6 9476 w 99 99849 9775 99676 99 9857 w 5568 5666 5665 559 5887 54857 w 9999 87 556 484 49 94 w 754 79E- 94 89 97 8777 w4 5 6 474 44 4 5 w5 8 5 687 7 59 44 w6 8 46 98 596 85 56 w7 68E-5 55E-5 6 469 4 5 w8 77E-5 86 8 899E-5 w9 77 477E-5 6E-5 w 56E-5 44E-5 w 8E-6 575E-6 w 64E-5 E-6 w 9E-7 w4 68E-7 w5 47E-7 Performace Evaluato Techques 7 summer term
Assgmet 4 Thomas Adam Stepha Brumme Ha Lorez Jue th master st semester 57 7544 757 Lambda.5 9 8 7 6 Probablty 5 4 w w w w w4 w5 w6 w7 w8 w9 w w w w w4 w5 w6 w7 Legth of Queue 4 5 calculated ru 4 5 calculated av. SRT 48 778 7664 88 6 w 8897 8444 844 86 896 8 w 8885 89 88 767 84 8 w 9856 489 465 499 46 4667 w 864 E- 788 446 544 8 w4 486 786 785 8 8 47 w5 54 46 57 54 65 58 w6 74 58 84 8 57 64 w7 79 946 57 746 9 w8 7 9 665 9 89 65 w9 8 996E-6 78 6 w 97E-5 7 9 6 w 985E-6 5 84E-5 w 8 47E-5 w 4 E-5 w4 E-5 w5 59E-6 w6 54E-6 w7 7E-6 Performace Evaluato Techques 8 summer term
Assgmet 4 Thomas Adam Stepha Brumme Ha Lorez Jue th master st semester 57 7544 757 Lambda.6 8 7 6 5 Probablty 4 w w w w w4 w5 w6 w7 w8 w9 w w w w w4 w5 w6 w7 w8 w9 w Legth of Queue 4 5 calculated ru 4 5 calculated av. SRT 4969 5449 5567 4648 555 565 w 7464 76754 76558 7475 7449 7 w 665 4946 84 574 97 8 w 685 599 6448 6567 64 648 w 77 95E- 874 6945 764 888 w4 45 59 9 49 567 8 w5 55 5456 49 8 59 997 w6 6587 86 647 5747 7986 898 w7 46 95 6 97 596 59 w8 86 765 89 4 45 w9 47 894 87 78 84 w 584 586 488 88 w 46 69 657 4 65 w 47E-5 86 9 w 656 6 5 w4 9E-5 79 4 w5 9E-5 846E-5 w6 67 58E-5 w7 4 5E-5 w8 8E-5 w9 E-5 w 658E-6 Performace Evaluato Techques 9 summer term
Assgmet 4 Thomas Adam Stepha Brumme Ha Lorez Jue th master st semester 57 7544 757 Lambda.7 7 6 5 Probablty 4 w w w w w4 w5 w6 w7 w8 w9 w w w w w4 w5 w6 w7 w8 w9 w w w w w4 Legth of Queue 4 5 calculated ru 4 5 calculated av. SRT 94744 77 85 76 985 96784 w 6 685 6659 576754 58784 59647 w 4 8877 49 949 59 w 868 849 79957 8945 85848 8474 w 5769 554E- 59 5676 655 599 w4 446 6 4474 446 4 45 w5 899 67 797 76 966 w6 69 76 7 56 987 46 w7 455 947 446 899 54 44 w8 94 759 884 965 75 997 w9 764 465 665 5 747 6979 w 488 6 575 644 5949 4885 w 66 88 44 598 4 w 578 98 4 69 94 w 4 88 89 5 99 676 w4 58 969E-5 95 58 658 7 w5 57 46 769 8 w6 549E-5 96E-5 866 45 575 w7 5 96E-5 866 64 4 w8 75E-5 46 5 8 w9 6 97 w 7 8 w 56 966E-5 w 676E-5 w 47E-5 w4 E-5 Performace Evaluato Techques summer term
Assgmet 4 Thomas Adam Stepha Brumme Ha Lorez Jue th master st semester 57 7544 757 Lambda.8 5 45 4 5 Probablty 5 5 5 Legth of Queue 4 5 calculated ru 4 5 calculated av. SRT 7949 7958 7799 7989 489 777778 w 4948 4859 44795 448 46956 4 w 686 99 957 76 65 778 w 875 87868 898 95588 95466 9 w 867 7E- 76 7569 797 788 w4 79 57887 5555 649 54788 5854 w5 5789 484 4 57 4598 466 w6 85 897 78 486 977 78 w7 4 88 96 4 589 986 w8 685 7 65 9 988 86 w9 795 888 44 7 5599 989 w 85 86 7766 69 558 57 w 46 66 4 856 878 7 w 94 97 5 44 886 977 w 66 797 846 7 78 789 w4 476 68 566 6 4899 655 w5 498 454 6 98 6 54 w6 47 4776 4586 58 45 4 w7 648 485 49 59 98 w8 5 7 4 775 95 56 w9 45 56 8 45 7 5 w 7 949 545 69 999 64 w 7 6 65 94 89 w 7 454 4 5 46 49 w 87E-5 96 949 7 856 84 w4 484E-5 67 68 99 85 67 w5 7 4 44 848 54 57 w6 78 8 966E-5 47 79E-5 4 w7 6 46 E-5 74 44 w8 484E-5 69 8 75 w9 646E-5 479E-5 4 w 56 46 76 w 7 5 4 w 44 w 7 9E-5 w4 9 8 7E-5 w5 69E-5 577E-5 w6 46E-5 w7 69E-5 w8 95E-5 Performace Evaluato Techques summer term
Assgmet 4 Thomas Adam Stepha Brumme Ha Lorez Jue th master st semester 57 7544 757 average System Respose Tme 5 Secods 5 5 4 5 6 7 8 lambda 4 5 calculated ru 4 5 calculated 4 54 48 85 9999 44 8 46 457 48 4667 878 959 64 85 965 989 4 5899 96 58 6 6 9476 5 48 778 7664 88 6 6 4969 5449 5567 4648 555 565 7 94744 77 85 76 985 96784 8 7949 7958 7799 7989 489 777778 Performace Evaluato Techques summer term
Assgmet 4 Thomas Adam Stepha Brumme Ha Lorez Jue th master st semester 57 7544 757 Problem Use the Pollacze-Khtche mea value formula to show that a M/M/ system has twce the expected umber of customers the system as the M/D/ system as ( < ). The Pollacze-Khtche mea value formula: E [ ] ( ) C b ( ) That formula ca be appled to both the M/M/ ad the M/D/ case. The term C b dffers the M/M/ case: C b Ad for M/D/: C b We fd that the expected umber of customers a M/M/ system s determed by: E [ ] M / M / ( ) ( ) ( ) Smplfyg the Pollacze-Khtche formula of a M/D/ system: E [ ] M / D / ( ) ( ) ( ) ( ) Performace Evaluato Techques summer term
Assgmet 4 Thomas Adam Stepha Brumme Ha Lorez Jue th master st semester 57 7544 757 Let s compute the lmt: E lm E M / M / M / D / [ ] [ ] ( ) ( ) ( ) ( ) ( ) Ideed a M/M/ system has twce the expected umber of customers a system as the M/D/ system for < ). large ( Performace Evaluato Techques 4 summer term
Assgmet 4 Thomas Adam Stepha Brumme Ha Lorez Jue th master st semester 57 7544 757 Problem Cosder the M/M// loss system ( ) wth arrval rate ad beg the rate of a sgle server. Draw the state dagram Gve the geerator matrx Q Fd the steady-state vector (... ) Usg ths show that wth Pr [" Customer loss" ] Assume 5 : (ths s the Erlag loss formula) ad evaluate Pr[ " loss" ] How mght a telephoe compay use ths formula? Customer for.... If ay of the servers the M/M// queue s dle the arrvg job s servced mmedately. If all server are busy the arrvg job wats a queue. The state of the system s represeted by the umber of jobs the system. Thus the state trasto dagram loos as follows:... - (-) The correspodg ( ) ( ) above: geerator matrx Q ca be derved statly from the dagram show Q M ( ) ( ) ( ) L O ( ( ) ) ( ) ( ( ) ) M Performace Evaluato Techques 5 summer term
Assgmet 4 Thomas Adam Stepha Brumme Ha Lorez Jue th master st semester 57 7544 757 Performace Evaluato Techques 6 summer term The steady-state vector ca be ferred from Q sce each row equals zero. Therefore: Q Ad more detal: ( ) ( ) ( ) ( ) 4 K Solvg these equatos depedg o yelds: 4 4 4 4 6 K A closer loo to the dagram reveals that a M/M// queue s a brth-death process. Therefore: Accordg to the ormalzato codto:
Assgmet 4 Thomas Adam Stepha Brumme Ha Lorez Jue th master st semester 57 7544 757 Performace Evaluato Techques 7 summer term We solve for : Sce for the sum ca be exteded to: Usg : Substtutg ad : That way we proved Erlag s loss formula. Smlarly we get the steady-state vector: 6 L
Assgmet 4 Thomas Adam Stepha Brumme Ha Lorez Jue th master st semester 57 7544 757 A moder math sute computes the customer loss very qucly. We wrote a short program for Maple 8 Tral verso. Its two les are: rho:5: erlag:->rho^/(*sum((rho^)/..)); The program s targeted at hgh precso computatos ad therefore outputs chuy ratos. However we also wated to obta rouded values: result:seq(erlag()..); 5 5 5 65 65 5 565 785 965 965 result : 6 7 6 569 94 689 9648 59 4846 4747 955 976565 48885 44465 44465 56749 8786489 694764 574996 55559464 75 65565 4844574549 575785 55878965 47748958 765644769 444989694666 55878965 57779496647769 resultf:evalf(result); resultf :.8.6756756757.596669.984896.848678.9847589.5865.74785.745778597.884574.88768467.44875.7844.478459.575686.4947459.4457864.446465-5.56484675-5.64989-6 I a M/M// system queueg s ot ecessary sce there are as may servers as customers. So f a customer s able to actually eter the system the he/she wll be served too. Otherwse he/she wll be rejected ad does ot eter the system at all. The capacty of a telephoe etwor (a bacboe) ought to be as hgh as eeded order to master the case that each customer calls/arrves at the same tme (up to calls). I realty that case was ever observed hece the compaes reduce ther capactes to the typcal case order to cut lots of costs. The telecommucato compaes am to serve as may customers as possble ad to refuse as few as feasble. Due to log-term observatos t s approxmately ow advace how may ew calls per tme have to be served ad how log they last average. ow the compaes defe some percetages they le to acheve.e. there are ew calls per mute they last about mutes each ad oly.% should be rejected. The: The fal step s to fd the smallest where Pr [" loss" ] <.% Customer accordg to Erlag s loss formula. That the deotes the lowest capacty eeded to acheve the proposed servce avalablty. Performace Evaluato Techques 8 summer term
Assgmet 4 Thomas Adam Stepha Brumme Ha Lorez Jue th master st semester 57 7544 757 If oe has to estmate the loss usg a gve capacty throughput ad arrval rate he ca utlze Erlag s loss formula too. As a example a telephoe compay gets a chace to approxmate how may calls are lost ( average) wth ther curret telephoe exchage (or swtch). If that umber s too hgh the compay should calculate how may of the lost calls may have bee served by stallg a addtoal exchage. Hece the outcome of all these calculatos are future vestmets (the ew telephoe exchage) ad upcomg eargs (served calls). The resposble maager the ca decde upo these facts whether he admts to the ew vestmets or ot. Performace Evaluato Techques 9 summer term
Assgmet 4 Thomas Adam Stepha Brumme Ha Lorez Jue th master st semester 57 7544 757 Problem 4 Cosder the fully Marova queueg etwor show ths fgure: queue queue.5.5 Fd a stablty codto for ths system. Fd the mea tme for a customer to proceed through the system. From the dagram we fer that the gve etwor s a ope etwor ad apply Jacso s theorem. The system s routg probabltes ca be descrbed as: p p.5 p p p.5 p p p.5 The traffc equatos: e e p p p p e p e p e e Reduced: e e.5 e e.5 e Solved: e e 4 e e 4 Queue has to process the tass three tmes faster tha they eter the system whle queue has to be eve qucer: t must be able to hadle four tmes the umber of arrvals. ow we exame both M/M/ queues separately. Each ode has to fulfll the stablty codto <. Due to we fd > 4. The mea tme for a customer to proceed through the system s the outcome of the equato: E [ t] e E[ T ] e E[ ] T Performace Evaluato Techques summer term
Assgmet 4 Thomas Adam Stepha Brumme Ha Lorez Jue th master st semester 57 7544 757 Utl ow the vst ratos are ow but we eed to further vestgate the estmated tme each ode: Hece: [ ] E T [ ] E T 4 4 E[ t] 4 7 4 ( ) ( 4) Performace Evaluato Techques summer term