Skip to content

Commit

Permalink
Merge pull request #12 from Operations-Research-lib/develop
Browse files Browse the repository at this point in the history
update readme and add mm1 unit test
  • Loading branch information
Antonio-Tresol authored Dec 18, 2023
2 parents 3bec44b + 85aecfa commit 9cb9be7
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 11 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
otherthings.md
practica.py
other.py
src/__pycache__/queueing_theory.cpython-312.pyc
src/__pycache__/test_queueing_theory.cpython-312-pytest-7.4.3.pyc
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

+ [Luis Solano](https://github.com/GoninDS)

+ [Jorge Sagot](https://github.com/JirlOP)


### **Requirements:**
Expand Down
File renamed without changes.
11 changes: 0 additions & 11 deletions src/SimulationAndRand.py → src/simulation_and_rand.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,6 @@ def uniform_random_from_mixed_congruential_generator(a, c, m, x_zero, upper_boun
it += 1
return numbers_generated


"""
Example:
a = 10
b = 20
m = 1.0/50.0 * (20.0 - 10.0)
function = "1.0/50.0 * (x - 10.0)"
print(generate_acceptance_rejection(m, a, b, function, 100))
"""


def generate_acceptance_rejection(m, a, b, function, upper_limit):
"""Calculates a random observation from a function that has a range [a,b]
using the acceptance
Expand Down
27 changes: 27 additions & 0 deletions src/test_queueing_theory.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"""Module providing unit test for queueing_theory"""
import math as ma

import queueing_theory as qt


class TestMm1:
"""Class to test the M/M/1 queueing model"""

def test_mm1_model_compute_rho(self):
"""
Test case for mm1_model_compute_rho function.
This function tests the calculation of rho (traffic intensity) in the M/M/1
queueing model.
It verifies that the calculated value of rho is not equal to 0 and is
approximately equal to 0.8.
"""
lam_input = 8
miu_input = 10
expected_output = 0.8
rho_calc = qt.mm1_model_compute_rho(lam = lam_input, miu = miu_input)

assert rho_calc != 0, "rho is equal to 0"
assert ma.isclose(rho_calc, expected_output,
rel_tol=1e-9), "rho is not approximately equal to 0.8"

0 comments on commit 9cb9be7

Please sign in to comment.