From a992299aed5042ab102ae82b36ebe47117b24232 Mon Sep 17 00:00:00 2001 From: Geraint Palmer Date: Tue, 14 Nov 2023 12:16:31 +0000 Subject: [PATCH] fix bug where simulations error if first event of node is a shift change --- ciw/node.py | 1 + ciw/tests/test_node.py | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/ciw/node.py b/ciw/node.py index 8cd827c..3128694 100644 --- a/ciw/node.py +++ b/ciw/node.py @@ -30,6 +30,7 @@ def __init__(self, id_, simulation): self.date_generator = self.date_from_schedule_generator(raw_schedule_boundaries) self.next_shift_change = next(self.date_generator) self.next_event_date = self.next_shift_change + self.next_event_type = 'shift_change' else: self.c = node.number_of_servers self.schedule = None diff --git a/ciw/tests/test_node.py b/ciw/tests/test_node.py index 34113eb..165b49c 100644 --- a/ciw/tests/test_node.py +++ b/ciw/tests/test_node.py @@ -1964,3 +1964,14 @@ def test_do_not_repeat_finish_service_for_blocked_individuals(self): (1, 9), ] self.assertEqual(set(Q.nodes[2].blocked_queue), set(expected_blocked_queue)) + + def test_shift_change_before_arrival(self): + N = ciw.create_network( + arrival_distributions=[ciw.dists.Sequential(sequence=[2.0, float('inf')])], + service_distributions=[ciw.dists.Deterministic(value=1.0)], + number_of_servers=[([[1, 1.0], [2, 10.0]], False)] + ) + Q = ciw.Simulation(N) + Q.simulate_until_max_time(10.5) + recs = Q.get_all_records() + self.assertEqual(len(recs), 1)