; function to provide inut-output - reads the file ; data from the fine cities.dat ; global variables are start with * ; function tsp takes as an argument the list and solves the TSP problem (defun skel1 () (let (data_file sym_list) (setq data_file (open "cities.dat" :direction :input)) (setq *print_max* 30) (loop (if (null (setq sym_list (read data_file nil nil ))) (return)) (solve_tsp sym_list) ) (close data_file) '****Finished**** ) ) ; Here is a dummy version of tsp fuction which you will be required ; to modify (defun solve_tsp (sym_list) (setq *city_max* (length sym_list)) (format t "~%Generating tours for following ~D cities: ~%" *city_max*) (dolist (item sym_list) (format t " ~A~%" item) ) (setq *tour_cnt* 0) (permute sym_list '()) (format t "~% Tour count: ~D~%~%" *tour_cnt*) ) ; Function permute is invoked with two arguments ; unused symbols and partial permutation (which is at the beginning null) ; the unused symbols are added to the front of the patial permutation list ; creating a child node, and permute is called recursively do generate ; the grand children etc. (defun permute (unused perm) (let () (cond ((null unused) (cond ( (< *tour_cnt* *print_max*) (print perm) ) ( (= *tour_cnt* *print_max*) (format t "~% supressing printing ...") ) ) (setq *tour_cnt* (+ *tour_cnt* 1)) ) (t (dolist (item unused) (permute (remove item unused) (cons item perm)) )) ) ) )