########################################
##########MAIN##########################
########################################

STARTTIME = time()
MAXTIME = float('inf') if len(sys.argv) < 3 else int(sys.argv[2]) 

if len(sys.argv) < 2: 
  print "must supply input file"
  exit()



cities = getcities.readCities(sys.argv[1], nearestneighbor.nearcity)
nearestneighbor.nearneighbors(cities)

#assert [x.index for x in cities] == range(len(cities))
#assert sorted(x.id for x in cities) == range(len(cities))


besttour = float('inf')
besttourstring = ""

hardcopycities = cities
#from random import shuffle
#shuffle(hardcopycities)

twoopts = []
import getcities
import primm
from math import sqrt

import sys

def distance(u,v):
    return int(round(sqrt( (u.x-v.x)**2 + (u.y-v.y)**2 )))

if len(sys.argv) < 2: 
  print "must supply input file"
  exit()


cities = getcities.readCities(sys.argv[1], primm.primcity)

distances = []

# for i in range(len(cities)):

#     cities = getcities.readCities(sys.argv[1], primm.primcity)

#     root = primm.primmtree(cities,i)

#     stack = [root]
#     tour = []

#     while stack:
#         city = stack.pop()
#         tour.append(city)
#         stack.extend(city.descendants)
Beispiel #3
0

########################################
##########MAIN##########################
########################################

STARTTIME = time()
MAXTIME = float('inf') if len(sys.argv) < 3 else int(sys.argv[2]) 

if len(sys.argv) < 2: 
  print "must supply input file"
  exit()



cities = getcities.readCities(sys.argv[1], nearestneighbor.nearcity)
nearestneighbor.nearneighbors(cities)

#assert [x.index for x in cities] == range(len(cities))
#assert sorted(x.id for x in cities) == range(len(cities))


besttour = float('inf')
besttourstring = ""

hardcopycities = cities
#from random import shuffle
#shuffle(hardcopycities)

twoopts = []
import getcities
import primm
from math import sqrt

import sys


def distance(u, v):
    return int(round(sqrt((u.x - v.x)**2 + (u.y - v.y)**2)))


if len(sys.argv) < 2:
    print "must supply input file"
    exit()

cities = getcities.readCities(sys.argv[1], primm.primcity)

distances = []

# for i in range(len(cities)):

#     cities = getcities.readCities(sys.argv[1], primm.primcity)

#     root = primm.primmtree(cities,i)

#     stack = [root]
#     tour = []

#     while stack:
#         city = stack.pop()
#         tour.append(city)