Compare commits
No commits in common. "f66de9fb541189a543118be8a5f81811f411276a" and "b9119fdb29b4b5d481ef904dca5847f85291196d" have entirely different histories.
f66de9fb54
...
b9119fdb29
File diff suppressed because it is too large
Load Diff
Before Width: | Height: | Size: 141 KiB After Width: | Height: | Size: 141 KiB |
File diff suppressed because it is too large
Load Diff
Before Width: | Height: | Size: 141 KiB |
File diff suppressed because it is too large
Load Diff
Before Width: | Height: | Size: 125 KiB After Width: | Height: | Size: 125 KiB |
4
PPO.py
4
PPO.py
|
@ -331,8 +331,8 @@ if __name__ == '__main__':
|
|||
buffer = list()
|
||||
'''init training parameters'''
|
||||
num_episode = args.num_episode
|
||||
# args.train = False
|
||||
# args.save_network = False
|
||||
args.train = False
|
||||
args.save_network = False
|
||||
# args.test_network = False
|
||||
# args.save_test_data = False
|
||||
# args.compare_with_gurobi = False
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import gym
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
|
||||
from gym import spaces
|
||||
from module import *
|
||||
from parameters import *
|
||||
from data_manager import *
|
||||
|
@ -39,8 +39,8 @@ class ESSEnv(gym.Env):
|
|||
self.solar = Solar(self.solar_parameters)
|
||||
self.wind = Wind(self.wind_parameters)
|
||||
|
||||
self.action_space = gym.spaces.Box(low=-1, high=1, shape=(5,), dtype=np.float32) # 已增加调节电压动作
|
||||
self.state_space = gym.spaces.Box(low=0, high=1, shape=(10,), dtype=np.float32)
|
||||
self.action_space = spaces.Box(low=-1, high=1, shape=(5,), dtype=np.float32) # 已增加调节电压动作
|
||||
self.state_space = spaces.Box(low=-np.inf, high=np.inf, shape=(10,), dtype=np.float32)
|
||||
|
||||
def reset(self, *args):
|
||||
self.month = np.random.randint(1, 13) # choose 12 month
|
||||
|
@ -69,7 +69,7 @@ class ESSEnv(gym.Env):
|
|||
temperature = self.data_manager.get_temperature_data(self.month, self.day, self.current_time)
|
||||
irradiance = self.data_manager.get_irradiance_data(self.month, self.day, self.current_time)
|
||||
wind_speed = self.data_manager.get_wind_data(self.month, self.day, self.current_time)
|
||||
|
||||
# print('house_load:', house_load)
|
||||
pv_generation = self.solar.step(temperature, irradiance)
|
||||
wd_generation = self.wind.step(wind_speed)
|
||||
generation = pv_generation + wd_generation
|
||||
|
@ -129,9 +129,10 @@ class ESSEnv(gym.Env):
|
|||
solar_cost = self.solar.get_cost(self.solar.current_power)
|
||||
wind_cost = self.wind.gen_cost(self.wind.current_power)
|
||||
|
||||
reward -= (battery_cost + dg1_cost + dg2_cost + dg3_cost + solar_cost + wind_cost + excess_penalty +
|
||||
deficient_penalty - sell_benefit + buy_cost) / 1e3
|
||||
self.operation_cost = (battery_cost + dg1_cost + dg2_cost + dg3_cost + solar_cost + wind_cost + excess_penalty +
|
||||
deficient_penalty - sell_benefit + buy_cost)
|
||||
reward -= self.operation_cost / 1e3
|
||||
self.unbalance = unbalance
|
||||
self.real_unbalance = self.shedding + self.excess
|
||||
final_step_outputs = [self.dg1.current_output, self.dg2.current_output, self.dg3.current_output,
|
||||
|
|
|
@ -133,8 +133,8 @@ def plot_evaluation_information(datasource, directory):
|
|||
axs[1, 1].cla()
|
||||
axs[1, 1].set_ylabel('Costs')
|
||||
axs[1, 1].bar(eval_data['time_step'], eval_data['operation_cost'])
|
||||
fig.savefig(f"{directory}/evaluation_information.svg", format='svg', dpi=600, bbox_inches='tight')
|
||||
print('evaluation figure have been ploted and saved')
|
||||
fig.savefig(f"{directory}/Evoluation Information.svg", format='svg', dpi=600, bbox_inches='tight')
|
||||
print('evaluation figure have been plot and saved')
|
||||
|
||||
|
||||
def make_dir(directory, feature_change):
|
||||
|
|
12
tools.py
12
tools.py
|
@ -43,8 +43,6 @@ def optimization_base_result(env, month, day, initial_soc):
|
|||
NUM_GEN = len(DG_parameters.keys())
|
||||
battery_capacity = env.battery.capacity
|
||||
battery_efficiency = env.battery.efficiency
|
||||
solar_cofficient = env.solar.opex_cofficient
|
||||
wind_cofficient = env.wind.opex_cofficient
|
||||
|
||||
m = gp.Model("UC")
|
||||
|
||||
|
@ -84,10 +82,8 @@ def optimization_base_result(env, month, day, initial_soc):
|
|||
t in range(period) for g in range(NUM_GEN))
|
||||
cost_grid_import = gp.quicksum(grid_energy_import[t] * price[t] for t in range(period))
|
||||
cost_grid_export = gp.quicksum(grid_energy_export[t] * price[t] * env.sell_coefficient for t in range(period))
|
||||
cost_solar = gp.quicksum(pv[t] * solar_cofficient for t in range(period))
|
||||
cost_wind = gp.quicksum(wind[t] * wind_cofficient for t in range(period))
|
||||
|
||||
m.setObjective((cost_gen + cost_grid_import - cost_grid_export + cost_solar + cost_wind), GRB.MINIMIZE)
|
||||
m.setObjective((cost_gen + cost_grid_import - cost_grid_export), GRB.MINIMIZE)
|
||||
m.optimize()
|
||||
|
||||
output_record = {'pv': [], 'wind': [], 'price': [], 'load': [], 'netload': [],
|
||||
|
@ -99,13 +95,11 @@ def optimization_base_result(env, month, day, initial_soc):
|
|||
for g in range(NUM_GEN))
|
||||
grid_import_cost = grid_energy_import[t].x * price[t]
|
||||
grid_export_cost = grid_energy_export[t].x * price[t] * env.sell_coefficient
|
||||
solar_cost = pv[t] * solar_cofficient
|
||||
wind_cost = wind[t] * wind_cofficient
|
||||
output_record['pv'].append(pv[t])
|
||||
output_record['wind'].append(wind[t])
|
||||
output_record['price'].append(price[t])
|
||||
output_record['load'].append(load[t])
|
||||
output_record['netload'].append(load[t] - pv[t] - wind[t])
|
||||
output_record['netload'].append(load[t] - pv[t])
|
||||
output_record['soc'].append(soc[t].x)
|
||||
output_record['battery_energy_change'].append(battery_energy_change[t].x)
|
||||
output_record['grid_import'].append(grid_energy_import[t].x)
|
||||
|
@ -113,7 +107,7 @@ def optimization_base_result(env, month, day, initial_soc):
|
|||
output_record['gen1'].append(gen_output[0, t].x)
|
||||
output_record['gen2'].append(gen_output[1, t].x)
|
||||
output_record['gen3'].append(gen_output[2, t].x)
|
||||
output_record['step_cost'].append(gen_cost + grid_import_cost - grid_export_cost + solar_cost + wind_cost)
|
||||
output_record['step_cost'].append(gen_cost + grid_import_cost - grid_export_cost)
|
||||
output_record_df = pd.DataFrame.from_dict(output_record)
|
||||
return output_record_df
|
||||
|
||||
|
|
Loading…
Reference in New Issue