Skip to content

Commit 855cf1f

Browse files
Merge pull request #170 from CiwPython/state-tracking
State tracking
2 parents df10d0c + 07c5423 commit 855cf1f

14 files changed

Lines changed: 1251 additions & 103 deletions

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ language: python
22
python:
33
- 3.5
44
- 3.6
5-
- "pypy3.5"
5+
- 3.7
6+
- "pypy3"
67

78
cache:
89
directories:

AUTHORS.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ Ciw has been developed by the following contributors:
1414
+ `Emma Aspland <https://github.com/EmmaAspland>`_
1515
+ `Henry Wilde <https://github.com/daffidwilde>`_
1616
+ `timlathy <https://github.com/timlathy>`_
17+
+ `Michalis Panayides <https://github.com/11michalis11>`_

README.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ Current supported version of Python:
4343

4444
- Python 3.5
4545
- Python 3.6
46-
- PyPy3.5
46+
- Python 3.7
47+
- PyPy3
4748

4849
Usage
4950
-----

appveyor.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
environment:
22
matrix:
3+
- PYTHON: "C:\\Python37"
34
- PYTHON: "C:\\Python36"
45
- PYTHON: "C:\\Python35"
56
install:

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/tests/test_simulation.py

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,14 +198,43 @@ def test_simulate_until_max_customers_with_pbar_method(self):
198198
self.assertEqual(Q3.progress_bar.n, max_custs)
199199

200200
def test_simulate_until_deadlock_method(self):
201+
# NaiveBlocking tracker
201202
ciw.seed(3)
202203
Q = ciw.Simulation(ciw.create_network_from_yml(
203204
'ciw/tests/testing_parameters/params_deadlock.yml'),
204205
deadlock_detector=ciw.deadlock.StateDigraph(),
205-
tracker=ciw.trackers.NaiveTracker())
206+
tracker=ciw.trackers.NaiveBlocking())
206207
Q.simulate_until_deadlock()
207208
self.assertEqual(round(Q.times_to_deadlock[((0, 0), (0, 0))], 8), 53.88526441)
208209

210+
# SystemPopulation tracker
211+
ciw.seed(3)
212+
Q = ciw.Simulation(ciw.create_network_from_yml(
213+
'ciw/tests/testing_parameters/params_deadlock.yml'),
214+
deadlock_detector=ciw.deadlock.StateDigraph(),
215+
tracker=ciw.trackers.SystemPopulation())
216+
Q.simulate_until_deadlock()
217+
self.assertEqual(round(Q.times_to_deadlock[0], 8), 53.88526441)
218+
219+
# NodePopulation tracker
220+
ciw.seed(3)
221+
Q = ciw.Simulation(ciw.create_network_from_yml(
222+
'ciw/tests/testing_parameters/params_deadlock.yml'),
223+
deadlock_detector=ciw.deadlock.StateDigraph(),
224+
tracker=ciw.trackers.NodePopulation())
225+
Q.simulate_until_deadlock()
226+
self.assertEqual(round(Q.times_to_deadlock[(0, 0)], 8), 53.88526441)
227+
228+
# NodeClassMatrix tracker
229+
ciw.seed(3)
230+
Q = ciw.Simulation(ciw.create_network_from_yml(
231+
'ciw/tests/testing_parameters/params_deadlock.yml'),
232+
deadlock_detector=ciw.deadlock.StateDigraph(),
233+
tracker=ciw.trackers.NodeClassMatrix())
234+
Q.simulate_until_deadlock()
235+
self.assertEqual(round(Q.times_to_deadlock[((0,), (0,))], 8), 53.88526441)
236+
237+
209238
def test_detect_deadlock_method(self):
210239
Q = ciw.Simulation(ciw.create_network_from_yml(
211240
'ciw/tests/testing_parameters/params_deadlock.yml'),
@@ -731,7 +760,7 @@ def test_schedules_and_blockages_work_together(self):
731760
queue_capacities=[2, 2]
732761
)
733762
ciw.seed(11)
734-
Q = ciw.Simulation(N, deadlock_detector=ciw.deadlock.StateDigraph(),tracker=ciw.trackers.NaiveTracker())
763+
Q = ciw.Simulation(N, deadlock_detector=ciw.deadlock.StateDigraph(),tracker=ciw.trackers.NaiveBlocking())
735764
Q.simulate_until_deadlock()
736765
ttd = Q.times_to_deadlock[((0, 0), (0, 0))]
737766
self.assertEqual(round(ttd, 5), 119.65819)

0 commit comments

Comments
 (0)