-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcompute_results.py
More file actions
82 lines (68 loc) · 2.7 KB
/
Copy pathcompute_results.py
File metadata and controls
82 lines (68 loc) · 2.7 KB
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
import os
current_path = os.path.abspath('')
import pandas as pd
import numpy as np
from datetime import date, datetime, timedelta
from tools import Customer, DataFrame, time_series_to_json
from param import (
RHO_C,
RHO_D,
U_LOW,
U_UP,
X_LOW,
X_UP,
lt_1213,
P_PURCHASE,
P_SALE,
DAY_BEGIN,
DAY_END,
DATA_BEGIN,
ONE_STEP
)
from forecast import res, forecast_two_next_weeks, forecast_prices
from optimisation import solve_optim
if __name__ == "__main__":
x = [0.0 for i in range(5 * 48)]
cost = [0]
u = []
x_forecast_memory = np.zeros(((DAY_END - DAY_BEGIN) // ONE_STEP, 14 * 48-1))
net_demand_forecast_memory = np.zeros(((DAY_END - DAY_BEGIN) // ONE_STEP, 14 * 48))
last_x_memory = np.zeros(((DAY_END - DAY_BEGIN) // ONE_STEP, 5 * 48))
last_net_demand_memory = np.zeros(((DAY_END - DAY_BEGIN) // ONE_STEP, 5 * 48))
for i in range((DAY_END - DAY_BEGIN) // ONE_STEP):
print(i)
day = DAY_BEGIN + i * ONE_STEP
two_last_weeks = lt_1213.customers[0].net_load[(day-DATA_BEGIN) // ONE_STEP - 14*48 : (day-DATA_BEGIN) // ONE_STEP]
two_next_weeks = forecast_two_next_weeks(two_last_weeks, res, 14*48)
p_buy, p_sell = forecast_prices(day, P_PURCHASE, P_SALE, step=ONE_STEP, n_days=14)
dict_var = solve_optim(
forecast=two_next_weeks,
rho_c=RHO_C,
rho_d=RHO_D,
u_low=U_LOW,
u_up=U_UP,
x_low=X_LOW,
x_up=X_UP,
last_x=x[-1],
p_buy=p_buy,
p_sell=p_sell,
index=i
)
#advised_battery_load = [dict_var['battery_load_' + str(i)] for i in range(len(two_next_weeks)-1)]
x_forecast = [dict_var['battery_state_' + str(i)] for i in range(1, len(two_next_weeks))]
print(dict_var['battery_load_positive_part_0'], dict_var['battery_load_negative_part_0'])
u.append(dict_var['battery_load_positive_part_0'] - dict_var['battery_load_negative_part_0'])
x.append(x_forecast[1])
x_forecast_memory[i,:] = x_forecast
net_demand_forecast_memory[i,:] = two_next_weeks
last_x_memory[i,:] = x[-5*48:]
last_net_demand_memory[i,:] = lt_1213.customers[0].net_load[(day - DATA_BEGIN) // ONE_STEP - 5*48 : (day-DATA_BEGIN) // ONE_STEP]
np.save("save/x_forecast_memory", x_forecast_memory)
np.save("save/net_demand_forecast_memory", net_demand_forecast_memory)
np.save("save/last_x_memory", last_x_memory)
np.save("save/last_net_demand_memory", last_net_demand_memory)
np.save("save/u", np.array(u))
#print(x_forecast_memory)
#print(net_demand_forecast_memory)
#print(last_x_memory)
#print(last_net_demand_memory)