Skip to content

Commit

Permalink
never mind, seem to need it
Browse files Browse the repository at this point in the history
  • Loading branch information
cliffckerr committed Dec 12, 2023
1 parent 3f663a0 commit 8c9e02c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
8 changes: 7 additions & 1 deletion stisim/sim.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,15 @@
import sciris as sc
import stisim as ss
import itertools

import numba as nb

__all__ = ['Sim', 'AlreadyRunError', 'diff_sims']

@nb.njit
def set_numba_seed(value):
# Needed to ensure reproducibility when using random calls in numba, e.g. RandomNetwork
# Note, these random numbers are not currently common-random-number safe
np.random.seed(value)

class Sim(sc.prettyobj):

Expand Down Expand Up @@ -79,6 +84,7 @@ def initialize(self, popdict=None, reset=False, **kwargs):
self.validate_dt()
self.init_time_vecs() # Initialize time vecs
ss.set_seed(self.pars['rand_seed']) # Reset the random seed before the population is created
set_numba_seed(self.pars['rand_seed'])

# Initialize the core sim components
self.rng_container.initialize(self.pars['rand_seed'] + 2) # +2 ensures that seeds from the above population initialization and the +1-offset below are not reused within the rng_container
Expand Down
6 changes: 3 additions & 3 deletions tests/benchmark.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"time": {
"people": 0.018,
"initialize": 0.043,
"run": 0.359
"initialize": 0.042,
"run": 0.356
},
"parameters": {
"n_agents": 10000,
"n_years": 20,
"dt": 0.2
},
"cpu_performance": 0.9410416196975259
"cpu_performance": 0.9653682555070681
}

0 comments on commit 8c9e02c

Please sign in to comment.