Trip Planner

class components.trip_planner.TripPlanner

The TripPlanner object contains functions used for Trip Planner tab

Methods

add_new_point_on_table(lat, lon, landmark, data)

Adds new entry into landmark table

best_route_gurobi(distance_matrix)

Calculates best route using gurobi optimiser

best_route_nearest_insertion(distance_matrix)

Calculates best route using nearest insertion heuristic

best_route_nearest_neighbour(distance_matrix)

Calculates best route using nearest neighbour heuristic

get_distance_and_duration_from_table(data)

Get distance and duration matrix from landmark table, calls Google API

get_distance_from_routes(routes, distance_matrix)

Calculates distance from existing routes tuple list

get_map_from_table(data, children)

Adds landmark location pin on map from landmark table

get_permutation_of_routes(routes_list, landmark)

Get permutation of routes with existing routes list and new landmark

get_routes_from_list(routes_list)

Get tuple of routes from existing routes list

get_street_name(lat, lon)

Get street name from latitude and longitude information, calls Google API

get_style_table(data)

Return style of landmark table

optimiser_pipeline(data)

Pipeline to run optimization algorithm

remove_last_point_on_table(data)

Removes last entry from landmark table

add_new_point_on_table(lat, lon, landmark, data)

Adds new entry into landmark table

Parameters
  • lat (float) – latitude information

  • lon (float) – longitude information

  • landmark (str) – name of landmark, could be None or empty string

  • data (list) – data of landmark table

Returns

(list)

static best_route_gurobi(distance_matrix)

Calculates best route using gurobi optimiser

Parameters

distance_matrix (np.ndarray) – inter-distance between locations

Returns

contains tuple of routes

Return type

(list)

best_route_nearest_insertion(distance_matrix)

Calculates best route using nearest insertion heuristic

Parameters

distance_matrix (np.ndarray) – inter-distance between locations

Returns

contains tuple of routes

Return type

(list)

static best_route_nearest_neighbour(distance_matrix)

Calculates best route using nearest neighbour heuristic

Parameters

distance_matrix (np.ndarray) – inter-distance between locations

Returns

contains tuple of routes

Return type

(list)

get_distance_and_duration_from_table(data)

Get distance and duration matrix from landmark table, calls Google API

Parameters

data (list) – data of landmark table

Returns

2-element tuple

  • (np.ndarray): distance matrix

  • (np.ndarray): duration matrix

static get_distance_from_routes(routes, distance_matrix)

Calculates distance from existing routes tuple list

Parameters
  • routes (list) – list of tuple of existing routes

  • distance_matrix (np.ndarray) – inter-distance between locations

Returns

(float)

static get_map_from_table(data, children)

Adds landmark location pin on map from landmark table

Parameters
  • data (list) – data of landmark table

  • children (list) – current map children

Returns

updated map children

Return type

(list)

static get_permutation_of_routes(routes_list, landmark)

Get permutation of routes with existing routes list and new landmark

Parameters
  • routes_list (list) – existing routes

  • landmark (int) – new landmark to visit

Returns

list of list

Return type

(list)

static get_routes_from_list(routes_list)

Get tuple of routes from existing routes list

Parameters

routes_list (list) – existing routes

Returns

list of tuple

get_street_name(lat, lon)

Get street name from latitude and longitude information, calls Google API

Return default string if street name is not found

Parameters
  • lat (float) – latitude information

  • lon (float) – longitude information

Returns

(str)

static get_style_table(data)

Return style of landmark table

Parameters

data (list) – data of landmark table

Returns

(dict)

optimiser_pipeline(data)

Pipeline to run optimization algorithm

Parameters

data (list) – data of landmark table

Returns

(str/list)

static remove_last_point_on_table(data)

Removes last entry from landmark table

Parameters

data (list) – data of landmark table

Returns

(list)