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
| #!/usr/bin/python3
|
| import collections
| import functools
| import time
|
| from lib.ArgParser import get_config, get_model_from_config
| from lib.Controller import simulate, ReplayController
| from lib.Cost import DeviationCost, NegativeCost
| from lib.Env import CentralHeatingHistoryEnv
|
| # ARGS
| config = get_config()
|
| name_past_future = (
| ('past', ('temp_in', 'temp_out', 'mode'), tuple()),
| ('flow', ('temp_in', 'temp_out', 'mode', 'temp_flow', 'temp_return'), tuple()),
| ('fore', ('temp_in', 'temp_out', 'mode'), ('temperature', 'wind_speed', 'radiation', 'humid')),
| ('all', ('temp_in', 'temp_out', 'mode', 'temp_flow', 'temp_return'), ('temperature', 'wind_speed', 'radiation', 'humid')),
| )
|
| for name, past, future in name_past_future:
| config['model_past_fields'] = past
| config['model_future_fields'] = future
|
| # MODEL
| start_time = time.clock()
| model = get_model_from_config(config)
| end_time = time.clock()
|
| # PLOT
| config['plot_fields'] = ['time', 'temp_in', 'temp_in_calc']
| config['past_fields'] = ['mode']
| config['past_values'] = 1
| config['future_values'] = 0
|
| # ENV
| env = CentralHeatingHistoryEnv()
| env.cost_class = DeviationCost
| #env.cost_class = functools.partial(NegativeCost, 19.5, 22)
| env.model = model
| env.config = config
| env.reset()
|
| # MAIN
| controller = ReplayController()
| simulate(env, controller, render=False)
|
| print('RESULT {}_{}_{}{} {} {} {}'.format(name, 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))
|
|