-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathsetting.py
130 lines (111 loc) · 2.92 KB
/
setting.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
'''
- hyperparameters
- environment
- power ratings
- cost parameters
'''
import numpy as np
# --- Hyperparameters ---
BATCH_SIZE = 100
GAMMA = 0.99
LR_ACTOR = 5e-4
LR_CRITIC = 5e-4
NN_BOUND = 1.
SEQ_LENGTH= 1
# TD3 only
ACTION_NOISE_SCALE = 0.3
BUFFER_SIZE = 500000
NOISE_TYPE = 'param' # ['action', 'param']
PARAM_NOISE_ADAPT_RATE = 1.01
PARAM_NOISE_BOUND = 0.1
PARAM_NOISE_SCALE = 0.1
UPDATE_FREQ = 50
UPDATE_TIMES = 4
WARMUP = 1000
# PPO only
POLICY_CLIP = 0.2
TARGET_KL = 0.01
PPO_BATCH_SIZE = 60
PPO_TRAIN_FREQ = 720
PPO_TRAIN_ITERS = 80
# others
PREDICT_LENGTH = 24
DENSE_DIM_A = 16
DENSE_DIM_FNN = 16
DENSE_DIM_SEQ = 32
# Environment
HOUR_PER_TIME_STEP = 1
# --- Power Ratings ---
# PV
P_PV3_MAX = 0.3
P_PV4_MAX = 0.3
P_PV5_MAX = 0.4
P_PV6_MAX = 0.4
P_PV8_MAX = 0.4
P_PV9_MAX = 0.5
P_PV10_MAX = 0.5
P_PV11_MAX = 0.3
P_PV_MAX_LIST = [P_PV3_MAX, P_PV4_MAX, P_PV5_MAX, P_PV6_MAX, P_PV8_MAX, P_PV9_MAX, P_PV10_MAX, P_PV11_MAX]
# WT
P_WT7_MAX = 2.5
P_WT_MAX_LIST = [P_WT7_MAX]
# MGT
# P_MGT5_MAX = 0.033
# P_MGT9_MAX = 0.212
# P_MGT10_MAX = 0.033
# P_MGT5_MIN = 0.
# P_MGT9_MIN = 0.
# P_MGT10_MIN = 0.
# P_MGT_MAX_LIST = [P_MGT5_MAX, P_MGT9_MAX, P_MGT10_MAX]
# Battery
E_B5_MAX = 3.
P_B5_MAX = 0.6
P_B5_MIN = -0.6
E_B10_MAX = 1.
P_B10_MAX = 0.2
P_B10_MIN = -0.2
SOC_MAX = 0.9
SOC_MIN = 0.1
SOC_TOLERANCE = 0.01
# Load
P_LOADR1_MAX = 0.85
P_LOADR3_MAX = 0.285
P_LOADR4_MAX = 0.245
P_LOADR5_MAX = 0.65
P_LOADR6_MAX = 0.565
P_LOADR8_MAX = 0.605
P_LOADR10_MAX = 0.49
P_LOADR11_MAX = 0.34
P_LOAD_MAX_LIST = [P_LOADR1_MAX, P_LOADR3_MAX, P_LOADR4_MAX, P_LOADR5_MAX, P_LOADR6_MAX, P_LOADR8_MAX, P_LOADR10_MAX, P_LOADR11_MAX]
P_LOAD_MAX = P_LOADR1_MAX + P_LOADR3_MAX + P_LOADR4_MAX + P_LOADR5_MAX + P_LOADR6_MAX + P_LOADR8_MAX + P_LOADR10_MAX + P_LOADR11_MAX
# PCC
P_EXCESS_MAX = sum([*P_PV_MAX_LIST, *P_WT_MAX_LIST])
# State
# N_INTERMITTENT_STATES = len([P_EXCESS_MAX,'price'])
N_INTERMITTENT_STATES = len([*P_PV_MAX_LIST, *P_WT_MAX_LIST, *P_LOAD_MAX_LIST,'price'])
# N_INTERMITTENT_STATES = len([*P_PV_MAX_LIST, *P_WT_MAX_LIST, *P_LOAD_MAX_LIST, P_EXCESS_MAX,'price'])
N_CONTROLLABLE_STATES = len([P_B5_MAX, P_B10_MAX])
STATE_SEQ_SHAPE = (SEQ_LENGTH, N_INTERMITTENT_STATES)
STATE_FNN_SHAPE = (N_CONTROLLABLE_STATES,)
# Action
ACTION_IDX = {'p_b5': 0, 'p_b10': 1}
MAX_ACTION = np.array([P_B5_MAX, P_B10_MAX])
MIN_ACTION = np.array([P_B5_MIN, P_B10_MIN])
N_ACTION = len(MAX_ACTION)
# --- Cost Parameters ---
C_PRICE_MAX = 3.
# C_MGT5 = [100, 1.5]
# C_MGT9 = [15.8, 2.]
# C_MGT10 = [100, 1.5]
C_BAT5_DoD = 0.43
C_BAT10_DoD = 0.16
C_SOC_LIMIT = 100
MAX_COST = C_PRICE_MAX * (P_B5_MAX + P_B10_MAX + P_LOAD_MAX) + \
(C_BAT5_DoD + C_BAT10_DoD) * pow(SOC_MAX-SOC_MIN, 2) + \
C_SOC_LIMIT
REWARD_INVALID_ACTION = -5e-3
if __name__ == '__main__':
print(f'Number of actions: {N_ACTION}')
print(f'Number of intermittent states: {N_INTERMITTENT_STATES}')
print(f'Number of controllable states: {N_CONTROLLABLE_STATES}')
print(f'Load max: {P_LOAD_MAX}')