#*****************************************************************************80 # ## tsp_dantzig42_test() tests tsp_dantzig42(). # # Licensing: # # This code is distributed under the MIT license. # # Modified: # # 17 July 2026 # # Author: # # John Burkardt # cat ( date ( ), "\n" ) cat ( "\n" ) cat ( "tsp_dantzig42_test():\n" ) cat ( " ", version$version.string, "\n" ) cat ( " tsp_dantzig42() returns the Dantzig 42 state TSP challenge.\n" ) source ( "/home/john/public_html/r_src/tsp_dantzig42/tsp_dantzig42_order.R" ) source ( "/home/john/public_html/r_src/tsp_dantzig42/tsp_dantzig42_xy.R" ) source ( "/home/john/public_html/r_src/tsp_display/tsp_display.R" ) source ( "/home/john/public_html/r_src/vecnorm/vecnorm.R" ) n <- 42 order <- tsp_dantzig42_order ( ) xy <- tsp_dantzig42_xy ( ) cat ( "\n" ) cat ( " City coordinates:\n" ) cat ( "\n" ) xy cat ( "\n" ) cat ( " Optimal ordering:\n" ) cat ( "\n" ) order # # Print cost of round trip. # cost <- 0.0 from <- order[n] for ( i in 1 : n ) { to <- order[i] cost <- cost + vecnorm ( xy[to,] - xy[from,] ) from <- to } cat ( "\n" ) cat ( " Cost of round trip", cost, "\n" ) # # Make a copy of the data in the optimal order. # xy2 <- xy for ( i in 1 : n ) { xy2[i,1] = xy[order[i],1] xy2[i,2] = xy[order[i],2] } # # Plot the data. # prefix <- "tsp_dantzig42" tsp_display ( prefix, n, xy2 ) # # Terminate. # cat ( "\n" ) cat ( "tsp_dantzig42_test():\n" ) cat ( " Normal end of execution.\n" ) cat ( date ( ), "\n" ) quit ( )