Skip to content

Commit 0e7ca2b

Browse files
committed
add property based test checking utilisation always less than 1
1 parent 7cae52c commit 0e7ca2b

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

ciw/tests/test_node.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import unittest
22
import ciw
3+
from hypothesis import given
4+
from hypothesis.strategies import (floats, integers, random_module)
35

46
class TestNode(unittest.TestCase):
57

@@ -649,6 +651,23 @@ def test_server_utilisation_with_wrapup(self):
649651
for srvr in Q.transitive_nodes[0].servers:
650652
self.assertGreaterEqual(srvr.total_time, srvr.busy_time)
651653

654+
@given(lmbda=floats(min_value=0.01, max_value=10),
655+
mu=floats(min_value=0.01, max_value=10),
656+
c=integers(min_value=1, max_value=10),
657+
rm=random_module())
658+
def test_utilisation_always_1_or_less(self, lmbda, mu, c, rm):
659+
N = ciw.create_network(
660+
Arrival_distributions=[['Exponential', lmbda]],
661+
Service_distributions=[['Exponential', mu]],
662+
Number_of_servers=[c]
663+
)
664+
ciw.seed(1)
665+
Q = ciw.Simulation(N)
666+
Q.simulate_until_max_time(200)
667+
for srvr in Q.transitive_nodes[0].servers:
668+
self.assertGreaterEqual(srvr.total_time, srvr.busy_time)
669+
self.assertLessEqual(Q.transitive_nodes[0].server_utilisation, 1.0)
670+
652671
def test_num_inds_equal_len_all_inds(self):
653672
# Create a Simulatin class that inherits form ciw.Simulation so that
654673
# an assertion than number_of_individuals == len(all_individuals)

0 commit comments

Comments
 (0)