This repository has been archived on 2021-10-31. You can view files and clone it, but cannot push or open issues or pull requests.
AICup/src/utils.py

15 lines
400 B
Python
Raw Normal View History

2020-09-25 09:15:15 +00:00
def compute_length(solution, dist_matrix):
2019-11-10 09:42:13 +00:00
total_length = 0
starting_node = solution[0]
from_node = starting_node
for node in solution[1:]:
total_length += dist_matrix[from_node, node]
from_node = node
return total_length
2020-09-25 09:15:15 +00:00
def distance_euc(zi, zj):
xi, xj = zi[0], zj[0]
yi, yj = zi[1], zj[1]
return round(np.sqrt((xi - xj) ** 2 + (yi - yj) ** 2), 0)