Heating controller with neural thermal model written in Python
Jacek Kowalski
2018-06-24 66a9fb40efe1311b34a3cee3f83f10c6990759af
commit | author | age
425bf7 1 #!/usr/bin/python3
JK 2
3 import collections
4 import functools
5
6 from lib.ArgParser import get_config, get_model_from_config
7 from lib.Controller import simulate, ReplayController
8 from lib.Cost import DeviationCost, NegativeCost
9 from lib.Env import CentralHeatingHistoryEnv
10
11 # ARGS
12 config = get_config()
13 config['model_past_fields'] = ['temp_in', 'temp_out', 'mode']
14 config['model_future_fields'] = ['temperature', 'wind_speed', 'radiation', 'humid']
15
16 plot = collections.OrderedDict()
17
18 for model_type in ('neural', 'linear'):
19     config['model_type'] = model_type
20
21     # MODEL
22     model = get_model_from_config(config)
23     print(repr(model.model))
24
25     # PLOT
26     config['plot_fields'] = ['time', 'temp_in', 'temp_in_calc']
27     config['past_fields'] = ['mode']
28     config['past_values'] = 1
29     config['future_values'] = 0
30
31     # ENV
32     env = CentralHeatingHistoryEnv()
33     env.cost_class = DeviationCost
34     #env.cost_class = functools.partial(NegativeCost, 19.5, 22)
35     env.model = model
36     env.config = config
37     env.reset()
38
39     # MAIN
40     controller = ReplayController()
41     simulate(env, controller, render=False)
42
43     plot['time'] = env.window.plot['time']
44     plot['temp_in'] = env.window.plot['temp_in']
45     plot['temp_in_' + model_type] = env.window.plot['temp_in_calc']
46
47 print(plot.keys())
48 env.window.plot = plot
49
50 env.render()