-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.py
More file actions
26 lines (19 loc) · 781 Bytes
/
main.py
File metadata and controls
26 lines (19 loc) · 781 Bytes
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
import argparse
import os
from CFP import CellFormationParser, GeneralVNS, CFPSolution
def arguments() -> argparse.Namespace:
parser = argparse.ArgumentParser(description='Solving CFP with Variable Neighborhood Search metaheuristic')
parser.add_argument('problem_file', type=str, help='Problem file')
return parser.parse_args()
if __name__ == '__main__':
args = arguments()
problem = CellFormationParser(args.problem_file).parse()
print(problem)
sol = CFPSolution(problem)
print(sol)
print(sol.objective_function)
sol = GeneralVNS(problem).solve()
if not os.path.exists('results/'):
os.mkdir('results')
with open(f"results/{os.path.basename(args.problem_file).split('.')[0]}.sol", "w") as f:
f.write(str(sol))