Skip to content

Commit

Permalink
Adds random seed for dream #267
Browse files Browse the repository at this point in the history
  • Loading branch information
thouska committed Apr 13, 2021
1 parent 2ca63c9 commit 9958b83
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion spotpy/algorithms/_algorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import numpy as np
import time
import threading
import random


try:
Expand Down Expand Up @@ -244,7 +245,9 @@ def __init__(self, spot_setup, dbname=None, dbformat=None, dbinit=True,
# Set the random state
if random_state is None: #ToDo: Have to discuss if these 3 lines are neccessary.
random_state = np.random.randint(low=0, high=2**30)
np.random.seed(random_state)
np.random.seed(random_state) #Both numpy.random and random or used in spotpy
random.seed(random_state) #Both numpy.random and random or used in spotpy


# If value is not None a timeout will set so that the simulation will break after sim_timeout seconds without return a value
self.sim_timeout = sim_timeout
Expand Down

0 comments on commit 9958b83

Please sign in to comment.