Solve, time, and profile programs solving the traveling salesperson problem in various languages. Solution relies on use of graph object.

avg_calcs.sh 459B

12345678910111213141516171819
  1. #!/bin/sh
  2. #
  3. # Extract the total calculation time from the output file.
  4. # Perform an averaging procedure on all numbers.
  5. # Report the result back.
  6. for f in `/bin/ls -1 avgtimeout_tsp*`
  7. do
  8. touch tmpfile
  9. cat /dev/null > tmpfile
  10. export N="`echo $f | sed 's/^.*_\([0-9]\{1,\}\).out/\1/'`"
  11. cat $f | grep "Elapsed" | cut -d" " -f3 >> tmpfile
  12. export AVG="`python calc_avg.py tmpfile`"
  13. echo "Average time : ${N}-node TSP problem : ${AVG}"
  14. rm tmpfile
  15. done