dragg package#

class dragg.aggregator.Aggregator(start=None, end=None, redis_url='redis://localhost')#

Bases: object

The aggregator combines the power consumption from all homes in the simulation, and manages the simulation of each home (MPCCalc) object in parallel.

calc_start_hour_index()#

Since all_data is posted as a list, where 0 corresponds to the first hour in the dataframe, the number of hours between the start_dt and the above mentioned hour needs to be calculated. :return: None

check_all_data_indices()#

Ensure enough data exists in all_data such that MPC calcs can be made throughout the requested start and end period. :return: None

check_baseline_vals()#
collect_data()#

Collects the data passed by the community redis connection. :return: None

create_homes()#

Given parameter distributions and number of homes of each type, create a list of dictionaries of homes with the parameters set for each home. :return:

create_mpc_home_obj()#
flush_redis()#

Cleans all information stored in the Redis server. (Including environmental and home data.) :return: None

gen_setpoint()#

Generates the setpoint of the RL utility. Dynamically sized for the number of houses in the community. :return: float

get_homes()#
join_data()#

Join the TOU, GHI, temp data into a single dataframe :return: pandas.DataFrame

my_summary()#
redis_add_all_data()#

Values for the timeseries data are written to Redis as a list, where the column names: [GHI, OAT, SPP] are the redis keys. Each list is as long as the data in self.all_data, which is 8760 for default config file. :return: None

redis_set_current_values()#

Sets the current values of the utility agent (reward price). :return: None

redis_set_initial_values()#

Set the initial timestep, iteration, reward price, and horizon to redis :return: None

reset_collected_data()#
reset_seed(new_seed)#

Reset value for seed. :param new_seed: int :return:

run()#

Runs simulation(s) specified in the config file with all combinations of parameters specified in the config file. :return: None

run_baseline()#

Runs the baseline simulation comprised of community of HEMS controlled homes. Utilizes MPC parameters specified in config file. (For no MPC in HEMS specify the MPC prediction horizon as 0.) :return: None

run_iteration()#

Calls the MPCCalc class to calculate the control sequence and power demand from all homes in the community. Threaded, using pathos :return: None

set_agg_mpc_initial_vals()#

Creates a dictionary to store values at each timestep for non-RL runs. :return: Dictionary

set_dummy_rl_parameters()#
set_run_dir()#

Sets the run directoy based on the start/end datetime, community and home configs, and the named version. :return: none

setup_rl_agg_run()#
summarize_baseline()#

Get the maximum of the aggregate demand for each simulation. :return: None

write_home_configs()#

Writes all home configurations to file at the initialization of the simulation for later reference. :return: None

write_outputs()#

Writes values for simulation run to a json file for later reference. Is called at the end of the simulation run period and optionally at a checkpoint period. :return: None

class dragg.logger.Logger(name)#

Bases: object

A logger for simulation outputs

dragg.logger.progress(self, message, *args, **kws)#
class dragg.mpc_calc.MPCCalc(home, redis_url='redis://localhost')#

Bases: object

add_base_constraints()#

Creates the system dynamics for thermal energy storage systems: HVAC and water heater.

Returns:

None

add_current_bounds()#
cast_redis_curr_rps()#

Casts the reward price signal values for the current timestep.

Returns:

None

cast_redis_timestep()#

Sets the timestep of the current time with respect to total simulation time.

Returns:

None

cleanup_and_finish()#

Resolves .solve_mpc() with error handling and collects all data on solver.

Returns:

None

get_initial_conditions()#
initialize_environmental_variables()#
redis_get_initial_values()#

Collects the values from the outside environment including GHI, OAT, and the base price set by the utility.

Returns:

None

redis_get_prev_optimal_vals()#

Collects starting point environmental values for all homes (such as current temperature). :return: None

redis_write_optimal_vals()#

Sends the optimal values for each home to the redis server. :return: None

run_home()#

Intended for parallelization in parent class (e.g. aggregator); runs a single MPCCalc home.

Returns:

None

set_base_p_grid()#

Sets p_grid of home to equal the load of the HVAC and water heater. To be used if and only if home type is base.

Returns:

None

set_battery_only_p_grid()#

Sets p_grid of home to equal the load of the HVAC and water heater, plus or minus the charge/discharge of the battery. To be used if and only if home is of type battery_only.

Returns:

None

set_environmental_variables()#

Slices cast values of the environmental values for the current timestep.

Returns:

None

set_p_grid()#
set_pv_battery_p_grid()#

Sets p_grid of home equal to the load of the HVAC and water heater, plus or minus the charge/discharge of the battery, minus potential generation from the PV subsystem. To be used if and only if the home is of type pv_battery.

Returns:

None

set_pv_only_p_grid()#

Sets p_grid of home equal to the load of the HVAC and water heater minus potential generation from the PV subsystem. To be used if and only if the home is of type pv_only.

Returns:

None

setup_base_problem()#

Sets variable objects for CVX optimization problem. Includes “base home” systems of HVAC and water heater. :return: None

solve_mpc(debug=False)#

Sets the objective function of the Home Energy Management System to be the minimization of cost over the MPC time horizon and solves via CVXPY. Used for all home types.

Returns:

None

solve_type_problem()#

Selects routine for MPC optimization problem setup and solve using home type.

Returns:

None

dragg.mpc_calc.manage_home(home)#

Calls class method as a top level function (picklizable by pathos) :return: None

class dragg.reformat.Reformat#

Bases: object

add_date_ranges()#
add_mpc_params()#
all_rps(fig)#
get_type_list(type)#
main()#
plot_all(save_images=False)#
plot_all_homes(fig=None)#
plot_base_home(name, fig, data, summary, fname, file, plot_price=True)#
plot_baseline(fig)#
plot_battery(name, fig, data, fname, file)#
plot_environmental_values(name, fig, summary, file, fname)#
plot_ev(name, fig, data, fname, file)#
plot_max_and_12hravg(fig)#
plot_parametric(fig)#
plot_pv(name, fig, data, fname, file)#
plot_single_home(fig)#
plot_thermal_bounds(fig, x_lims, name, fname)#
plot_typ_day(fig)#
rl2baseline(fig)#
save_images()#
set_date_folders()#
set_files()#
set_mpc_folders()#