Você está na página 1de 3

Simulation Examples Chapter 2

Examples (in book)


Queueing systems
Single server (ex. 2.1) Two server (ex. 2.2)

Inventory system (section 2.3,ex. 2.3) Monte Carlo simulation (like ex. 2.6) Reliability (ex 2.5)

1 Server Queue
Calling population Queue Server State = {QLength, ServerState}
Qlength = {0, 1,} ServerState = {busy, idle} {QL>0,idle} impossible state

Stability and Criticality


A queueing system is stable if no variable (such as queue length) grows indefinitely over time, otherwise it is unstable. A critical point of a system is a value x=xc of some system parameter such that for x<xc the system is stable, whereas for x>xc the system is unstable. (If we have more than one x we can have critical line, area, etc.)

Events = {Arrival, Departure} Simulation Clock tracks time Tarrival and Tservice probabilistic

Simulate by hand
Assume interarrival times Ta and service times Ts are:
Ta = 1 and Ts = 1 stable Ta = 2 and Ts = 3 unstable Ta = 3 and Ts = 2 stable Ta = (2,4,1,2,6) and Ts = (2,1,3,2,1,4) Finally fully stochastic as in Table 2.6-7

Simulate rest in MATLAB


See sim1.m

2 Server problem
See sim2.m See book ex. 2.2 (will come back later)

Littles law
<T> = average time spent in system of some entity <N> = average number of those entities in the system <R> = arrival rate of those entities (entities/day for example) Littles law: <N>=<R><T>

Proof
Let system run for long period [0 t]. Let C be the accumulated time in system of all entities. Let D be the total number of entities arrived. Per definition we have <N>=C/t and <T>=C/D. So <N>=(D/t)<T>. D/t is the arrival rate R.

Inventory System
Book Sec. 2.2 (M,N) Inventory system
M is full inventory level N is review period Delay after order is lead time

Newspaper problem
sim3.m Ex 2.3 in book

Newspaper problem
Buy for 33c/paper Sell for 50c/paper Left-over for 5c/paper Buy in quanta of 10 papers Cost of excess demand 17c/paper Demand modeled as in book See sim3.m for code

Machine Failure Problem


Ex 2.5 from book See sim5.m Replace all parts when 1 fails? Test over 2 year simulation

Monte Carlo Simulation


Use random sampling to estimate Instead of ex. 2.6 in book Used for scientific applications Used for rough estimates Throw random dots at circle to compute (3.14159) See sim4.m
r

Compute
Throw darts at this picture Fraction in circle = X X = number inside/total darts X = area circle/area square

Monte Carlo Applications


Volume of f(x1,,xn)<1 See sim 6.m and sim7.m Integrals of high dimensional functions Often n is very large

Você também pode gostar