-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_sequential.py
More file actions
53 lines (46 loc) · 1.59 KB
/
Copy pathtest_sequential.py
File metadata and controls
53 lines (46 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
"""
Basic test script for the ppsim package.
"""
import numpy as np
from ppsim import SimulatorSequentialArray
def test_simulator_sequential_array():
"""Test the SimulatorSequentialArray class."""
# Create a simulator instance
init_config = np.array([12,1,1,1], dtype=np.uint)
delta = np.array([
[[0,0], [1,1], [2,2], [3,3]],
[[1,1], [1,1], [2,2], [3,3]],
[[2,2], [2,2], [2,2], [3,3]],
[[3,3], [3,3], [3,3], [3,3]],
], dtype=np.uint)
null_transitions = np.zeros((4,4), dtype=np.bool)
random_transitions = np.zeros((4,4,2), dtype=np.uint)
random_outputs = np.zeros((1, 2), dtype=np.uint)
transition_probabilities = np.ones(1, dtype=np.float64)
sim = SimulatorSequentialArray(
init_config,
delta,
null_transitions,
random_transitions,
random_outputs,
transition_probabilities,
gillespie=False,
seed=0,
)
# print(f'{sim=}')
# print(f'{sim.config=}')
# print(f'{sim.delta=}')
# print(f'{sim.population=}')
# Create a test configuration array
config = np.array([12, 1, 1, 1], dtype=np.uint)
# Reset the simulator with the configuration
# sim.reset(config, t=0)
# Run the simulator
sim.run(t_max=10**1)
print(f"config: {sim.config} pop: {sim.population} init_config: {config}")
sim.reset(config, t=0)
print(f"config: {sim.config} pop: {sim.population}")
sim.run(t_max=10**1, max_wallclock_time=1)
print(f"config: {sim.config} pop: {sim.population}")
if __name__ == "__main__":
test_simulator_sequential_array()