Simulation d'une file d'attente

Incantations initiales

Rappel sur la loi exponentielle

Loi du nombre d'arrivées est Poisson

Méthode de simulation

Exemple de simulation

On fait tourner à la main

Avec échéancier

Une ligne :
durée avant survenue,
nature : 0 arrivée, 1 service,
numéro client

> tri:= (A,B)-> evalb(A[1]<B[1]);

tri := proc (A, B) options operator, arrow; evalb(A...

> N:=50000: load:=0: k:=0: ech:=[[0,0,0]]: mem:= table():
for i to 2*N do
val:= ech[1][1];
ech:= map(A->[A[1]-val,A[2],A[3]], ech);
load:= `if`(load>0,load-val,0);
if ech[1][2]=0 # arrivée
then nn:= ech[1][3]+1; k:=k+1;
gg:= gb(); load:= load+gg;
ajout:= [ga(),0,nn],[load,1,nn];
mem[nn]:= [nn,load,gg,k];
else # départ
ajout:= NULL; k:=k-1;
fi;
ech:= sort([op(subsop(1=NULL, ech)), ajout], tri);
# print(nn,load,gg,k,%);
od:

> Matrix([seq(mem[j], j=1..10)]);

_rtable[28555144]

Nb clients

> [seq(mem[j][4],j=1..N)]: tmp:= stats[transform, tally](%):
stats[transform, tallyinto](%, [seq(j-1/2..j+1/2, j=1..(max@op)(%%))]):
xhisto(%, area=1); pl_nb:=%:

> evalf([moy(tmp), var(tmp)]);

[Maple Plot]

[3.982220000, 12.83906387]

> lambda/mu; [seq([k,(1-%)*%^k], k=0..10)]; plots[pointplot](%, style=line, color=red):
display(%, pl_nb);;

3/4

[[0, 1/4], [1, 3/16], [2, 9/64], [3, 27/256], [4, 8...

[Maple Plot]

>

>

Séjour

> tmp:= [seq(mem[j][2],j=1..N)]: xhisto(tmp, area=1, numbars=20):
display(%, plot(exp(-t), t=0..4));

[Maple Plot]

Service

> tmp:= [seq(mem[j][3],j=1..N)]: xhisto(tmp, area=1, numbars=20):

> display(%, pl1, view=[0..2, DEFAULT]);

[Maple Plot]

>

>

>