Skip to content

Commit

Permalink
Change coincident switch on
Browse files Browse the repository at this point in the history
Move the code which determines whether the indexes are within or out of
the peak window outside the function, so it makes the argument of the
method more meaningful
  • Loading branch information
Bachibouzouk committed Jun 3, 2022
1 parent c740b76 commit 5353911
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions ramp/core/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -693,8 +693,8 @@ def calc_indexes_for_rand_switch_on(self, switch_on, rand_time, max_free_spot, r
indexes = np.arange(switch_on, switch_on + upper_limit)
return indexes

def calc_coincident_switch_on(self, peak_time_range, indexes):
"""Computes how many of the 'n' of the Appliance instance are switched on simultaneously
def calc_coincident_switch_on(self, inside_peak_window=True):
"""Computes how many of the 'n' Appliance instance are switched on simultaneously
Implement eqs. 3 and 4 of [1]
Expand All @@ -706,13 +706,13 @@ def calc_coincident_switch_on(self, peak_time_range, indexes):
"""
s_peak, mu_peak, op_factor = switch_on_parameters()

# check if indexes are in peak window
if np.in1d(peak_time_range, indexes).any() is True and self.fixed == 'no':
# check if indexes are within peak window
if inside_peak_window is True and self.fixed == 'no':
# calculates coincident behaviour within the peak time range
# eq. 4 of [1]
coincidence = min(self.number, max(1, math.ceil(random.gauss(mu=(self.number * mu_peak + 0.5), sigma=(s_peak * self.number * mu_peak)))))
# check if indexes are off-peak
elif np.in1d(peak_time_range, indexes).any() is False and self.fixed == 'no':
elif inside_peak_window is False and self.fixed == 'no':
# calculates probability of coincident switch_ons off-peak
# eq. 3 of [1]
prob = random.uniform(0, (self.number - op_factor) / self.number)
Expand Down Expand Up @@ -777,10 +777,10 @@ def generate_load_profile(self, rand_time, peak_time_range, rand_window_1, rand_
if tot_time > rand_time:
# the total functioning time is reached, a correction is applied to avoid overflow of indexes
indexes_adj = indexes[:-(tot_time - rand_time)]
inside_peak_window = np.in1d(peak_time_range, indexes_adj).any()
# Computes how many of the 'n' of the Appliance instance are switched on simultaneously
coincidence = self.calc_coincident_switch_on(
peak_time_range=peak_time_range,
indexes=indexes_adj,
inside_peak_window
)
# Update the daily use depending on existence of duty cycles of the Appliance instance
self.update_daily_use(
Expand All @@ -793,9 +793,9 @@ def generate_load_profile(self, rand_time, peak_time_range, rand_window_1, rand_
else:
# the total functioning time has not yet exceeded the rand_time
# Computes how many of the 'n' of the Appliance instance are switched on simultaneously
inside_peak_window = np.in1d(peak_time_range, indexes).any()
coincidence = self.calc_coincident_switch_on(
peak_time_range=peak_time_range,
indexes=indexes,
inside_peak_window
)
# Update the daily use depending on existence of duty cycles of the Appliance instance
self.update_daily_use(
Expand Down

0 comments on commit 5353911

Please sign in to comment.