improved tour length
This commit is contained in:
parent
797db5c1da
commit
d1c53e08bb
@ -3,3 +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.4
|
||||||
|
@ -63,6 +63,7 @@ def test(start_coords: tuple[float, float], finish_coords: tuple[float, float] =
|
|||||||
logger.info("Optimized route : ")
|
logger.info("Optimized route : ")
|
||||||
for l in linked_tour :
|
for l in linked_tour :
|
||||||
logger.info(f"{l}")
|
logger.info(f"{l}")
|
||||||
|
logger.info(f"Estimated length of tour : {linked_tour.total_time}")
|
||||||
|
|
||||||
# with open('linked_tour.yaml', 'w') as f:
|
# with open('linked_tour.yaml', 'w') as f:
|
||||||
# yaml.dump(linked_tour.asdict(), f)
|
# yaml.dump(linked_tour.asdict(), f)
|
||||||
|
@ -21,6 +21,7 @@ class Optimizer:
|
|||||||
detour_factor: float # detour factor of straight line vs real distance in cities
|
detour_factor: float # detour factor of straight line vs real distance in cities
|
||||||
average_walking_speed: float # average walking speed of adult
|
average_walking_speed: float # average walking speed of adult
|
||||||
max_landmarks: int # max number of landmarks to visit
|
max_landmarks: int # max number of landmarks to visit
|
||||||
|
overshoot: float # overshoot to allow maxtime to overflow. Optimizer is a bit restrictive
|
||||||
|
|
||||||
|
|
||||||
def __init__(self) :
|
def __init__(self) :
|
||||||
@ -31,6 +32,7 @@ class Optimizer:
|
|||||||
self.detour_factor = parameters['detour_factor']
|
self.detour_factor = parameters['detour_factor']
|
||||||
self.average_walking_speed = parameters['average_walking_speed']
|
self.average_walking_speed = parameters['average_walking_speed']
|
||||||
self.max_landmarks = parameters['max_landmarks']
|
self.max_landmarks = parameters['max_landmarks']
|
||||||
|
self.overshoot = parameters['overshoot']
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -167,7 +169,7 @@ class Optimizer:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
def init_ub_dist(self, landmarks: list[Landmark], max_steps: int):
|
def init_ub_dist(self, landmarks: list[Landmark], max_time: int):
|
||||||
"""
|
"""
|
||||||
Initialize the objective function coefficients and inequality constraints for the optimization problem.
|
Initialize the objective function coefficients and inequality constraints for the optimization problem.
|
||||||
|
|
||||||
@ -176,7 +178,7 @@ class Optimizer:
|
|||||||
|
|
||||||
Args:
|
Args:
|
||||||
landmarks (list[Landmark]): List of landmarks.
|
landmarks (list[Landmark]): List of landmarks.
|
||||||
max_steps (int): Maximum number of steps allowed.
|
max_time (int): Maximum time of visit allowed.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Tuple[list[float], list[float], list[int]]: Objective function coefficients, inequality constraint coefficients, and the right-hand side of the inequality constraint.
|
Tuple[list[float], list[float], list[int]]: Objective function coefficients, inequality constraint coefficients, and the right-hand side of the inequality constraint.
|
||||||
@ -200,7 +202,7 @@ class Optimizer:
|
|||||||
A_ub += dist_table
|
A_ub += dist_table
|
||||||
c = c*len(landmarks)
|
c = c*len(landmarks)
|
||||||
|
|
||||||
return c, A_ub, [max_steps]
|
return c, A_ub, [max_time*self.overshoot]
|
||||||
|
|
||||||
|
|
||||||
def respect_number(self, L, max_landmarks: int):
|
def respect_number(self, L, max_landmarks: int):
|
||||||
@ -474,7 +476,7 @@ class Optimizer:
|
|||||||
A, b = self.respect_start_finish(L) # Force start and finish positions
|
A, b = self.respect_start_finish(L) # Force start and finish positions
|
||||||
A_eq = np.vstack((A_eq, A), dtype=np.int8)
|
A_eq = np.vstack((A_eq, A), dtype=np.int8)
|
||||||
b_eq += b
|
b_eq += b
|
||||||
A, b = self.respect_order(L) # Respect order of visit (only works when max_steps is limiting factor)
|
A, b = self.respect_order(L) # Respect order of visit (only works when max_time is limiting factor)
|
||||||
A_eq = np.vstack((A_eq, A), dtype=np.int8)
|
A_eq = np.vstack((A_eq, A), dtype=np.int8)
|
||||||
b_eq += b
|
b_eq += b
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user