-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
55 lines (49 loc) · 1.96 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
47
48
49
50
51
52
53
54
55
from internals.solver import solveInstance
from internals.general_utils import *
import pandas as pd
import warnings
import logging
import sys
import os
columns=["name", "cluster_type", "nvar","nconstraints","optimal_sol","sol","sol_is_integer","status","ncuts","elapsed_time","gap","relative_gap","iterations"]
logging.basicConfig(filename='resolution.log', format='%(asctime)s - %(message)s',level=logging.INFO, datefmt='%d-%b-%y %H:%M:%S')
warnings.filterwarnings("ignore", category=DeprecationWarning)
warnings.filterwarnings('ignore')
if __name__ == '__main__':
# Flush Log
flushLog("resolution.log")
# Statistics variables in DataFrame
stats = pd.DataFrame(columns=columns)
# Read the configuration file
config = ConfigParser()
config.read('config.ini')
if len(sys.argv) == 2:
if not sys.argv[1]=="-all":
invalidInput()
else:
print("Generating istances ....")
for cluster in config.sections():
generateIstances(cluster)
print("Solving cluster '",cluster,"'...")
for instance in os.listdir("instances/"+cluster+"/") :
stats=solveInstance(instance,cluster,stats)
print("...Done.")
elif len(sys.argv) == 3:
execution_type = sys.argv[1]
if execution_type == "-c":
cluster=sys.argv[2]
print("Generating istances ....")
generateIstances(cluster)
print("...Done.")
print("Solving cluster '",cluster,"'...")
for instance in os.listdir("instances/"+cluster+"/") :
stats=solveInstance(instance,cluster,stats)
print("...Done.")
elif execution_type == "-s":
stats=solveInstance(sys.argv[2].split("/")[2],sys.argv[2].split("/")[1],stats)
print("...Done.")
else:
invalidInput()
else:
invalidInput()
stats.to_excel("stats.xlsx")