|
1 | 1 | import unittest |
2 | 2 | import ciw |
| 3 | +from hypothesis import given |
| 4 | +from hypothesis.strategies import (floats, integers, random_module) |
3 | 5 |
|
4 | 6 | class TestNode(unittest.TestCase): |
5 | 7 |
|
@@ -649,6 +651,23 @@ def test_server_utilisation_with_wrapup(self): |
649 | 651 | for srvr in Q.transitive_nodes[0].servers: |
650 | 652 | self.assertGreaterEqual(srvr.total_time, srvr.busy_time) |
651 | 653 |
|
| 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 | + |
652 | 671 | def test_num_inds_equal_len_all_inds(self): |
653 | 672 | # Create a Simulatin class that inherits form ciw.Simulation so that |
654 | 673 | # an assertion than number_of_individuals == len(all_individuals) |
|
0 commit comments