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
Your tsppy 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 D list matrix called distance and fill the elements with the
distance between any 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 quiz in the createData.py code
NOT ALLOWED BELOW
import itertools
listitertoolspermutations
NOT ALLOWED ABOVE
Overview:
Deliver these files tsppy tspDist.py projslurm, projoutput, distance.pickle
On the remote system place these and only these files in a folder called proj
On the remote system tar the entire folder as
tar zcvf projtgz proj
Python code to find best TSP path tsppy
This must be run only as given below:
For the OSC systems:
singularity exec ~nehrbajopythonsif python tsppy combined.pickle
on osc systems
~nehrbajoprojgrade projtgz
Input files or codes needed:
Located on Owens
~nehrbajocombinedpickle # you may copy this file to $HOME
~nehrbajopythonsif # don't copy this. Run from my directory
~nehrbajoprojgrade # don't copy this. Run from my directory
Steps:
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
Implement the TSP algorithm.
This python code will find the optimal solution from home
to the next N cities and back to home.
You MUST calculate all possible paths.
Testdebug 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.
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 listofcommandstorun
In our case the listofcommandstorun are
python pythoncode.py python parameters
Grading criteria:
# Format of first lines of both python codes MUST follow.
Header on python codes tsppy tspDist.py
Do not include header for the projslurm, projoutput files
# the path to your python code within the singularity container
# Name: John Smith
# wNumber: wabc Never put your UIDnumber
# Project name: proj
# Assigned: Oct
# Due date: Oct
# Tested on: fry pitzer, owens pick one and ONLY one of these
# example format for the above line:
# Tested on: fry
# Header lines and should be exactly as above
For projslurm
Properly formatted slurm header using Node and 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
Then it will run the tsppy test with the
inputPickleFile set to the combined.pickle file and N
Both of these shall be done in one slurm script... not different ones.
For tspDist.py
This shall be run as example on fry
singularity exec ~wjwnpythonsif python tspDist.py
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 tsppy
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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
