|
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 |
|
@@ -637,6 +639,36 @@ def test_server_utilisation_with_schedules(self): |
637 | 639 | recs = Q.get_all_records() |
638 | 640 | self.assertEqual(Q.transitive_nodes[0].server_utilisation, 21.0/37.0) |
639 | 641 |
|
| 642 | + def test_server_utilisation_with_wrapup(self): |
| 643 | + N = ciw.create_network( |
| 644 | + Arrival_distributions=[['Exponential',7.14]], |
| 645 | + Service_distributions=[['Exponential',0.04]], |
| 646 | + Number_of_servers=[70] |
| 647 | + ) |
| 648 | + ciw.seed(1) |
| 649 | + Q = ciw.Simulation(N) |
| 650 | + Q.simulate_until_max_time(168) |
| 651 | + for srvr in Q.transitive_nodes[0].servers: |
| 652 | + self.assertGreaterEqual(srvr.total_time, srvr.busy_time) |
| 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 | + self.assertGreaterEqual(Q.transitive_nodes[0].server_utilisation, 0.0) |
| 671 | + |
640 | 672 | def test_num_inds_equal_len_all_inds(self): |
641 | 673 | # Create a Simulatin class that inherits form ciw.Simulation so that |
642 | 674 | # an assertion than number_of_individuals == len(all_individuals) |
|
0 commit comments