-
Notifications
You must be signed in to change notification settings - Fork 0
/
parameter.py
35 lines (30 loc) · 975 Bytes
/
parameter.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
from typing import List
def read_map(file_path:str) -> List[List[float]]:
"""
Read all point coordianates from data file
:param file_path: path to tsp file
"""
with open(file_path, "r") as file:
cities = []
city_flag = False
for line in file:
if line.strip() == "NODE_COORD_SECTION":
city_flag = True
continue
if line.strip() == "EOF":
return cities
if city_flag:
city_coor = [float(i) for i in line.strip().split()[1:]]
cities.append(city_coor)
PATH_TO_MAP = "./Benchmark/eil51.tsp"
TOWNS = read_map(PATH_TO_MAP)
# Parameter for SOS
PARAMETER_SPACE = (1, 5)
POP_SIZE = 10 # The number of candidate solutions
DIM = 2 # number of problem variables [α, β]
# Parameter for ACO
ANTS = 10
EVAPORATION_RATE = 0.1
INTENSIFICATION = 1000
MAX_ITER_ACO = 200 # The number of iterations
BETA_EVAPORATION_RATE = 0.05