Skip to content

Commit f59e2f9

Browse files
committed
only timestamp at change of current_time
1 parent f4898c2 commit f59e2f9

2 files changed

Lines changed: 7 additions & 9 deletions

File tree

ciw/simulation.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ def simulate_until_max_time(self, max_simulation_time, progress_bar=False):
192192

193193
while self.current_time < max_simulation_time:
194194
next_active_node = self.event_and_return_nextnode(next_active_node)
195+
self.statetracker.timestamp()
195196

196197
if progress_bar:
197198
remaining_time = max_simulation_time - self.progress_bar.n

ciw/trackers/state_tracker.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ def initialise(self, simulation):
1010
"""
1111
self.simulation = simulation
1212
self.state = None
13-
self.history = [[0.0, self.hash_state()]]
13+
self.history = []
14+
self.timestamp()
1415

1516
def change_state_accept(self, node_id, cust_clss):
1617
"""
@@ -58,22 +59,21 @@ def initialise(self, simulation):
5859
self.simulation = simulation
5960
self.state = [[0, 0] for i in range(
6061
self.simulation.network.number_of_nodes)]
61-
self.history = [[0.0, self.hash_state()]]
62+
self.history = []
63+
self.timestamp()
6264

6365
def change_state_accept(self, node_id, cust_clss):
6466
"""
6567
Changes the state of the system when a customer is accepted.
6668
"""
6769
self.state[node_id-1][0] += 1
68-
self.timestamp()
6970

7071
def change_state_block(self, node_id, destination, cust_clss):
7172
"""
7273
Changes the state of the system when a customer gets blocked.
7374
"""
7475
self.state[node_id-1][1] += 1
7576
self.state[node_id-1][0] -= 1
76-
self.timestamp()
7777

7878
def change_state_release(self, node_id, destination, cust_clss, blocked):
7979
"""
@@ -83,7 +83,6 @@ def change_state_release(self, node_id, destination, cust_clss, blocked):
8383
self.state[node_id-1][1] -= 1
8484
else:
8585
self.state[node_id-1][0] -= 1
86-
self.timestamp()
8786

8887
def hash_state(self):
8988
"""
@@ -118,22 +117,21 @@ def initialise(self, simulation):
118117
self.simulation.network.number_of_nodes)], [0 for i in range(
119118
self.simulation.network.number_of_nodes)]]
120119
self.increment = 1
121-
self.history = [[0.0, self.hash_state()]]
120+
self.history = []
121+
self.timestamp()
122122

123123
def change_state_accept(self, node_id, cust_clss):
124124
"""
125125
Changes the state of the system when a customer is accepted.
126126
"""
127127
self.state[-1][node_id-1] += 1
128-
self.timestamp()
129128

130129
def change_state_block(self, node_id, destination, cust_clss):
131130
"""
132131
Changes the state of the system when a customer gets blocked.
133132
"""
134133
self.state[0][node_id-1][destination-1].append(self.increment)
135134
self.increment += 1
136-
self.timestamp()
137135

138136
def change_state_release(self, node_id, destination, cust_clss, blocked):
139137
"""
@@ -147,7 +145,6 @@ def change_state_release(self, node_id, destination, cust_clss, blocked):
147145
self.adjust_positions(position)
148146
else:
149147
self.state[-1][node_id-1] -= 1
150-
self.timestamp()
151148

152149
def find_blocked_position_and_pop(self, node_id, destination):
153150
"""

0 commit comments

Comments
 (0)