nothing
This commit is contained in:
parent
438dbe5bf6
commit
f66de9fb54
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
After 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()
|
buffer = list()
|
||||||
'''init training parameters'''
|
'''init training parameters'''
|
||||||
num_episode = args.num_episode
|
num_episode = args.num_episode
|
||||||
args.train = False
|
# args.train = False
|
||||||
args.save_network = False
|
# args.save_network = False
|
||||||
# args.test_network = False
|
# args.test_network = False
|
||||||
# args.save_test_data = False
|
# args.save_test_data = False
|
||||||
# args.compare_with_gurobi = False
|
# args.compare_with_gurobi = False
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import gym
|
import gym
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
from gym import spaces
|
|
||||||
from module import *
|
from module import *
|
||||||
from parameters import *
|
from parameters import *
|
||||||
from data_manager import *
|
from data_manager import *
|
||||||
|
@ -39,8 +39,8 @@ class ESSEnv(gym.Env):
|
||||||
self.solar = Solar(self.solar_parameters)
|
self.solar = Solar(self.solar_parameters)
|
||||||
self.wind = Wind(self.wind_parameters)
|
self.wind = Wind(self.wind_parameters)
|
||||||
|
|
||||||
self.action_space = spaces.Box(low=-1, high=1, shape=(5,), dtype=np.float32) # 已增加调节电压动作
|
self.action_space = gym.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)
|
self.state_space = gym.spaces.Box(low=0, high=1, shape=(10,), dtype=np.float32)
|
||||||
|
|
||||||
def reset(self, *args):
|
def reset(self, *args):
|
||||||
self.month = np.random.randint(1, 13) # choose 12 month
|
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)
|
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)
|
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)
|
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)
|
pv_generation = self.solar.step(temperature, irradiance)
|
||||||
wd_generation = self.wind.step(wind_speed)
|
wd_generation = self.wind.step(wind_speed)
|
||||||
generation = pv_generation + wd_generation
|
generation = pv_generation + wd_generation
|
||||||
|
@ -129,10 +129,9 @@ class ESSEnv(gym.Env):
|
||||||
solar_cost = self.solar.get_cost(self.solar.current_power)
|
solar_cost = self.solar.get_cost(self.solar.current_power)
|
||||||
wind_cost = self.wind.gen_cost(self.wind.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 +
|
self.operation_cost = (battery_cost + dg1_cost + dg2_cost + dg3_cost + solar_cost + wind_cost + excess_penalty +
|
||||||
deficient_penalty - sell_benefit + buy_cost)
|
deficient_penalty - sell_benefit + buy_cost)
|
||||||
|
reward -= self.operation_cost / 1e3
|
||||||
self.unbalance = unbalance
|
self.unbalance = unbalance
|
||||||
self.real_unbalance = self.shedding + self.excess
|
self.real_unbalance = self.shedding + self.excess
|
||||||
final_step_outputs = [self.dg1.current_output, self.dg2.current_output, self.dg3.current_output,
|
final_step_outputs = [self.dg1.current_output, self.dg2.current_output, self.dg3.current_output,
|
||||||
|
|
|
@ -134,7 +134,7 @@ def plot_evaluation_information(datasource, directory):
|
||||||
axs[1, 1].set_ylabel('Costs')
|
axs[1, 1].set_ylabel('Costs')
|
||||||
axs[1, 1].bar(eval_data['time_step'], eval_data['operation_cost'])
|
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')
|
fig.savefig(f"{directory}/evaluation_information.svg", format='svg', dpi=600, bbox_inches='tight')
|
||||||
print('evaluation figure have been plot and saved')
|
print('evaluation figure have been ploted and saved')
|
||||||
|
|
||||||
|
|
||||||
def make_dir(directory, feature_change):
|
def make_dir(directory, feature_change):
|
||||||
|
|
Loading…
Reference in New Issue