Skip to content

Commit

Permalink
fix bug where simulations error if first event of node is a shift change
Browse files Browse the repository at this point in the history
geraintpalmer committed Nov 14, 2023
1 parent fc07e07 commit a992299
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions ciw/node.py
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions ciw/tests/test_node.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit a992299

Please sign in to comment.