Can use distance as metric
This commit is contained in:
@@ -1,15 +1,15 @@
|
|||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
# find all routes between all pointes in positions.csv
|
# find all routes between all pointes in positions.csv
|
||||||
# max 100 points
|
# max 100 points
|
||||||
# uses time as metrice
|
# default by type, param -l use length
|
||||||
|
|
||||||
import json
|
|
||||||
import requests
|
import requests
|
||||||
import pickle
|
import pickle
|
||||||
from os.path import isfile
|
from os.path import isfile
|
||||||
import fast_tsp
|
import fast_tsp
|
||||||
import gpxpy
|
import gpxpy
|
||||||
import gpxpy.gpx
|
import gpxpy.gpx
|
||||||
|
import sys
|
||||||
|
|
||||||
class Person:
|
class Person:
|
||||||
name: str
|
name: str
|
||||||
@@ -27,6 +27,13 @@ index: int = 0
|
|||||||
persons: list[Person] = []
|
persons: list[Person] = []
|
||||||
key: str
|
key: str
|
||||||
matrix: list[list[int]] = []
|
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:
|
with open("key.api", "r") as f:
|
||||||
key = f.readline()
|
key = f.readline()
|
||||||
@@ -54,7 +61,7 @@ if not isfile('data.pkl'):
|
|||||||
mat = r.json()
|
mat = r.json()
|
||||||
matrix.append([])
|
matrix.append([])
|
||||||
for res in mat['matrix'][0]:
|
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
|
# Serialize the object to a binary format
|
||||||
with open('data.pkl', 'wb') as file:
|
with open('data.pkl', 'wb') as file:
|
||||||
pickle.dump(matrix, file)
|
pickle.dump(matrix, file)
|
||||||
|
|||||||
Reference in New Issue
Block a user