Skip to content

Commit

Permalink
Merge pull request #128 from JW-Kraft/review/set-random-seed
Browse files Browse the repository at this point in the history
Add seed parameter to UseCase
  • Loading branch information
Bachibouzouk authored May 13, 2024
2 parents d757cb8 + 87fc130 commit f8c269e
Show file tree
Hide file tree
Showing 3 changed files with 206 additions and 0 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ Maria C.G. Hart, Leibniz Universität Hannover <[email protected]>
Francesco Sanvito, TU Delft <[email protected]>
Gregory Ireland, Reiner Lemoine Institut <[email protected]>
Sergio Balderrama, Universidad Mayor de San Simon <[email protected]>
Johann Kraft, Reiner Lemoine Institut <[email protected]>
196 changes: 196 additions & 0 deletions docs/notebooks/random_seed.ipynb

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions ramp/core/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def __init__(
date_end: str = None,
parallel_processing: bool = False,
peak_enlarge: float = 0.15,
random_seed: int = None,
):
"""Creates a UseCase instance for gathering a list of User instances which own Appliance instances
Expand All @@ -70,6 +71,8 @@ def __init__(
if set True, the profiles will be generated in parallel rather than sequencially
peak_enlarge: float, optional
percentage random enlargement or reduction of peak time range length, used in UseCase.calc_peak_time_range
random_seed: int, optional
specify seed for the random number generator to exactly reproduce results
"""
self.name = name
Expand All @@ -90,6 +93,8 @@ def __init__(
self.__num_days = None
self.__datetimeindex = None
self.daily_profiles = None
self.random_seed = random_seed


self.appliances = []
self.users = []
Expand All @@ -101,6 +106,10 @@ def __init__(
if self.date_start is not None and self.date_end is not None:
self.initialize()

# Set global random seed if it is specified
if self.random_seed:
random.seed(self.random_seed)

@property
def date_start(self):
"""Start date of the daily profiles generated by the UseCase instance"""
Expand Down

0 comments on commit f8c269e

Please sign in to comment.