fix loki #54
File diff suppressed because one or more lines are too long
@ -70,6 +70,7 @@ def new_trip(preferences: Preferences,
|
|||||||
osm_type='start',
|
osm_type='start',
|
||||||
osm_id=0,
|
osm_id=0,
|
||||||
attractiveness=0,
|
attractiveness=0,
|
||||||
|
duration=0,
|
||||||
must_do=True,
|
must_do=True,
|
||||||
n_tags = 0)
|
n_tags = 0)
|
||||||
|
|
||||||
@ -79,6 +80,7 @@ def new_trip(preferences: Preferences,
|
|||||||
osm_type='end',
|
osm_type='end',
|
||||||
osm_id=0,
|
osm_id=0,
|
||||||
attractiveness=0,
|
attractiveness=0,
|
||||||
|
duration=0,
|
||||||
must_do=True,
|
must_do=True,
|
||||||
n_tags=0)
|
n_tags=0)
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ class Optimizer:
|
|||||||
|
|
||||||
# inequality matrix and vector
|
# inequality matrix and vector
|
||||||
A_ub = np.zeros(L*L, dtype=np.int16)
|
A_ub = np.zeros(L*L, dtype=np.int16)
|
||||||
b_ub = round(max_time*self.overshoot)
|
b_ub = round(max_time*(1.1+max_time*self.overshoot))
|
||||||
|
|
||||||
for i, spot1 in enumerate(landmarks) :
|
for i, spot1 in enumerate(landmarks) :
|
||||||
c[i] = spot1.attractiveness
|
c[i] = spot1.attractiveness
|
||||||
@ -489,6 +489,17 @@ class Optimizer:
|
|||||||
return L
|
return L
|
||||||
|
|
||||||
|
|
||||||
|
def warm_start(self, x: list[pl.LpVariable], L: int) :
|
||||||
|
|
||||||
|
for i in range(L*L) :
|
||||||
|
x[i].setInitialValue(0)
|
||||||
|
|
||||||
|
x[1].setInitialValue(1)
|
||||||
|
x[2*L-1].setInitialValue(1)
|
||||||
|
|
||||||
|
return x
|
||||||
|
|
||||||
|
|
||||||
def pre_processing(self, L: int, landmarks: list[Landmark], max_time: int, max_landmarks: int | None) :
|
def pre_processing(self, L: int, landmarks: list[Landmark], max_time: int, max_landmarks: int | None) :
|
||||||
"""
|
"""
|
||||||
Preprocesses the optimization problem by setting up constraints and variables for the tour optimization.
|
Preprocesses the optimization problem by setting up constraints and variables for the tour optimization.
|
||||||
@ -539,6 +550,7 @@ class Optimizer:
|
|||||||
self.respect_order(prob, x, L) # Respect order of visit (only works when max_time is limiting factor)
|
self.respect_order(prob, x, L) # Respect order of visit (only works when max_time is limiting factor)
|
||||||
self.respect_user_must(prob, x, L, landmarks) # Force to do/avoid landmarks set by user.
|
self.respect_user_must(prob, x, L, landmarks) # Force to do/avoid landmarks set by user.
|
||||||
|
|
||||||
|
# return prob, self.warm_start(x, L)
|
||||||
return prob, x
|
return prob, x
|
||||||
|
|
||||||
|
|
||||||
@ -561,7 +573,7 @@ class Optimizer:
|
|||||||
prob, x = self.pre_processing(L, landmarks, max_time, max_landmarks)
|
prob, x = self.pre_processing(L, landmarks, max_time, max_landmarks)
|
||||||
|
|
||||||
# Solve the problem and extract results.
|
# Solve the problem and extract results.
|
||||||
prob.solve(pl.PULP_CBC_CMD(msg=False, gapRel=0.1))
|
prob.solve(pl.PULP_CBC_CMD(msg=False, gapRel=0.1, timeLimit=10, warmStart=False))
|
||||||
status = pl.LpStatus[prob.status]
|
status = pl.LpStatus[prob.status]
|
||||||
solution = [pl.value(var) for var in x] # The values of the decision variables (will be 0 or 1)
|
solution = [pl.value(var) for var in x] # The values of the decision variables (will be 0 or 1)
|
||||||
|
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
city_bbox_side: 7500 #m
|
city_bbox_side: 7500 #m
|
||||||
radius_close_to: 50
|
radius_close_to: 50
|
||||||
church_coeff: 0.65
|
church_coeff: 0.55
|
||||||
nature_coeff: 1.35
|
nature_coeff: 1.4
|
||||||
overall_coeff: 10
|
overall_coeff: 10
|
||||||
tag_exponent: 1.15
|
tag_exponent: 1.15
|
||||||
image_bonus: 1.1
|
image_bonus: 1.1
|
||||||
viewpoint_bonus: 5
|
viewpoint_bonus: 5
|
||||||
wikipedia_bonus: 1.1
|
wikipedia_bonus: 1.25
|
||||||
name_bonus: 3
|
name_bonus: 3
|
||||||
N_important: 40
|
N_important: 40
|
||||||
pay_bonus: -1
|
pay_bonus: -1
|
||||||
|
@ -3,4 +3,4 @@ detour_corridor_width: 300
|
|||||||
average_walking_speed: 4.8
|
average_walking_speed: 4.8
|
||||||
max_landmarks: 10
|
max_landmarks: 10
|
||||||
max_landmarks_refiner: 20
|
max_landmarks_refiner: 20
|
||||||
overshoot: 1.1
|
overshoot: 0.0016
|
||||||
|
@ -51,7 +51,7 @@ class Landmark(BaseModel) :
|
|||||||
website_url : Optional[str] = None
|
website_url : Optional[str] = None
|
||||||
wiki_url : Optional[str] = None
|
wiki_url : Optional[str] = None
|
||||||
description : Optional[str] = None # TODO future
|
description : Optional[str] = None # TODO future
|
||||||
duration : Optional[int] = 0
|
duration : Optional[int] = 5
|
||||||
name_en : Optional[str] = None
|
name_en : Optional[str] = None
|
||||||
|
|
||||||
# Unique ID of a given landmark
|
# Unique ID of a given landmark
|
||||||
|
@ -50,7 +50,6 @@ def test_turckheim(client, request): # pylint: disable=redefined-outer-name
|
|||||||
# checks :
|
# checks :
|
||||||
assert response.status_code == 200 # check for successful planning
|
assert response.status_code == 200 # check for successful planning
|
||||||
assert isinstance(landmarks, list) # check that the return type is a list
|
assert isinstance(landmarks, list) # check that the return type is a list
|
||||||
assert duration_minutes*0.8 < int(result['total_time']) < duration_minutes*1.2, f"Trip duration not within 20\% of desired length"
|
|
||||||
assert len(landmarks) > 2 # check that there is something to visit
|
assert len(landmarks) > 2 # check that there is something to visit
|
||||||
assert duration_minutes*0.8 < result['total_time'], f"Trip too short: {result['total_time']} instead of {duration_minutes}"
|
assert duration_minutes*0.8 < result['total_time'], f"Trip too short: {result['total_time']} instead of {duration_minutes}"
|
||||||
assert duration_minutes*1.2 > result['total_time'], f"Trip too long: {result['total_time']} instead of {duration_minutes}"
|
assert duration_minutes*1.2 > result['total_time'], f"Trip too long: {result['total_time']} instead of {duration_minutes}"
|
||||||
|
@ -294,8 +294,6 @@ class LandmarkManager:
|
|||||||
elif value == 'cathedral' :
|
elif value == 'cathedral' :
|
||||||
landmark.is_place_of_worship = False
|
landmark.is_place_of_worship = False
|
||||||
landmark.duration = 10
|
landmark.duration = 10
|
||||||
else :
|
|
||||||
landmark.duration = 5
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
self.set_landmark_score(landmark, landmarktype, preference_level)
|
self.set_landmark_score(landmark, landmarktype, preference_level)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user