[NOT WORKING] Start of "Probability of rejection" for performance measures.

This commit is contained in:
Yohan Boujon 2025-01-30 17:58:33 +01:00
parent 57d7a303b1
commit ddda393095
2 changed files with 83 additions and 0 deletions

BIN
perf-om2m/img/network.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

83
perf-om2m/simulation.py Executable file
View file

@ -0,0 +1,83 @@
#!/usr/bin/env python3
import argparse
import math
import numpy as np
'''
Rappel des notations:
H -> HTTP Server
R -> Resource
D -> Database
T -> Thread
---
LAMBDA -> Entrée
MU -> Sortie
'''
def rejection_probability():
# Counter when T is empty
kappa = 0
# Initially, N thread is given
X_T = N
# Number of message received
msg_recu = 0
proba_sortie = 0
for _ in range(STEPS):
entree_proba = np.random.exponential(1/LAMBDA_H)
sortie_proba = np.random.exponential(1/MU_H)
# If an arrival occurs first
if entree_proba < sortie_proba:
msg_recu += 1
if X_T > 0:
X_T -= 1
else:
kappa += 1
else:
proba_sortie += 1
if X_T < N:
X_T += 1
print(msg_recu)
print(kappa)
print(proba_sortie)
return kappa/msg_recu
def create_network():
STATE_VECTOR[0] = N
def simulate_network():
print(f"Simating for {STEPS} steps:")
for _ in range(STEPS):
msg_received = np.random.exponential(1/LAMBDA_H)
msg_send = np.random.exponential(1/MU_H)
= np.random.exponential(1/MU_R)
sortie_proba = np.random.exponential(1/MU_D)
# General variables
STATE_VECTOR = [0,0,0,0]
STEPS = 100000
LAMBDA_H = 3
MU_H = 1
MU_R = 1
MU_D = 1
# Tokens (Processors) for Resources
C = 1
# Available Token (Thread) for the HTTP Server
N = 1
def parse():
# Parsing arguments
parser = argparse.ArgumentParser(description="A simple script to parse the -n argument with a number.")
parser.add_argument('-n', '--number', type=int, required=True, help='The size of the queue')
args = parser.parse_args()
# Access the number
return args.number
if __name__ == "__main__":
create_network()
print(f"Probability of rejection: {rejection_probability():.4f}")