upgraded optimizer
This commit is contained in:
@@ -7,8 +7,7 @@ from landmarks_manager import generate_landmarks
|
||||
from fastapi.encoders import jsonable_encoder
|
||||
|
||||
from optimizer_v4 import solve_optimization
|
||||
from optimizer_v2 import generate_path
|
||||
from refiner import refine_optimization, refine_path
|
||||
from refiner import refine_optimization
|
||||
from structs.landmarks import Landmark
|
||||
from structs.landmarktype import LandmarkType
|
||||
from structs.preferences import Preferences, Preference
|
||||
@@ -81,7 +80,7 @@ def test4(coordinates: tuple[float, float]) -> List[Landmark]:
|
||||
shopping=Preference(
|
||||
name='shopping',
|
||||
type=LandmarkType(landmark_type='shopping'),
|
||||
score = 5))
|
||||
score = 0))
|
||||
|
||||
|
||||
# Create start and finish
|
||||
@@ -97,37 +96,20 @@ def test4(coordinates: tuple[float, float]) -> List[Landmark]:
|
||||
#write_data(landmarks, "landmarks_Lyon.txt")
|
||||
|
||||
# Insert start and finish to the landmarks list
|
||||
#landmarks_short = landmarks_short[:4]
|
||||
landmarks_short.insert(0, start)
|
||||
landmarks_short.append(finish)
|
||||
|
||||
# TODO use these parameters in another way
|
||||
with open (os.path.dirname(os.path.abspath(__file__)) + '/parameters/optimizer.params', "r") as f :
|
||||
parameters = json.loads(f.read())
|
||||
max_landmarks = parameters['max landmarks']
|
||||
max_walking_time = 120 # minutes
|
||||
detour = 10 # minutes
|
||||
|
||||
detour = 30 # minutes
|
||||
|
||||
# First stage optimization
|
||||
base_tour = solve_optimization(landmarks_short, max_walking_time, True)
|
||||
|
||||
|
||||
#base_tour = solve_optimization(landmarks_short, max_walking_time, True)
|
||||
|
||||
# First stage using NetworkX
|
||||
#base_tour = generate_path(landmarks_short, max_walking_time, max_landmarks)
|
||||
|
||||
# Second stage using linear optimization
|
||||
if detour != 0 :
|
||||
if detour != 0 or len(base_tour) <= 4:
|
||||
refined_tour = refine_optimization(landmarks, base_tour, max_walking_time+detour, True)
|
||||
|
||||
# Second stage using NetworkX
|
||||
#refined_tour = refine_path(landmarks, base_tour, max_walking_time+detour, True)
|
||||
|
||||
# Use NetworkX again to correct to shortest path
|
||||
#refined_tour = refine_path(landmarks, base_tour, max_walking_time+detour, True)
|
||||
|
||||
return refined_tour
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user