Essay On The Travelling Salesperson Problem

834 Words2 Pages

1. Introduction This report illustrates the results and discussion of the Travelling Salesperson Problem (TSP). The travelling Salesperson travels from University Of Pretoria (UP) and has to travel to four possible locations using the shortest path. BFS and DFS will be used and compared according to efficiency of each for the Salesperson to reach his goal in the most optimal manner. The goal-state allows the Salesperson to visit all of the locations below and return to UP with the most optimal path. The following locations have to be visited: • University of Pretoria (Start) • CSIR, Meiring Naude Road, Pretoria • Armscor, Delmas Road, Pretoria • Denel Dynamics, Nelmaphius Drive, Centurion • Air Force Base Waterkloof, Centurion A tree structure …show more content…

UP_Armscor = gmaps.distance_matrix( "University of Pretoria, Pretoria", "Armscor, Delmas Road, Pretoria") UP_Airforce = gmaps.distance_matrix( "University of Pretoria, Pretoria", " Air Force Base Waterkloof, Centurion") UP_Denel = gmaps.distance_matrix( "University of Pretoria, Pretoria", " Denel Dynamics, Nellmapius Drive, Centurion") import string class Tree: def __init__ ( self, par, val=None ): self.par = par self.val = val self.children = [] if par is None: self.bO = 0 else: self.bO = len(par.children) par.children.append ( self ) def nChildren ( self ): return len(self.children) def nthChild ( self, n ): return self.children[n] def fullPath ( self ): result = [] par = self.par kid = self while par: result.insert ( 0, kid.bO ) par, kid = par.par, par return result def nId ( self ): fullPath = self.fullPath() return nId ( fullPath ) class nId: def __init__ ( self, path ): self.path = path def __str__ ( self ): L = map ( str, self.path

More about Essay On The Travelling Salesperson Problem

Open Document