1 / 25

DISCRETE-EVENT SIMULATION MODEL

DISCRETE-EVENT SIMULATION MODEL. KOMPONEN & SUSUNAN D-E SM. System state : koleksi variabel state yang diperlukan untuk menggambarkan sistem pada saat tertentu. Simulation clock : variabel yang menghasilkan nilai terbaru saat itu ( current ) dari waktu tersimulasi.

manon
Télécharger la présentation

DISCRETE-EVENT SIMULATION MODEL

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. DISCRETE-EVENT SIMULATION MODEL

  2. KOMPONEN & SUSUNAN D-E SM • System state : koleksi variabel state yang diperlukan untuk menggambarkan sistem pada saat tertentu. • Simulation clock : variabel yang menghasilkan nilai terbaru saat itu (current) dari waktu tersimulasi. • Event list : daftar yang memuat waktu berikutnya ketika masing-masing event akan muncul.

  3. KOMPONEN & SUSUNAN D-E SM • Statistical counters : variabel yang digunakan untuk menyimpan informasi statistik tentang kinerja sistem. • Initialization routine :subprogram untuk menginisialisasi model pada saat t = 0. • Timing routine :subprogram yang menentukan event berikutnya dari event list dan kemudian memajukan simulation clock ke waktu di mana event berikutnya tersebut muncul.

  4. KOMPONEN & SUSUNAN D-E SM • Event routine :subprogram yang meng-update state sistem ketika tipe event tertentu muncul (masing-masing tipe event mempunyai satu event routine). • Library routine : himpunan subprogram untuk menghasilkan (generate) observasi-observasi random dari distribusi probabilitas yang ditentukan sebagai bagian model simulasi.

  5. KOMPONEN & SUSUNAN D-E SM • Report generator :subprogram yang menghitung estimasi (dari statistical counters) dari ukuran kinerja yang diinginkan dan menghasilkan laporan (reports) ketika simulasi selesai. • Main program :subprogram yang memanggil (call – invoke) timing routine untuk menentukan next event dan kemudian mentrasfer kontrol ke event routine yang bersesuaian untuk meng-updatestate sistem secara tepat. Main program mungkin juga memeriksa terminasi (pemberhentian) dan invokes report generator ketika simulasi berakhir.

  6. ALUR KONTROL UNTUK D-E SM Start Initialization routine Main Program Timing routine 0 • 0.Invoke the initialization routine • Invoke the timing routine • Invoke event routine i • (1 dan 2 diulang-ulang) • Menentukan next event type, sebut i • Memajukan simulation clock • Set simulation clock = 0 • Initialize system state & statistical counters • Initialize event list 1 i 2 Event routine i Library routine • Update system state • Update statistical counters • Generate future events & add to event list Generate random variates

  7. ALUR KONTROL UNTUK D-E SM Apakah simulasi selesai ? Report generator • Hitung estimasi-estimasi yang dibutuhkan • Tulis report Stop

  8. SINGLE-SERVER QUEUEING SYSTEM • Interarrival times A1, A2, … independent, identically distributed (IID) random variables. • Identically distributed : interarrival times mempunyai distribusi probailitas yang sama. • Customer yang tiba (arrives) dan menjumpai server idle akan langsung di-serve, dan service times S1, S2, … dari customer yang berurutan merupakan variabel-variabel random IID yang independent terhadap nilai-nilai Ai. • Customer yang tiba dan menjumpai server busy akan bergabung di akhir queue (antrian). • Server memilih customer dari queue menggunakan cara (manner) FIFO.

  9. SINGLE-SERVER QUEUEING SYSTEM Customer yang arrives Customers dalam queue Customer sedang di-serve Server Customer yang departs • Simulasi akan mulai dalam keadaan (state) “empty-and-idle”, yaitu suatu keadaan di mana tidak ada customer yang datang dan server idle. • Pada saat t = 0, menunggu kedatangan customer pertama yang akan terjadi setelah interarrival time pertama A1 (bukan di t = 0). • Simulasi akan berhenti ketika customer ke-n memasuki services. • Waktu berakhirnya simulasi merupakan variabel random.

  10. FLOWCHART UNTUK ARRIVAL ROUTINE, QUEUEING SYSTEM Arrival event Schedule the next arrival event Is the server busy ? Set delay = 0 for this customer and gather statistics Add 1 to the number in queue

  11. FLOWCHART UNTUK ARRIVAL ROUTINE, QUEUEING SYSTEM Add 1 to the number of customer delayed Write error message & stop simulation Is the queue full ? Store time of arrival of this customer Make the server busy Schedule a departure event for this customer Return

  12. FLOWCHART UNTUK DEPARTURE ROUTINE, QUEUEING SYSTEM Departure event Is the queue empty ? Subtract 1 from the number in queue Make the server idle Compute delay of customer entering service and gather statistics Eliminate departure event from consideration

  13. FLOWCHART UNTUK DEPARTURE ROUTINE, QUEUEING SYSTEM Add 1 to the number of customer delayed Schedule a departure event for this customer Move each customer in queue (if any) up one place Return

  14. PROGRAM PASCAL PROGRAMSingleServerQ(Input, Output); CONST QLimit = 100; Busy = 1; Idle = 0; VAR NextEventType, NumCustsDelayed, NumDelaysRequired, NumEvents, NumInQ, ServerStatus : Integer; AreaNumInQ, AreaServerStatus, MeanInterarrival, MeanService, Tijme, TimeLastEvent, TotalOfDelays : Real; Timearrival : ARRAY[1..QLimit] of Real; TimeNextEvent : ARRAY[1..2] of Real; Zrng : ARRAY[1..100] of Integer; PROCEDURE Initialize; FORWARD; PROCEDURE Timing; FORWARD; PROCEDURE Arrive; FORWARD; PROCEDURE Depart; FORWARD; PROCEDURE Report; FORWARD; PROCEDUREUpdateTimeAvgStats; FORWARD; FUNCTION Expon(Mean : Real) : Real; FORWARD; PROCEDURERanddf; FORWARD; FUNCTION Rand(Stream : Integer) : Real; FORWARD; PROCEDURERandst(Zset : Integer; Stream : Integer); FORWARD; FUNCTIONRandgt(Stream : Integer) : Integer; FORWARD;

  15. PROGRAM PASCAL Procedure Initialize; Begin {simulation clock} Time := 0.0; {state variables} ServerStatus := Idle; NumInQ := 0; TimeLastEvent := 0.0; {statistical counters} NumCustDelayed := 0; TotalOfDelays := 0.0; AreaNumInQ := 0.0; AreaServerStatus := 0.0; {event list} TimeNextEvent[1] := Time + Expon(MeanInterArrival); TimeNextEvent[2] := 1.0E+30 End;

  16. PROGRAM PASCAL Procedure Timing; Var I : Integer; MinTimeNextEvent : Real; Begin MinTimeNextEvent := 1.0E+29; NextEventType := 0; { menentukan tipe event dari next event yang muncul } For I := 1 To NumEvent Do Begin If TimeNextEvent[I] < MinTimeNextEvent Then Begin MinTimeNextEvent := TimeNextEvent[I]; NextEventType := I End End; { melihat apakah event list kosong } If NextEventType = 0 Then Begin { event list kosong, hentikan simulasi } writeln(‘Event list kosong pada pukul : ‘, Time); Halt End; { event list tidak kosong, majukan simulation clock } Time := MinTimeNextEvent End;

  17. PROGRAM PASCAL Procedure Arrive; Var Delay : Real; Begin { schedule next event } TimeNextEvent[1] := Time + Expon(MeanInterArrival); { melihat apakah server busy } If ServerStatus = Busy Then Begin NumInQ := NumInQ + 1; If NumInQ > QLimit Then Begin Writeln(‘Queue overload pada waktu :’,Time); Halt End; TimeArrival[NumInQ] := Time End Else(* dilanjutkan … *)

  18. PROGRAM PASCAL (* … lanjutan *) Else Begin { server idle } Delay := 0.0; TotalOfDelays := TotalOfDelays + Delay; { rubah status server menjadi busy } NumCustDelayed := NumCustDelayed + 1; ServerStatus := Busy; { schedule departure (service completion) } TimeNextEvent[2] := Time + Expon(MeanService) End End{ end dari procedure arrival }

  19. PROGRAM PASCAL Procedure Depart; Var I : Integer; Delay : Real; Begin If NumInQ = 0 Then Begin ServerStatus := Idle; TimeNextEvent[2] := 1.0E+30; End Else Begin NumInQ := NumInQ - 1; Delay := Time – TimeArrival[1]; TotalOfDelays := TotalOfDelays + Delay; NumCustDelayed := NumCustDelayed + 1; TimeNextEvent[2] := Time + Expon(MeanService); For I := 1 To NumInQ Do TimeArrival[I] := TimeArrival[I + 1] End End;

  20. PROGRAM PASCAL Procedure Report; Var AvgDelayInQ, AvgNumInQ, ServerUtilization : Real; Begin AvgDelayInQ := TotalOfDelays / NumCustDelayed; AvgNumInQ := AreaNumInQ / Time; ServerUtilization := AreaServerStatus / Time; Writeln; Writeln(‘Rata-rata delay dalam queue ‘, AvgDelayInQ:11:3, ‘ menit’); Writeln(‘Rata-rata panjang queue ‘, AvgNumInQ:10:3); Writeln(‘Server Utilization ‘, ServerUtilization:10:3); Writeln(‘Waktu akhir simulasi : ‘,Time:12:3) End;

  21. PROGRAM PASCAL Procedure UpdateTimeAvgStats; Var TimeSinceLastEvent : Real; Begin { menghitung waktu sejak event terakhir, dan meng- update last-event-time marker } TimeSinceLastEvent := Time – TimeLastEvent; TimeLastEvent := Time; AreaNumInQ := AreaNumInQ + NumInQ * TimeSinceLastEvent; AreaServerStatus := AreaServerStatus + ServerStatus * TimeSinceLastEvent End;

  22. PROGRAM PASCAL Function Expon; { fungsi pembentukan variabel eksponensial } Var U : Real; Begin { men-generate variabel random U(0,1) } U := Rand(1); Expon := -Mean * Ln(U) End;

  23. PROGRAM PASCAL { Single server Queuing Main Program } Begin (* Mulai Main Program *) { Inisialisasi pembangkit bilangan acak } Randdf; { Menentukan banyaknya event untuk prosedur timing } NumEvents := 2; Readln(MeanInterArrival, MeanService, NumDelaysRequired); { Menulis report heading dan input parameters } writeln(‘Single Server Queuing System’); writeln; …

  24. PROGRAM PASCAL ……………..lanjutan { Inisialisasi Simulasi } Initialize; While NumCustDelayed < NumDelaysRequired Do Begin Timing; UpdateTimeAvgStats; Case NextEventType Of 1 : Arrive; 2 : Depart; End End; Report End. (* Akhir Main Program *)

  25. C Program #include <stdio.h> #include <math.h> #include “rand.h” /* header file untuk random-number generator */ #define Q_LIMIT 100 #define BUSY 1 #define IDLE 0 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, time, time_arrival[Q_LIMIT+1], time_last_event, time_next_event[3], total_of_delays; FILE *infile, *outfile; 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);

More Related