import numpy as np from Utilities.Time import generate_timestrings, index_peak_times, index_operating_hours from scipy.optimize import root_scalar def get_no_of_peaks(peak_bounds): peak_occurences = np.random.randint(peak_bounds["min"], peak_bounds["max"], 1) return peak_occurences def generate_peak_info(c, dt): no_of_peaks = get_no_of_peaks(c["site_info"]["no_of_peaks"]) operating_hours = generate_timestrings( c["site_info"]["operating hours"]["start"], c["site_info"]["operating hours"]["end"], dt, ) peak_times = np.random.choice(operating_hours, no_of_peaks, replace=False) peak_durations = np.random.randint( c["site_info"]["peak_duration"]["min"], c["site_info"]["peak_duration"]["max"], no_of_peaks, ) return peak_times, peak_durations def generate_out_of_hours_consumption_ratio(c): # Generate a random ratio for out-of-hours consumption ratio = np.random.uniform( c["site_info"]["out_of_hours_consumption"]["min"], c["site_info"]["out_of_hours_consumption"]["max"], ) return ratio def generate_realistic_profile(site, peak_indices, out_of_hours_ratio): pass def objective(x): pass def get_load_profile(c, dt, batch_start_time, batch_process_duration): # Generate load profile for each site # c is the configuration dictionary # dt is the time step in seconds # batch_start_time is the start time for the batch process in seconds since the epoch # batch_process_duration is the duration of the batch process in seconds # start with indexing all the peak occurences # generate timeseries from start to end time start_time = batch_start_time end_time = start_time + batch_process_duration timestamps = np.arange(start_time, end_time + 1, dt) operating_hours_indices = index_operating_hours( timestamps, c["site_info"]["operating hours"] ) # loop through each site in the configuration for site in c["site_info"]["sites"]: # Generate peak times and durations peak_times, peak_durations = generate_peak_info(c, dt) # Generate peak times and durations peak_indices = index_peak_times(timestamps, peak_times, peak_durations) # Generate out-of-hours consumption ratio # The % of energy used outside of the operating hours out_of_hours_ratio = generate_out_of_hours_consumption_ratio(c)