-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
33 lines (26 loc) · 859 Bytes
/
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
if __name__ == '__main__':
import importlib
import argparse
parser = argparse.ArgumentParser()
# need to be
parser.add_argument("input", help="input file")
parser.add_argument("--output", help="output file")
parser.add_argument("--solver", type=str, default="example")
args = parser.parse_args()
solver = None
# try load the given solver
try:
solver = importlib.import_module('.'.join(["solver", args.solver]))
except ImportError as e:
parser.print_help()
print(e)
exit(1)
# solver init with filepath
solver = solver.Solver(args.input)
# solve the problem with given input
success = solver.solve()
if not success:
raise RuntimeError("No solution found!")
# maybe create a solution file
if args.output:
solver.write(args.output)