Can use distance as metric

This commit is contained in:
2024-09-05 19:41:15 +02:00
parent 56f9eb1c14
commit 13b097cee3

View File

@@ -1,15 +1,15 @@
#!/usr/bin/python3
# find all routes between all pointes in positions.csv
# max 100 points
# uses time as metrice
# default by type, param -l use length
import json
import requests
import pickle
from os.path import isfile
import fast_tsp
import gpxpy
import gpxpy.gpx
import sys
class Person:
name: str
@@ -27,6 +27,13 @@ index: int = 0
persons: list[Person] = []
key: str
matrix: list[list[int]] = []
byWhat: str
if len(sys.argv) == 2 and sys.argv[1] == "-l":
byWhat = 'length'
else:
byWhat = 'duration'
with open("key.api", "r") as f:
key = f.readline()
@@ -54,7 +61,7 @@ if not isfile('data.pkl'):
mat = r.json()
matrix.append([])
for res in mat['matrix'][0]:
matrix[p.index].append(res['duration'])
matrix[p.index].append(res[byWhat])
# Serialize the object to a binary format
with open('data.pkl', 'wb') as file:
pickle.dump(matrix, file)