fixed loki + some opti changes
Some checks failed
Build and deploy the backend to staging / Build and push image (pull_request) Successful in 1m36s
Run linting on the backend code / Build (pull_request) Successful in 27s
Run testing on the backend code / Build (pull_request) Failing after 4m46s
Build and deploy the backend to staging / Deploy to staging (pull_request) Successful in 22s

This commit is contained in:
Helldragon67 2025-01-24 16:03:05 +01:00
parent 163e10032c
commit e612a82921
8 changed files with 25 additions and 14 deletions

File diff suppressed because one or more lines are too long

View File

@ -70,6 +70,7 @@ def new_trip(preferences: Preferences,
osm_type='start',
osm_id=0,
attractiveness=0,
duration=0,
must_do=True,
n_tags = 0)
@ -79,6 +80,7 @@ def new_trip(preferences: Preferences,
osm_type='end',
osm_id=0,
attractiveness=0,
duration=0,
must_do=True,
n_tags=0)

View File

@ -87,7 +87,7 @@ class Optimizer:
# inequality matrix and vector
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) :
c[i] = spot1.attractiveness
@ -489,6 +489,17 @@ class Optimizer:
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) :
"""
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_user_must(prob, x, L, landmarks) # Force to do/avoid landmarks set by user.
# return prob, self.warm_start(x, L)
return prob, x
@ -561,7 +573,7 @@ class Optimizer:
prob, x = self.pre_processing(L, landmarks, max_time, max_landmarks)
# 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]
solution = [pl.value(var) for var in x] # The values of the decision variables (will be 0 or 1)

View File

@ -1,12 +1,12 @@
city_bbox_side: 7500 #m
radius_close_to: 50
church_coeff: 0.65
nature_coeff: 1.35
church_coeff: 0.55
nature_coeff: 1.4
overall_coeff: 10
tag_exponent: 1.15
image_bonus: 1.1
viewpoint_bonus: 5
wikipedia_bonus: 1.1
wikipedia_bonus: 1.25
name_bonus: 3
N_important: 40
pay_bonus: -1

View File

@ -3,4 +3,4 @@ detour_corridor_width: 300
average_walking_speed: 4.8
max_landmarks: 10
max_landmarks_refiner: 20
overshoot: 1.1
overshoot: 0.0016

View File

@ -51,7 +51,7 @@ class Landmark(BaseModel) :
website_url : Optional[str] = None
wiki_url : Optional[str] = None
description : Optional[str] = None # TODO future
duration : Optional[int] = 0
duration : Optional[int] = 5
name_en : Optional[str] = None
# Unique ID of a given landmark

View File

@ -50,7 +50,6 @@ def test_turckheim(client, request): # pylint: disable=redefined-outer-name
# checks :
assert response.status_code == 200 # check for successful planning
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 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}"

View File

@ -294,8 +294,6 @@ class LandmarkManager:
elif value == 'cathedral' :
landmark.is_place_of_worship = False
landmark.duration = 10
else :
landmark.duration = 5
else:
self.set_landmark_score(landmark, landmarktype, preference_level)