Question: This problem will solve the Traveling Salesman Problem for a small number of cities N = 1 1 . Your tsp . py code must

This problem will solve the Traveling Salesman Problem for a small number of cities N=11.
Your tsp.py code must record how long it takes to compute a solution.
The method chosen is the brute force method.
Your code will compute ALL possible paths and find the path that minimizes the total distance.
Your code must create a (2D list) matrix called distance and fill the elements with the
distance between any 2 locations as explained in lecture.
Codes must be submitted to the slurm queuing system on either fry or owens.
You may not use the module itertools to find all permutations. You must do this in nested lops as was done in quiz04 in the createData.py code
NOT ALLOWED BELOW
import itertools
list(itertools.permutations([1,2,3]))
NOT ALLOWED ABOVE
Overview:
*) Deliver these 5 files (tsp.py, tspDist.py, proj02.slurm, proj02.output, distance.pickle)
On the remote system place these and only these 5 files in a folder called proj02
On the remote system tar the entire folder as
tar zcvf proj02.tgz proj02/
*) Python code to find best TSP path (tsp.py)
This must be run only as given below:
For the OSC systems:
singularity exec ~nehrbajo/python3.sif python3 tsp.py combined.pickle 11
on osc systems
~nehrbajo/proj02_grade proj02.tgz
Input files or codes needed:
-------------------
Located on Owens
~nehrbajo/combined.pickle # you may copy this file to $HOME
~nehrbajo/python3.sif # don't copy this. Run from my directory
~nehrbajo/proj02_grade # don't copy this. Run from my directory
Steps:
1.) Write a python code to read in the pickle file.
Keep only the first N cities and keep them in this order.
The first city is home.... Wright State University.
address[0]
2.) Implement the TSP algorithm.
This python code will find the optimal solution from home
to the next N-1 cities and back to home.
You **MUST** calculate all possible paths.
3.) Test/debug your code on a smaller number of cities
before submitting to the testing code.
You are not allowed to run your code interactively, but rather
You **MUST** submit your code to the slurm queuing system.
This can be done on either owens or fry.
4.) Keep track of how long it takes for your tsp code to
finish. Include this information in your output as defined below.
--------------------------------------------
Syntax for singularity:
singularity --silent exec containerName list_of_commands_to_run
In our case the list_of_commands_to_run are
python3 python_code.py [python parameters]
Grading criteria:
--------------------------------------------
# Format of first 7 lines of both python codes MUST follow.
Header on python codes (tsp.py, tspDist.py)
( Do not include header for the proj02.slurm, proj02.output files)
#!/ the path to your python3 code within the singularity container
# Name: John Smith
# wNumber: w123abc Never put your UIDnumber
# Project name: proj02
# Assigned: Oct 03
# Due date: Oct 17
# Tested on: (fry, pitzer, owens) pick one and ONLY one of these
# example format for the above line:
# Tested on: fry
# Header lines 4,5 and 6 should be exactly as above
For proj02.slurm
Properly formatted slurm header using (1 Node and 1 task per node)
Include bash commands to run your codes
The slurm script will first run just one tspDist.py test
that will use the list of 0419378562100
Then it will run the tsp.py test with the
inputPickleFile set to the combined.pickle file and N=11
Both of these shall be done in one slurm script... not 2 different ones.
For tspDist.py
This shall be run as ( example on fry )
singularity exec ~w006jwn/python3.sif python3 tspDist.py 0419378562100
I will however test your code against other orders and sizes of lists but you may assume
that I will use the combined.pickle file as an input.
Output is exclusively one number (ddddd) which is the integer distance in miles
For tsp.py
run as ( example on OSC)
singularity exec ~

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!