@@ -197,6 +197,18 @@ def setVerbose(self, verbose):
197
197
"""
198
198
self .simParams .verbose = verbose
199
199
200
+
201
+ def setJobNumber (self , job_number ):
202
+ """
203
+ Set the job number of the simulation.
204
+ Used in AWS work to modify the seed used in dispersion.
205
+ Should be set to $AWS_BATCH_JOB_ARRAY_INDEX
206
+
207
+ :param job_number:
208
+ :return:
209
+ """
210
+ self .simParams .job_number = job_number
211
+
200
212
def setDispMagnitudeFile (self , magnitudes ):
201
213
"""
202
214
Save .txt with the magnitude of each dispersion in % or sigma away from mean
@@ -712,7 +724,7 @@ class SimulationParameters():
712
724
def __init__ (self , creationFunction , executionFunction , configureFunction ,
713
725
retentionPolicies , dispersions , shouldDisperseSeeds ,
714
726
shouldArchiveParameters , filename , icfilename , index = None , verbose = False , modifications = {},
715
- showProgressBar = False ):
727
+ showProgressBar = False , job_number = 1 ):
716
728
self .index = index
717
729
self .creationFunction = creationFunction
718
730
self .executionFunction = executionFunction
@@ -728,7 +740,7 @@ def __init__(self, creationFunction, executionFunction, configureFunction,
728
740
self .dispersionMag = {}
729
741
self .saveDispMag = False
730
742
self .showProgressBar = showProgressBar
731
-
743
+ self . job_number = job_number
732
744
733
745
734
746
class SimulationExecutor :
@@ -764,9 +776,11 @@ def __call__(cls, params):
764
776
try :
765
777
signal .signal (signal .SIGINT , signal .SIG_IGN ) # On ctrl-c ignore the signal... let the parent deal with it.
766
778
767
- # must make new random seed on each new thread.
768
- np .random .seed (simParams .index * 10 )
769
- random .seed (simParams .index * 10 )
779
+
780
+ # must make new random seed on each new thread and job number
781
+ dispersion_seed = (simParams .job_number << 32 ) + (simParams .index * 10 )
782
+ np .random .seed (dispersion_seed )
783
+ random .seed (dispersion_seed )
770
784
771
785
# create the users sim by calling their supplied creationFunction
772
786
simInstance = simParams .creationFunction ()
0 commit comments