-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
47 lines (36 loc) · 1.55 KB
/
main.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
from heuristics_manager import HeuristicsManager
import logging
from utilities import logger as lg
from utilities.visualisation import Visualisation
import os
from datetime import datetime
class HeuristicOptimizerPlatform:
"""
Heuristic Optimizer Platform
"""
def __init__(self):
self.results_path = 'results/hoprun_' + datetime.now().strftime("%Y%m%d-%H%M%S")
self.create_results_folder()
self.set_log_file()
lg.msg(logging.INFO, 'Heuristic Optimizer Platform (HOP) starting...')
self.hm = HeuristicsManager(results_path=self.results_path)
self.vis = Visualisation()
self.optimize()
lg.msg(logging.INFO, 'Heuristic Optimizer Platform (HOP) completed')
def create_results_folder(self):
try:
os.mkdir(self.results_path)
except OSError:
print('Creation of results directory {} failed'.format(self.results_path))
else:
print('Successfully created results directory {}'.format(self.results_path))
def set_log_file(self):
log_filename = str(self.results_path + '/' + 'hoplog_' + datetime.now().strftime("%Y%m%d-%H%M%S") + '.txt')
logging.basicConfig(filename=log_filename, level=logging.INFO,
format='[%(asctime)s] [%(levelname)8s] %(message)s')
# Disable matplotlib font manager logger
logging.getLogger('matplotlib.font_manager').disabled = True
def optimize(self):
self.hm.execute_jobs()
if __name__ == "__main__":
hop = HeuristicOptimizerPlatform()