Skip to content

Commit 7cae52c

Browse files
committed
fix utilisation bug, write test
1 parent c3793b3 commit 7cae52c

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

ciw/node.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ def wrap_up_servers(self, current_time):
444444
for srvr in self.servers:
445445
srvr.total_time = self.increment_time(current_time, -srvr.start_date)
446446
if srvr.busy:
447-
srvr.busy_time += self.increment_time(current_time, -srvr.cust.arrival_date)
447+
srvr.busy_time += self.increment_time(current_time, -srvr.cust.service_start_date)
448448

449449

450450
def write_individual_record(self, individual):

ciw/tests/test_node.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,18 @@ def test_server_utilisation_with_schedules(self):
637637
recs = Q.get_all_records()
638638
self.assertEqual(Q.transitive_nodes[0].server_utilisation, 21.0/37.0)
639639

640+
def test_server_utilisation_with_wrapup(self):
641+
N = ciw.create_network(
642+
Arrival_distributions=[['Exponential',7.14]],
643+
Service_distributions=[['Exponential',0.04]],
644+
Number_of_servers=[70]
645+
)
646+
ciw.seed(1)
647+
Q = ciw.Simulation(N)
648+
Q.simulate_until_max_time(168)
649+
for srvr in Q.transitive_nodes[0].servers:
650+
self.assertGreaterEqual(srvr.total_time, srvr.busy_time)
651+
640652
def test_num_inds_equal_len_all_inds(self):
641653
# Create a Simulatin class that inherits form ciw.Simulation so that
642654
# an assertion than number_of_individuals == len(all_individuals)

0 commit comments

Comments
 (0)