def Metropolis(S, T, M) :
	hill_climbing = int()
	while M != 0 :
		NewS = Utilities.genNeighbor(copy.deepcopy(S))
		deltaH = Utilities.cost(NewS, nets) - Utilities.cost(S, nets)
		exp = -deltaH/T 
		if deltaH < 0 :
			S = NewS;
		elif random.random() < math.exp(exp) :
		 	S = NewS;
		 	hill_climbing += 1
		M = M - 1;
	return S, hill_climbing
		print '-h help(display this msg)'
		sys.exit()
	elif opt == "-i" :
		input_file = value
	elif opt == "-t" :
		T0 = float(value)
	elif opt == "-a" :
		alpha = float(value)	
	elif opt == "-b" :
		beta = float(value)
	elif opt == "-m" :
		M = float(value)
	elif opt == "-x" :
		X = float(value)

fl = FileRead(input_file, "r")
width, height, nets, cells = fl.getData() 

print "\nInitial Placement: "
cells = Utilities.genInitialGrid(cells, width, height) 
printCells(cells)
print "Initial Cost:", Utilities.cost(cells, nets)

print "\nSolution: "
time_init = time.time()
cells, hills = Simulated_annealing(cells, T0, alpha, beta, M, X)
time_end = time.time()
printCells(cells)
print "Final Cost:", Utilities.cost(cells, nets)
print "\"Hills Climbed\": ", hills
print "Time: ", round(time_end - time_init, 2), " s"