module documentation

Solve traveling salesman problems with bound and branch

Implements a variant of the bound and branch algorithm to solve a cluster-based variant of an assymetric traveling salesman problem. This determines the optimal order of components to create the cutting path. The clusters are introduced because ordered list of points comprising a component path can be navigated either forward or backward, but not both.

Function bnb_tsp Undocumented
Function calculate_distance Undocumented
Function create_distance_matrix Create matrix of distances between nodes
Function generate_brothers Create brothers (clusters) to track which nodes represent the same component
Function plot_graph Undocumented
Function tsp_branch_and_bound_with_brothers Find solution to a clustered, assymetric traveling salesman problem with bound and branch
def bnb_tsp(matrix, nodes):

Undocumented

def calculate_distance(path, matrix):

Undocumented

def create_distance_matrix(num_nodes, brothers, nodes):

Create matrix of distances between nodes

Parameters
num_nodes:intNumber of nodes in the problem. Equal to twice the number of components
brothers:dictionaryMap of node clusters
nodes:listList of all component objects in the scene
Returns
listCost to travel between two nodes
def generate_brothers(num_nodes):

Create brothers (clusters) to track which nodes represent the same component

Parameters
num_nodes:intNumber of nodes in the problem. Equal to twice the number of components"
Returns
dictionaryMap of node clusters
def plot_graph(matrix, brothers, best_path, selected_nodes):

Undocumented

def tsp_branch_and_bound_with_brothers(matrix, brothers):

Find solution to a clustered, assymetric traveling salesman problem with bound and branch

Parameters
matrix:listMatrix of edge costs between nodes
brothers:dictionaryMaps which nodes belong to which clusters
Returns
tuple
  • best_overall_path (list): Optimal path
  • best_overall_cost (float): Cost of the path
  • best_selection: Set of nodes selected from clusters