-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.py
73 lines (51 loc) · 2.34 KB
/
app.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
from util import reader_util, writer_util, data_util, config
from services import data_generator, solve
import data
import pprint, logging
if __name__ == '__main__':
data.init()
# Import engine subtypes
reader_util.import_engine_subtypes()
# Import removal information
data.removals_info, data.aos_cost = reader_util.import_removal_info(
filepath='data_to_read/removal_info.csv',
removals_data_storage=data.removals_info,
aos_cost_data_storage=data.aos_cost)
if config.first_run:
logging.info("FIRST_RUN is set to TRUE. All possible states and actions are going to be generated. This may take awhile.")
data_generator.generate_all_possible_states()
data_generator.generate_all_possible_actions()
for engine_subtype in data.engine_subtypes:
data.need_to_update_removal_info[engine_subtype] = True
logging.info("All files needed for future runs have been created. Please set FIRST_RUN to FALSE for any future runs on this machine.")
else:
# Import engine information
data.engines_info = reader_util.import_engine_info(
filepath='data_to_read/engine_info.csv',
data_storage=data.engines_info)
data_util.validate_removal_and_engine_info()
# Import engine subtype data
reader_util.import_engine_subtype_data()
data_util.validate_engine_subtype_data()
# Generate all possible removal situations if removal info has been updated
for engine_subtype in data.engine_subtypes:
if data.need_to_update_removal_info[engine_subtype]:
data_generator.generate_all_possible_removal_situations(
engine_subtype=engine_subtype)
# Import all possible states
data.all_possible_states = reader_util.import_all_possible_states(
filepath='data_to_read/all_possible_states.csv',
data_storage=data.all_possible_states)
# Import all possible actions
data.all_possible_actions = reader_util.import_all_possible_actions(
data_storage=data.all_possible_actions)
data_util.minimize_states_and_actions_to_iterate()
# Import all possible removal situations
data.all_possible_removal_situations = reader_util.import_all_possible_removal_situations(
data_storage=data.all_possible_removal_situations)
# Import future data for regression
reader_util.import_future_data()
# Solve Finite Horizon MDP
for engine_subtype in data.engine_subtypes:
solver = solve.FiniteHorizonMDPSolver(engine_subtype)
solver.solve_MDP()