#*****************************************************************************80 # ## tsp_anneal_test() tests tsp_anneal(). # # Licensing: # # Copyright 2016 James P. Howard, II # # The computer code and data files on this web page are distributed under # https://opensource.org/licenses/BSD-2-Clause, the BSD-2-Clause license. # # Modified: # # 04 June 2026 # # Author: # # John Burkardt # cat ( date ( ), "\n" ) cat ( "\n" ) cat ( "tsp_anneal_test():\n" ) cat ( " ", version$version.string, "\n" ) cat ( " tsp_anneal() solves a traveling salesperson problem (TSP) using simulated annealing.\n" ) source ( "/home/john/public_html/r_src/tsp_anneal/tsp_anneal.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" ) xy <- tsp_dantzig42_xy ( ) n <- 42 temp_vec = c ( 1.0, 10.0, 100.0, 1000.0, 10000.0, 100000.0 ) for ( temp in temp_vec ) { value <- tsp_anneal ( xy, temp ) order <- value$order cost <- value$distance cat ( "\n" ) cat ( " temp:\n" ) print ( temp ) cat ( " Ordering:\n" ); print ( order ) cat ( " Length of round trip:\n" ); print ( cost ) } # # Make a copy of the data in the optimal order. # xy2 <- xy order <- value$order for ( i in 1 : n ) { xy2[i,1] = xy[order[i],1] xy2[i,2] = xy[order[i],2] } # # Plot the data. # prefix <- "tsp_anneal" tsp_display ( prefix, n, xy2 ) # # Terminate. # cat ( "\n" ) cat ( "tsp_anneal_test():\n" ) cat ( " Normal end of execution.\n" ) cat ( date ( ), "\n" ) quit ( )