commit | author | age
|
425bf7
|
1 |
#!/usr/bin/python3 |
JK |
2 |
|
|
3 |
import collections |
|
4 |
import functools |
|
5 |
import time |
|
6 |
|
|
7 |
from lib.ArgParser import get_config, get_model_from_config |
|
8 |
from lib.Controller import simulate, ReplayController |
|
9 |
from lib.Cost import DeviationCost, NegativeCost |
|
10 |
from lib.Env import CentralHeatingHistoryEnv |
|
11 |
|
|
12 |
# ARGS |
|
13 |
config = get_config() |
|
14 |
|
|
15 |
name_past_future = ( |
|
16 |
('past', ('temp_in', 'temp_out', 'mode'), tuple()), |
|
17 |
('fore', ('temp_in', 'temp_out', 'mode'), ('temperature', 'wind_speed', 'radiation', 'humid')), |
|
18 |
) |
|
19 |
|
|
20 |
for name, past, future in name_past_future: |
|
21 |
config['model_past_fields'] = past |
|
22 |
config['model_future_fields'] = future |
|
23 |
|
|
24 |
# MODEL |
|
25 |
start_time = time.clock() |
|
26 |
model = get_model_from_config(config) |
|
27 |
end_time = time.clock() |
|
28 |
|
|
29 |
# PLOT |
|
30 |
config['plot_fields'] = ['time', 'temp_in', 'temp_in_calc'] |
|
31 |
config['past_fields'] = ['mode'] |
|
32 |
config['past_values'] = 1 |
|
33 |
config['future_values'] = 0 |
|
34 |
|
|
35 |
# ENV |
|
36 |
env = CentralHeatingHistoryEnv() |
|
37 |
env.cost_class = DeviationCost |
|
38 |
env.model = model |
|
39 |
env.config = config |
|
40 |
env.reset() |
|
41 |
|
|
42 |
# MAIN |
|
43 |
controller = ReplayController() |
|
44 |
simulate(env, controller, render=False) |
|
45 |
|
|
46 |
print('RESULT {}_{}_{}_{}{} {} {} {}'.format(name, config['model_past_values'], config['aggregate'] or 1, config['model_type'], ('_' + str(config['model_epochs'])) if config['model_type']=='neural' else '', env.cost.costs['diff'], env.cost.costs['sq_err'], end_time - start_time)) |