### Start TensorBoard for monitoring Source: https://github.com/hewlettpackard/dc-rl/blob/main/README.md Starts a TensorBoard server on port 6006 to visualize training metrics. Use an unused port if 6006 is occupied. ```bash %tensorboard --logdir results/sustaindc --port 6006 ``` -------------------------------- ### Install required packages Source: https://github.com/hewlettpackard/dc-rl/blob/main/README.md Installs the dependencies listed in requirements.txt using pip. ```bash pip install -r requirements.txt ``` -------------------------------- ### Navigate to project directory Source: https://github.com/hewlettpackard/dc-rl/blob/main/docs/installation.html Changes the current directory to the cloned dc-rl repository. ```bash cd dc-rl ``` -------------------------------- ### Run training with HAPPO algorithm Source: https://github.com/hewlettpackard/dc-rl/blob/main/README.md Example command to run training using the HAPPO algorithm with the experiment name 'happo_experiment'. ```bash python train_sustaindc.py --algo happo --exp_name happo_experiment ``` -------------------------------- ### Example dc_config.json configuration Source: https://github.com/hewlettpackard/dc-rl/blob/main/docs/usage/dcconf.html Example configuration file for customizing the data center environment. It includes sections for data center layout, HVAC parameters, and server characteristics. The file is located in the utils folder. ```json { "data_center_configuration": { "NUM_ROWS": 4, "NUM_RACKS_PER_ROW": 5, }, "hvac_configuration": { "C_AIR": 1006, "RHO_AIR": 1.225, "CRAC_SUPPLY_AIR_FLOW_RATE_pu": 0.00005663, "CRAC_REFRENCE_AIR_FLOW_RATE_pu": 0.00009438, "CRAC_FAN_REF_P": 150, "CHILLER_COP_BASE": 5.0, "CHILLER_COP_K": 0.1, "CHILLER_COP_T_NOMINAL": 25.0, "CT_FAN_REF_P": 1000, "CT_REFRENCE_AIR_FLOW_RATE": 2.8315, "CW_PRESSURE_DROP": 300000, "CW_WATER_FLOW_RATE": 0.0011, "CW_PUMP_EFFICIENCY": 0.87, "CT_PRESSURE_DROP": 300000, "CT_WATER_FLOW_RATE": 0.0011, "CT_PUMP_EFFICIENCY": 0.87 }, "server_characteristics": { "CPU_POWER_RATIO_LB": [0.01, 1.00], "CPU_POWER_RATIO_UB": [0.03, 1.02], "IT_FAN_AIRFLOW_RATIO_LB": [0.01, 0.225], "IT_FAN_AIRFLOW_RATIO_UB": [0.225, 1.0], } } ``` -------------------------------- ### Clone SustainDC repository with HTTPS Source: https://github.com/hewlettpackard/dc-rl/blob/main/docs/installation.html Clones the latest SustainDC version from GitHub using HTTPS. Requires Git installed. ```bash git clone https://github.com/HewlettPackard/dc-rl.git ``` -------------------------------- ### Monitor results with TensorBoard Source: https://github.com/hewlettpackard/dc-rl/blob/main/docs/_sources/gettingstarted.rst.txt Visualize training logs and results stored under the results sub-folder using TensorBoard. Specify the output directory of the results, replacing with the actual location. ```bash tensorboard --logdir ./results/dcrl//happo ``` -------------------------------- ### ShareVecEnv.step_async(actions) Source: https://github.com/hewlettpackard/dc-rl/blob/main/docs/code/harl.envs.html Tells all environments to start taking a step with the given actions. Call step_wait() to get the results of the step. Should not be called if a step_async run is already pending. ```APIDOC ## ShareVecEnv.step_async(actions) ### Description Tells all environments to start taking a step with the given actions. Call step_wait() to get the results of the step. Should not be called if a step_async run is already pending. ### Method step_async(actions) ### Parameters - **actions** - Required - Actions to step the environments with. ### Returns None ``` -------------------------------- ### ShareSubprocVecEnv.step_async(actions) Source: https://github.com/hewlettpackard/dc-rl/blob/main/docs/code/harl.envs.html Tells all environments to start taking a step with the given actions. Call step_wait() to get the results of the step. Should not be called if a step_async run is already pending. ```APIDOC ## ShareSubprocVecEnv.step_async(actions) ### Description Tells all environments to start taking a step with the given actions. Call step_wait() to get the results of the step. Should not be called if a step_async run is already pending. ### Method step_async(actions) ### Parameters - **actions** (array) - Required - Actions to apply to each environment. ### Returns None ``` -------------------------------- ### get_init_day() Source: https://github.com/hewlettpackard/dc-rl/blob/main/docs/code/modules.html Gets the initial day. This function is part of the utils.utils_cf module. ```APIDOC ## get_init_day() ### Description Gets the initial day. This function is part of the utils.utils_cf module. ### Method Function ### Endpoint utils.utils_cf.get_init_day ### Parameters No parameters documented. ### Returns No return value documented. ``` -------------------------------- ### get_init_day(start_month=0) Source: https://github.com/hewlettpackard/dc-rl/blob/main/docs/code/utils.html Obtains the initial day of the year to start the episode on. This function calculates the day corresponding to the first day of the specified month. ```APIDOC ## get_init_day(start_month=0) ### Description Obtains the initial day of the year to start the episode on. ### Method `get_init_day` ### Parameters - **start_month** (int, optional) - Starting month. Defaults to 0. ### Returns - **int** - Day of the year corresponding to the first day of the month. ``` -------------------------------- ### Imports and global setup for utils.managers Source: https://github.com/hewlettpackard/dc-rl/blob/main/docs/_modules/utils/managers.html Imports required libraries and sets the psychrolib unit system to SI. Defines the module-level PATH variable based on the file location. ```python import os import numpy as np import pandas as pd import psychrolib as psy file_path = os.path.abspath(__file__) PATH = os.path.split(os.path.dirname(file_path))[0] # Set the unit system for psychrolib psy.SetUnitSystem(psy.SI) ``` -------------------------------- ### Time_Manager.step method (incomplete) Source: https://github.com/hewlettpackard/dc-rl/blob/main/docs/_modules/utils/managers.html Starts the step function for the time manager but the implementation is truncated in the source. ```python [docs] def step(self): """Step function for the time maneger ``` -------------------------------- ### harl.utils.models_tools.init_device(args) Source: https://github.com/hewlettpackard/dc-rl/blob/main/sphinx/code/harl.utils.rst Initializes the device. ```APIDOC ## harl.utils.models_tools.init_device(args) ### Description Init device. ### Method Function call ### Endpoint harl.utils.models_tools.init_device(args) ### Parameters - **args** (dict) - Required - Arguments. ### Returns - **device** (torch.device) - Device. ``` -------------------------------- ### Clone SustainDC repository with SSH Source: https://github.com/hewlettpackard/dc-rl/blob/main/docs/installation.html Alternative clone command using SSH for users with SSH keys configured. ```bash git clone git@github.com:HewlettPackard/dc-rl.git ``` -------------------------------- ### make_dc_pyeplus_env(month=1, location='NYIS', dc_config_file='dc_config_file.json', datacenter_capacity_mw=1, max_bat_cap_Mw=2.0, add_cpu_usage=True, add_CI=True, episode_length_in_time=None, use_ls_cpu_load=False, num_sin_cos_vars=4) Source: https://github.com/hewlettpackard/dc-rl/blob/main/docs/code/utils.html Creates the data center environment with timeline, location, data files, gym specifications, and auxiliary methods. It returns an instantiated environment for the specified month. ```APIDOC ## make_dc_pyeplus_env(month=1, location='NYIS', dc_config_file='dc_config_file.json', datacenter_capacity_mw=1, max_bat_cap_Mw=2.0, add_cpu_usage=True, add_CI=True, episode_length_in_time=None, use_ls_cpu_load=False, num_sin_cos_vars=4) ### Description Method that creates the data center environment with the timeline, location, proper data files, gym specifications and auxiliary methods. ### Parameters - **month** (int, optional) - The month of the year for which the Environment uses the weather and Carbon Intensity data. Defaults to 1. - **location** (str, optional) - The geographical location in a standard format for which Carbon Intensity files are accessed. Supported options are 'NYIS', 'AZPS', 'BPAT'. Defaults to 'NYIS'. - **datacenter_capacity_mw** (int, optional) - Maximum capacity (MW) of the data center. This value will scale the number of servers installed in the data center. - **max_bat_cap_Mw** (float, optional) - The battery capacity in Megawatts for the installed battery. Defaults to 2.0. - **add_cpu_usage** (bool, optional) - Boolean Flag to indicate whether cpu usage is part of the environment statespace. Defaults to True. - **add_CI** (bool, optional) - Boolean Flag to indicate whether Carbon Intensity is part of the environment statespace. Defaults to True. - **episode_length_in_time** (pd.Timedelta, optional) - Length of an episode in terms of pandas time-delta object. Defaults to None. - **use_ls_cpu_load** (bool, optional) - Use the cpu workload value from a separate Load Shifting agent. This turns of reading default cpu data. Defaults to False. - **num_sin_cos_vars** (int, optional) - Number of sin and cosine variable that will be added externally from the centralized data source. ### Returns - **envs.dc_gym.dc_gymenv** - The environment instantiated with the particular month. ``` -------------------------------- ### Create and activate Conda environment Source: https://github.com/hewlettpackard/dc-rl/blob/main/docs/installation.html Creates a new Conda environment named 'sustaindc' with Python 3.10 and activates it. This step is optional. ```bash conda create -n sustaindc python=3.10 conda activate sustaindc ``` -------------------------------- ### DCGymEnv __init__ method Source: https://github.com/hewlettpackard/dc-rl/blob/main/docs/_modules/envs/dc_gym.html Initializes the DCGymEnv environment with observation and action spaces, data center configuration, and HVAC load ranges. Sets up internal state variables including battery state of charge, CPU load fraction, and power bounds. ```python self.observation_variables = observation_variables self.observation_space = observation_space self.action_variables = action_variables self.action_space = action_space self.action_mapping = action_mapping self.ranges = ranges self.seed = seed self.add_cpu_usage = add_cpu_usage self.ambient_temp = 20 self.scale_obs = False self.obs_max = [] self.obs_min = [] self.DC_Config = DC_Config # similar to reset self.dc = DataCenter.DataCenter_ITModel(num_racks=self.DC_Config.NUM_RACKS, rack_supply_approach_temp_list=self.DC_Config.RACK_SUPPLY_APPROACH_TEMP_LIST, rack_CPU_config=self.DC_Config.RACK_CPU_CONFIG, max_W_per_rack=self.DC_Config.MAX_W_PER_RACK, DC_ITModel_config=self.DC_Config) self.CRAC_Fan_load, self.CRAC_cooling_load, self.Compressor_load, self.CW_pump_load, self.CT_pump_load = None, None, None, None, None self.HVAC_load = self.ranges['Facility Total HVAC Electricity Demand Rate(Whole Building)'][0] self.rackwise_cpu_pwr, self.rackwise_itfan_pwr, self.rackwise_outlet_temp = [], [], [] self.cpu_load_frac = 0.5 self.bat_SoC = 300*1e3 # all units are SI self.raw_curr_state = None self.raw_next_state = None self.raw_curr_stpt = action_definition['cooling setpoints']['initial_value'] self.max_temp = max_temp self.min_temp = min_temp self.consecutive_actions = 0 self.last_action = None self.action_scaling_factor = 1 # Starts with a scale factor of 1 # IT + HVAC self.power_lb_kW = (self.ranges['Facility Total Building Electricity Demand Rate(Whole Building)'][0] + self.ranges['Facility Total HVAC Electricity Demand Rate(Whole Building)'][0]) / 1e3 self.power_ub_kW = (self.ranges['Facility Total Building Electricity Demand Rate(Whole Building)'][1] + self.ranges['Facility Total HVAC Electricity Demand Rate(Whole Building)'][1]) / 1e3 super().__init__() ``` -------------------------------- ### ShareDummyVecEnv.step_async(actions) Source: https://github.com/hewlettpackard/dc-rl/blob/main/docs/code/harl.envs.html Tells all environments to start taking a step with the given actions. Call step_wait() to get the results of the step. Should not be called if a step_async run is already pending. ```APIDOC ## ShareDummyVecEnv.step_async(actions) ### Description Tells all environments to start taking a step with the given actions. Call step_wait() to get the results of the step. Should not be called if a step_async run is already pending. ### Method step_async(actions) ### Parameters - **actions** (array) - Required - Actions to apply to each environment. ### Returns None ``` -------------------------------- ### init_dir(env, env_args, algo, exp_name, seed, logger_path) Source: https://github.com/hewlettpackard/dc-rl/blob/main/docs/_modules/harl/utils/configs_tools.html Initializes directories for saving results, including logs and models directories. Returns the paths to the results, logs, and models directories, along with a TensorBoard SummaryWriter. ```APIDOC ## init_dir(env, env_args, algo, exp_name, seed, logger_path) ### Description Initializes directories for saving results, including logs and models directories. Returns the paths to the results, logs, and models directories, along with a TensorBoard SummaryWriter. ### Parameters - **env** (str) - Required - Environment name. - **env_args** (dict) - Required - Environment configuration. - **algo** (str) - Required - Algorithm name. - **exp_name** (str) - Required - Experiment name. - **seed** (int) - Required - Random seed. - **logger_path** (str) - Required - Base path for logging. ### Returns - **results_path** (str) - Path to the results directory. - **log_path** (str) - Path to the logs directory. - **models_path** (str) - Path to the models directory. - **writter** (SummaryWriter) - TensorBoard summary writer. ``` -------------------------------- ### init_dir(env, env_args, algo, exp_name, seed, logger_path) Source: https://github.com/hewlettpackard/dc-rl/blob/main/docs/code/harl.utils.html Initializes the directory for saving results. ```APIDOC ## init_dir(env, env_args, algo, exp_name, seed, logger_path) ### Description Initializes the directory for saving results. ### Method Function call ### Endpoint harl.utils.configs_tools.init_dir ### Parameters - **env** - Required - Environment name. - **env_args** - Required - Environment arguments. - **algo** - Required - Algorithm name. - **exp_name** - Required - Experiment name. - **seed** - Required - Random seed. - **logger_path** - Required - Path for logger. ### Returns - Directory path for saving results. ``` -------------------------------- ### init_device(args) Source: https://github.com/hewlettpackard/dc-rl/blob/main/docs/code/harl.utils.html Initializes a torch device based on the provided arguments. Returns the device object. ```APIDOC ## init_device(args) ### Description Initializes a torch device based on the provided arguments. ### Parameters - **args** (dict) - Required - Arguments containing device configuration. ### Returns - (torch.device) - Device. ``` -------------------------------- ### Run in background mode Source: https://github.com/hewlettpackard/dc-rl/blob/main/docs/_sources/gettingstarted.rst.txt Run any Python script in the background using nohup. Replace PYTHON_SCRIPT with the script name (e.g., train_sustaindc.py) and OUTPUT_FILE with the output file name (e.g., latest_experiment_output). ```bash nohup python PYTHON_SCRIPT > OUTPUT_FILE.txt & ``` -------------------------------- ### dc_gym step() method with action scaling and HVAC power computation Source: https://github.com/hewlettpackard/dc-rl/blob/main/docs/_modules/envs/dc_gym.html Applies action mapping to adjust CRAC setpoint with dynamic scaling factor, clamps setpoint, computes IT load and outlet temperatures, calculates average CRAC return temp and total ITE load, then computes HVAC power components. Includes commented-out exploration loops. ```python def step(self, action): """ Makes an environment step in`dc_gymenv. Args: action_id (int): Action to take. Returns: observations (List[float]): Current state of the environmment reward (float): reward value. done (bool): A boolean value signaling the if the episode has ended. info (dict): A dictionary that containing additional information about the environment state """ crac_setpoint_delta = self.action_mapping[action] # Check if the current action is in the same direction as the last one if crac_setpoint_delta == self.last_action and action != 0: self.consecutive_actions += 1 else: self.consecutive_actions = 1 self.action_scaling_factor = 1 # Reset scaling factor if the direction changes # Adjust the scaling factor based on consecutive actions if self.consecutive_actions > 3: self.action_scaling_factor += 1 # Increase the scale factor after every 3 consecutive actions self.raw_curr_stpt += crac_setpoint_delta * self.action_scaling_factor self.raw_curr_stpt = max(min(self.raw_curr_stpt, self.max_temp), self.min_temp) ITE_load_pct_list = [self.cpu_load_frac*100 for i in range(self.DC_Config.NUM_RACKS)] # Util, Setpoint, Average return temperature, Average CRAC Ret Temp, DC ITE power, CT power, Chiller power # 0, 15, 26.26, 23.16, 656710 # 0, 21, 31.97, 28.87, 871450 # 100, 15, 35.45, 32.44, 1248170 # 100, 21, 36.88, 26.78, 1462910 self.rackwise_cpu_pwr, self.rackwise_itfan_pwr, self.rackwise_outlet_temp = \ self.dc.compute_datacenter_IT_load_outlet_temp(ITE_load_pct_list=ITE_load_pct_list, CRAC_setpoint=self.raw_curr_stpt) # for a in [0, 100]: # for b in [15, 23]: # ITE_load_pct_list = [a for i in range(self.DC_Config.NUM_RACKS)] # _, _, outlet = self.dc.compute_datacenter_IT_load_outlet_temp(ITE_load_pct_list=ITE_load_pct_list, CRAC_setpoint=b) # print(f'CPU util: {a}, Setpoint: {b}, Average Outlet Temp: {np.mean(outlet)}') avg_CRAC_return_temp = DataCenter.calculate_avg_CRAC_return_temp(rack_return_approach_temp_list=self.DC_Config.RACK_RETURN_APPROACH_TEMP_LIST, rackwise_outlet_temp=self.rackwise_outlet_temp) data_center_total_ITE_Load = sum(self.rackwise_cpu_pwr) + sum(self.rackwise_itfan_pwr) # Now, I want to obtain the CT_Cooling_load and the Compressor_load for the whole range of input parameters (setpoint, CRAC return temp, ambient temp) # for a in [15, 21]: # for c in [5, 20, 30, 40]: # for util in [0, 100]: # ITE_load_pct_list = [util for i in range(self.DC_Config.NUM_RACKS)] # self.rackwise_cpu_pwr, self.rackwise_itfan_pwr, self.rackwise_outlet_temp = \ # self.dc.compute_datacenter_IT_load_outlet_temp(ITE_load_pct_list=ITE_load_pct_list, CRAC_setpoint=a) # avg_CRAC_return_temp = DataCenter.calculate_avg_CRAC_return_temp(rack_return_approach_temp_list=self.DC_Config.RACK_RETURN_APPROACH_TEMP_LIST, # rackwise_outlet_temp=self.rackwise_outlet_temp) # data_center_total_ITE_Load = sum(self.rackwise_cpu_pwr) + sum(self.rackwise_itfan_pwr) # self.CRAC_Fan_load, self.CT_Cooling_load, self.CRAC_Cooling_load, self.Compressor_load, self.CW_pump_load, self.CT_pump_load = DataCenter.calculate_HVAC_power(CRAC_setpoint=a, # avg_CRAC_return_temp=avg_CRAC_return_temp, # ambient_temp=c, # data_center_full_load=data_center_total_ITE_Load, ``` -------------------------------- ### Initialize Workload_Manager with CPU data loading and noise setup Source: https://github.com/hewlettpackard/dc-rl/blob/main/docs/_modules/utils/managers.html Loads hourly CPU workload data from a CSV file (default Alibaba_CPU_Data_Hourly_1.csv), asserts one year of data (8760 points), interpolates to 4 steps per hour, applies timezone shift, and initializes a CoherentNoise process. ```python # Load CPU data from a CSV file # One year data=24*365=8760 if workload_filename == '': cpu_data_list = pd.read_csv(PATH+'/data/Workload/Alibaba_CPU_Data_Hourly_1.csv')['cpu_load'].values[:8760] else: cpu_data_list = pd.read_csv(PATH+f'/data/Workload/{workload_filename}')['cpu_load'].values[:8760] assert len(cpu_data_list) == 8760, "The number of data points in the workload data is not one year data=24*365=8760." cpu_data_list = cpu_data_list.astype(float) self.time_step = 0 self.future_steps = future_steps self.timestep_per_hour = 4 self.time_steps_day = self.timestep_per_hour*24 self.init_day = init_day self.timezone_shift = timezone_shift # Interpolate the CPU data to increase the number of data points x = range(0, len(cpu_data_list)) xcpu_new = np.linspace(0, len(cpu_data_list), len(cpu_data_list)*self.timestep_per_hour) self.cpu_smooth = np.interp(xcpu_new, x, cpu_data_list) # Shift the data to match the timezone shift self.cpu_smooth = np.roll(self.cpu_smooth, -1*self.timezone_shift*self.timestep_per_hour) # Save a copy of the original data self.original_data = self.cpu_smooth.copy() # Initialize CoherentNoise process self.coherent_noise = CoherentNoise(base=self.original_data[0], weight=weight, desired_std_dev=desired_std_dev) ``` -------------------------------- ### Workload_Manager.get_total_wkl() Source: https://github.com/hewlettpackard/dc-rl/blob/main/docs/code/modules.html Method to get total workload. ```APIDOC ## Workload_Manager.get_total_wkl() ### Description Method to get total workload. ### Method get_total_wkl() ### Parameters None documented. ### Returns Not documented. ``` -------------------------------- ### Monitor training on Tensorboard Source: https://github.com/hewlettpackard/dc-rl/blob/main/README.md Launch Tensorboard to monitor training logs. The log directory is /results/sustaindc//happo, where is the configured location. ```bash tensorboard --logdir /results/sustaindc//happo ``` -------------------------------- ### Workload_Manager.get_next_workload() Source: https://github.com/hewlettpackard/dc-rl/blob/main/docs/code/modules.html Method to get the next workload. ```APIDOC ## Workload_Manager.get_next_workload() ### Description Method to get the next workload. ### Method get_next_workload() ### Parameters None documented. ### Returns Not documented. ``` -------------------------------- ### init_dir: Create result directories and TensorBoard writer Source: https://github.com/hewlettpackard/dc-rl/blob/main/docs/_modules/harl/utils/configs_tools.html Creates the directory structure for saving experiment results, including a timestamped subdirectory under the logger path. Also creates a 'logs' subdirectory and a TensorBoard SummaryWriter, plus a 'models' subdirectory. Returns the paths and the writer. ```python def init_dir(env, env_args, algo, exp_name, seed, logger_path): """Init directory for saving results.""" task = get_task_name(env, env_args) hms_time = time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime()) results_path = os.path.join( logger_path, env, task, algo, exp_name, "-".join(["seed-{:0>5}".format(seed), hms_time]), ) log_path = os.path.join(results_path, "logs") os.makedirs(log_path, exist_ok=True) from tensorboardX import SummaryWriter writter = SummaryWriter(log_path) models_path = os.path.join(results_path, "models") os.makedirs(models_path, exist_ok=True) return results_path, log_path, models_path, writter ``` -------------------------------- ### on_episode_start callback - Initialize user_data variables Source: https://github.com/hewlettpackard/dc-rl/blob/main/sphinx/_build/html/_modules/utils/helper_methods.html Called at the beginning of each episode in the training process. Initializes user_data variables to be used later on, including 'Total Power kW', 'crac_setpoint_delta', and 'step_count'. ```python def on_episode_start(self, *, worker, base_env, policies, episode, env_index, **kwargs): """ Method that is called at the beginning of each episode in the training process. Initializes some user_data variables to be used later on. Args: worker (Worker): The worker object that is being used in the training process. base_env (BaseEnv): The base environment that is being used in the training process. policies (Dict[str, Policy]): The policies that are being used in the training process. episode (MultiAgentEpisode): The episode object that is being processed. env_index (int): The index of the environment within the worker task. **kwargs: additional arguments that can be passed. """ episode.user_data['Total Power kW'] = 0 episode.user_data['crac_setpoint_delta'] = [] episode.user_data["step_count"] = 0 ``` -------------------------------- ### Workload_Manager.get_current_workload() Source: https://github.com/hewlettpackard/dc-rl/blob/main/docs/code/modules.html Method to get the current workload. ```APIDOC ## Workload_Manager.get_current_workload() ### Description Method to get the current workload. ### Method get_current_workload() ### Parameters None documented. ### Returns Not documented. ``` -------------------------------- ### init(module, weight_init, bias_init, gain=1) Source: https://github.com/hewlettpackard/dc-rl/blob/main/docs/code/harl.utils.html Initializes a module with the given weight and bias initialization methods. Optionally applies a gain factor. ```APIDOC ## init(module, weight_init, bias_init, gain=1) ### Description Initializes a module with the given weight and bias initialization methods. ### Parameters - **module** (torch.nn) - Required - Module to initialize. - **weight_init** (torch.nn) - Required - Weight initialization method. - **bias_init** (torch.nn) - Required - Bias initialization method. - **gain** (float) - Optional - Gain factor (default: 1). ### Returns - (torch.nn) - Initialized module. ``` -------------------------------- ### Weather_Manager.get_current_temperature() Source: https://github.com/hewlettpackard/dc-rl/blob/main/docs/code/modules.html Method to get the current temperature. ```APIDOC ## Weather_Manager.get_current_temperature() ### Description Method to get the current temperature. ### Method get_current_temperature() ### Parameters None documented. ### Returns Not documented. ``` -------------------------------- ### init_device() Source: https://github.com/hewlettpackard/dc-rl/blob/main/docs/code/harl.utils.html Initializes the device (CPU/GPU). This function is part of the harl.utils.models_tools module. ```APIDOC ## init_device() ### Description Initializes the device (CPU/GPU). ### Method Function call ### Endpoint harl.utils.models_tools.init_device ### Parameters - **config** (dict) - Required - Configuration dictionary. ### Returns - Device object. ``` -------------------------------- ### Workload_Manager.get_n_next_workloads() Source: https://github.com/hewlettpackard/dc-rl/blob/main/docs/code/modules.html Method to get the next n workloads. ```APIDOC ## Workload_Manager.get_n_next_workloads() ### Description Method to get the next n workloads. ### Method get_n_next_workloads() ### Parameters None documented. ### Returns Not documented. ``` -------------------------------- ### Weather_Manager.get_total_weather() Source: https://github.com/hewlettpackard/dc-rl/blob/main/docs/code/modules.html Method to get total weather data. ```APIDOC ## Weather_Manager.get_total_weather() ### Description Method to get total weather data. ### Method get_total_weather() ### Parameters None documented. ### Returns Not documented. ``` -------------------------------- ### CI_Manager.step() Source: https://github.com/hewlettpackard/dc-rl/blob/main/docs/code/modules.html Method to step the carbon intensity manager. ```APIDOC ## CI_Manager.step() ### Description Method to step the carbon intensity manager. ### Method step() ### Parameters None documented. ### Returns Not documented. ``` -------------------------------- ### Weather_Manager.get_next_temperature() Source: https://github.com/hewlettpackard/dc-rl/blob/main/docs/code/modules.html Method to get the next temperature value. ```APIDOC ## Weather_Manager.get_next_temperature() ### Description Method to get the next temperature value. ### Method get_next_temperature() ### Parameters None documented. ### Returns Not documented. ``` -------------------------------- ### Run training script with algorithm and experiment name Source: https://github.com/hewlettpackard/dc-rl/blob/main/README.md Executes the training script for a specified algorithm and experiment name. Replace and with the desired values. ```bash python train_sustaindc.py --algo --exp_name ``` -------------------------------- ### Rack.cpu_and_fan_init() Source: https://github.com/hewlettpackard/dc-rl/blob/main/docs/code/envs.html Initializes the CPU and Fan parameters for the servers in each rack with the specified data center configurations. ```APIDOC ## Rack.cpu_and_fan_init() ### Description Initializes the CPU and Fan parameters for the servers in each rack with the specified data center configurations. ### Method cpu_and_fan_init ### Endpoint Rack.cpu_and_fan_init() ### Parameters None ### Returns None ``` -------------------------------- ### CI_Manager.get_forecast_ci() Source: https://github.com/hewlettpackard/dc-rl/blob/main/docs/code/modules.html Method to get the forecast carbon intensity. ```APIDOC ## CI_Manager.get_forecast_ci() ### Description Method to get the forecast carbon intensity. ### Method get_forecast_ci() ### Parameters None documented. ### Returns Not documented. ``` -------------------------------- ### OnPolicyCriticBufferFP.get_mean_rewards() Source: https://github.com/hewlettpackard/dc-rl/blob/main/sphinx/code/harl.common.buffers.rst Get the mean rewards. ```APIDOC ## OnPolicyCriticBufferFP.get_mean_rewards() ### Description Get the mean rewards. ### Method get_mean_rewards ### Signature `get_mean_rewards()` ### Parameters None ### Returns Mean rewards ``` -------------------------------- ### make_bat_fwd_env(month, max_bat_cap_Mwh=2.0, charging_rate=0.5, max_dc_pw_MW=7.23, dcload_max=2.5, dcload_min=0.1, n_fwd_steps=4) Source: https://github.com/hewlettpackard/dc-rl/blob/main/docs/code/utils.html Builds the Battery environment for forward simulation. It takes the training month and battery configuration parameters, returning a battery environment instance. ```APIDOC ## make_bat_fwd_env(month, max_bat_cap_Mwh=2.0, charging_rate=0.5, max_dc_pw_MW=7.23, dcload_max=2.5, dcload_min=0.1, n_fwd_steps=4) ### Description Method to build the Battery environment. ### Parameters - **month** (int) - Required - Month of the year in which the agent is training. - **max_bat_cap_Mwh** (float, optional) - Max battery capacity. Defaults to 2.0. - **charging_rate** (float, optional) - Charging rate of the battery. Defaults to 0.5. - **reward_method** (str, optional) - Method used to calculate the rewards. Defaults to 'default_bat_reward'. ### Returns - **battery_env_fwd** - Battery environment. ``` -------------------------------- ### Battery2.__init__ Source: https://github.com/hewlettpackard/dc-rl/blob/main/sphinx/_build/html/code/envs.html Initializes a Battery2 instance with capacity, current load, efficiencies, and charge/discharge limits. ```APIDOC ## Battery2.__init__ ### Description Initializes a Battery2 instance with capacity, current load, efficiencies, and charge/discharge limits. ### Method Constructor ### Parameters - **capacity** (float) - Required - Battery capacity. - **current_load** (float) - Optional - Initial current load (default 0). - **eff_c** (float) - Optional - Charging efficiency (default 1). - **eff_d** (float) - Optional - Discharging efficiency (default 1). - **c_lim** (float) - Optional - Charging limit (default 0.1). - **d_lim** (float) - Optional - Discharging limit (default 1). - **upper_u** (float) - Optional - Upper limit u (default -0.04). - **upper_v** (float) - Optional - Upper limit v (default 1). - **lower_u** (float) - Optional - Lower limit u (default 0.01). - **lower_v** (float) - Optional - Lower limit v (default 0). ### Returns None ``` -------------------------------- ### Weather_Manager.get_n_next_temperature() Source: https://github.com/hewlettpackard/dc-rl/blob/main/docs/code/modules.html Method to get the next n temperature values. ```APIDOC ## Weather_Manager.get_n_next_temperature() ### Description Method to get the next n temperature values. ### Method get_n_next_temperature() ### Parameters None documented. ### Returns Not documented. ``` -------------------------------- ### Weather_Manager.get_current_wet_bulb() Source: https://github.com/hewlettpackard/dc-rl/blob/main/docs/code/modules.html Method to get the current wet bulb temperature. ```APIDOC ## Weather_Manager.get_current_wet_bulb() ### Description Method to get the current wet bulb temperature. ### Method get_current_wet_bulb() ### Parameters None documented. ### Returns Not documented. ``` -------------------------------- ### System Sizing with DC_Config Source: https://github.com/hewlettpackard/dc-rl/blob/main/docs/_modules/utils/make_envs_pyenv.html Instantiates DC_Config with the provided configuration file and datacenter capacity to scale the number of CPUs. Comments explain how ambient temperature and min_CRAC_setpoint affect cooling tower and HVAC power consumption. ```python # from DC_Config, scale the variable number of CPUs to have a similar value to "datacenter_capacity_mw" dc_config = DC_Config(dc_config_file=dc_config_file, datacenter_capacity_mw=datacenter_capacity_mw) # Specify the relative or absolute path # Perform Cooling Tower Sizing # This step determines the potential maximum loading of the CT # setting a higher ambient temp here will cause the CT to consume less power for cooling water under normal ambient temperature. Lower amb temp -> higher HVAC power # setting a lower value of min_CRAC_setpoint will cause the CT to consume more power for higher crac setpoints during normal use. Lower min_CRAC_set -> higher HVAC power # dictionary with locations and min_CRAC_setpoint/max_amb_temp ``` -------------------------------- ### OnPolicyCriticBufferEP.get_mean_rewards Source: https://github.com/hewlettpackard/dc-rl/blob/main/sphinx/code/harl.common.buffers.rst Get mean rewards for logging. ```APIDOC ## OnPolicyCriticBufferEP.get_mean_rewards ### Description Get mean rewards for logging. ### Method Method call ### Endpoint OnPolicyCriticBufferEP.get_mean_rewards() ### Parameters None ### Response Mean rewards. ``` -------------------------------- ### make_dc_pyeplus_env Source: https://github.com/hewlettpackard/dc-rl/blob/main/docs/_modules/utils/make_envs_pyenv.html Creates the data center environment with timeline, location, data files, gym specifications, and auxiliary methods. ```APIDOC ## make_dc_pyeplus_env ### Description Method that creates the data center environment with the timeline, location, proper data files, gym specifications and auxiliary methods. ### Parameters - **month** (int, optional) - Month of the year. Defaults to 1. - **location** (str, optional) - Location identifier. Defaults to 'NYIS'. - **dc_config_file** (str, optional) - Data center configuration file name. Defaults to 'dc_config_file.json'. - **datacenter_capacity_mw** (int, optional) - Data center capacity in MW. Defaults to 1. - **max_bat_cap_Mw** (float, optional) - Max battery capacity in MW. Defaults to 2.0. - **add_cpu_usage** (bool, optional) - Whether to add CPU usage. Defaults to True. - **add_CI** (bool, optional) - Whether to add CI. Defaults to True. - **episode_length_in_time** (pd.Timedelta, optional) - Episode length in time. Defaults to None. - **use_ls_cpu_load** (bool, optional) - Whether to use LS CPU load. Defaults to False. - **num_sin_cos_vars** (int, optional) - Number of sine/cosine variables. Defaults to 4. ``` -------------------------------- ### CI_Manager.get_n_past_ci() Source: https://github.com/hewlettpackard/dc-rl/blob/main/docs/code/modules.html Method to get n past carbon intensity values. ```APIDOC ## CI_Manager.get_n_past_ci() ### Description Method to get n past carbon intensity values. ### Method get_n_past_ci() ### Parameters None documented. ### Returns Not documented. ``` -------------------------------- ### dc_gymenv.step(action) Source: https://github.com/hewlettpackard/dc-rl/blob/main/sphinx/_build/html/code/envs.html Makes an environment step in dc_gymenv. ```APIDOC ## step(action) ### Description Makes an environment step in dc_gymenv. ### Method step ### Parameters - **action_id** (int) - Action to take. ### Returns - **observations** (List[float]) - Current state of the environment. - **reward** (float) - Reward value. - **done** (bool) - A boolean value signaling if the episode has ended. - **info** (dict) - A dictionary containing additional information about the environment state. ``` -------------------------------- ### ValueNorm.running_mean_var Source: https://github.com/hewlettpackard/dc-rl/blob/main/docs/code/harl.common.html Get running mean and variance. ```APIDOC ## ValueNorm.running_mean_var ### Description Get running mean and variance. ### Method `running_mean_var()` ### Returns - **tuple** - A tuple containing the running mean and variance. ``` -------------------------------- ### OnPolicyCriticBufferFP.get_mean_rewards() Source: https://github.com/hewlettpackard/dc-rl/blob/main/docs/code/harl.common.buffers.html Get the mean rewards from the buffer. ```APIDOC ## OnPolicyCriticBufferFP.get_mean_rewards() ### Description Get the mean rewards from the buffer. ### Method Method call ### Endpoint OnPolicyCriticBufferFP.get_mean_rewards() ### Parameters None ### Response Mean rewards value. ``` -------------------------------- ### Initialize CPU and Fan Parameters (cpu_and_fan_init) Source: https://github.com/hewlettpackard/dc-rl/blob/main/docs/_modules/envs/datacenter.html Initializes CPU and IT fan parameters for each rack based on data center configurations. Sets coefficients m_coefficient=10, c_coefficient=5, and it_slope=20, and converts collected lists to numpy arrays for vectorized operations. ```python def cpu_and_fan_init(self,): """ Initialize the CPU and Fan parameters for the servers in each rack with the specified data center configurations """ #common to both cpu and fan inlet_temp_lb,inlet_temp_ub =[],[] # only for cpu m_cpu,c_cpu,ratio_shift_max_cpu,\ idle_pwr, full_load_pwr = [],[],[],[],[] # only for it fan m_itfan,c_itfan,ratio_shift_max_itfan,\ ITFAN_REF_P,ITFAN_REF_V_RATIO,IT_FAN_FULL_LOAD_V = \ [],[],[],[],[],[] self.m_coefficient = 10 #1 -> 10 self.c_coefficient = 5 #1 -> 5 self.it_slope = 20 #100 -> 20 for CPU_item in self.CPU_list: #common to both cpu and fan inlet_temp_lb.append(CPU_item.cpu_config.INLET_TEMP_RANGE[0]) inlet_temp_ub.append(CPU_item.cpu_config.INLET_TEMP_RANGE[1]) # only for cpu m_cpu.append(CPU_item.m_cpu) c_cpu.append(CPU_item.c_cpu) ratio_shift_max_cpu.append(CPU_item.ratio_shift_max_cpu) idle_pwr.append(CPU_item.idle_pwr) full_load_pwr.append(CPU_item.full_load_pwr) # only for itfan m_itfan.append(CPU_item.m_itfan) c_itfan.append(CPU_item.c_itfan) ratio_shift_max_itfan.append(CPU_item.ratio_shift_max_itfan) ITFAN_REF_P.append(CPU_item.cpu_config.ITFAN_REF_P) ITFAN_REF_V_RATIO.append(CPU_item.cpu_config.ITFAN_REF_V_RATIO) IT_FAN_FULL_LOAD_V.append(CPU_item.cpu_config.IT_FAN_FULL_LOAD_V) # commont to both cpu and itfan self.inlet_temp_lb,self.inlet_temp_ub =np.array(inlet_temp_lb),\ np.array(inlet_temp_ub) # only for cpu self.m_cpu,self.c_cpu,self.ratio_shift_max_cpu,\ self.idle_pwr, self.full_load_pwr = \ np.array(m_cpu),np.array(c_cpu),\ np.array(ratio_shift_max_cpu),\ np.array(idle_pwr), np.array(full_load_pwr) # only for itfan self.m_itfan,self.c_itfan,self.ratio_shift_max_itfan,\ self.ITFAN_REF_P,self.ITFAN_REF_V_RATIO,self.IT_FAN_FULL_LOAD_V = \ np.array(m_itfan),np.array(c_itfan),np.array(ratio_shift_max_itfan),\ np.array(ITFAN_REF_P),np.array(ITFAN_REF_V_RATIO),np.array(IT_FAN_FULL_LOAD_V) ``` -------------------------------- ### get_obs: build observation list Source: https://github.com/hewlettpackard/dc-rl/blob/main/docs/_modules/envs/dc_gym.html Returns a list of five observation values: ambient temperature, cooling setpoint, zone air temperature, HVAC power, and IT power. Uses defaults when data is unavailable. ```python def get_obs(self): """ Returns the observation at the current time step. Returns: observation (List[float]): Current state of the environmment. """ zone_air_therm_cooling_stpt = self.min_temp # in C, default for reset state if self.raw_curr_stpt is not None: zone_air_therm_cooling_stpt = self.raw_curr_stpt zone_air_temp = self.obs_min[2] # in C, default for reset state if self.rackwise_outlet_temp: zone_air_temp = sum(self.rackwise_outlet_temp)/len(self.rackwise_outlet_temp) # 'Facility Total HVAC Electricity Demand Rate(Whole Building)' ie 'HVAC POWER' hvac_power = self.HVAC_load #self.CT_Cooling_load + self.Compressor_load # 'Facility Total Building Electricity Demand Rate(Whole Building)' ie 'IT POWER' if self.rackwise_cpu_pwr: it_power = sum(self.rackwise_cpu_pwr) + sum(self.rackwise_itfan_pwr) else: it_power = self.ranges['Facility Total Building Electricity Demand Rate(Whole Building)'][0] return [self.ambient_temp, zone_air_therm_cooling_stpt, zone_air_temp, hvac_power, it_power] ``` -------------------------------- ### OnPolicyCriticBufferEP.get_mean_rewards Source: https://github.com/hewlettpackard/dc-rl/blob/main/docs/code/harl.common.buffers.html Get mean rewards for logging. ```APIDOC ## OnPolicyCriticBufferEP.get_mean_rewards ### Description Get mean rewards for logging. ### Method `get_mean_rewards()` ### Parameters None ### Returns Mean rewards (float). ``` -------------------------------- ### make_ls_env(month, n_vars_ci=4, n_vars_energy=4, n_vars_battery=1, queue_max_len=500, test_mode=False) Source: https://github.com/hewlettpackard/dc-rl/blob/main/docs/code/utils.html Builds the Load shifting environment. It takes the training month and configuration parameters for the environment, returning a CarbonLoadEnv instance. ```APIDOC ## make_ls_env(month, n_vars_ci=4, n_vars_energy=4, n_vars_battery=1, queue_max_len=500, test_mode=False) ### Description Method to build the Load shifting environment. ### Parameters - **month** (int) - Required - Month of the year in which the agent is training. - **n_vars_energy** (int, optional) - Number of variables from the Energy environment. Defaults to 4. - **n_vars_battery** (int, optional) - Number of variables from the Battery environment. Defaults to 1. - **queue_max_len** (int, optional) - The size of the queue where the tasks are stored to be processed latter. Default to 500. ### Returns - **envs.carbon_ls.CarbonLoadEnv** - Load Shifting environment. ``` -------------------------------- ### BaseLogger.get_task_name() Source: https://github.com/hewlettpackard/dc-rl/blob/main/sphinx/code/harl.common.rst Gets the task name. ```APIDOC ## BaseLogger.get_task_name() ### Description Gets the task name. ### Method get_task_name ### Parameters None ### Returns - **task_name** (unknown) - The name of the task. ``` -------------------------------- ### init_dir() Source: https://github.com/hewlettpackard/dc-rl/blob/main/docs/code/harl.utils.html Initializes directories for saving results. This function is part of the harl.utils.configs_tools module. ```APIDOC ## init_dir() ### Description Initializes directories for saving results. ### Method Function call ### Endpoint harl.utils.configs_tools.init_dir ### Parameters - **config** (dict) - Required - Configuration dictionary. ### Returns - None ``` -------------------------------- ### OffPolicyBufferEP.next Source: https://github.com/hewlettpackard/dc-rl/blob/main/docs/code/harl.common.buffers.html Get next indices for the off-policy buffer. ```APIDOC ## OffPolicyBufferEP.next ### Description Get next indices for the off-policy buffer. ### Method next ### Parameters - **indices** - The indices to get next for. ### Returns Next indices. ``` -------------------------------- ### ValueNorm.running_mean_var() Source: https://github.com/hewlettpackard/dc-rl/blob/main/sphinx/code/harl.common.rst Gets the running mean and variance. ```APIDOC ## ValueNorm.running_mean_var() ### Description Gets the running mean and variance. ### Method running_mean_var ### Parameters None ### Returns - **mean** (unknown) - The running mean. - **var** (unknown) - The running variance. ``` -------------------------------- ### OffPolicyBufferEP.next(indices) Source: https://github.com/hewlettpackard/dc-rl/blob/main/sphinx/_build/html/code/harl.common.buffers.html Get next indices for the off-policy buffer. ```APIDOC ## next(indices) ### Description Get next indices for the off-policy buffer. ### Method next ### Parameters - **indices** - Required - Indices to get next values for. ### Returns Next indices. ```