- #prevState = copy.deepcopy(state)

+ prevState = copy.deepcopy(state)

- #bestState = copy.deepcopy(state)

+ bestState = copy.deepcopy(state)

trials, accepts, improves = 0, 0, 0

if dE > 0.0 and math.exp(-dE/T) < random.random():

- #state = copy.deepcopy(prevState)

+ state = copy.deepcopy(prevState)

# Accept new state and compare to best state

- #prevState = copy.deepcopy(state)

+ prevState = copy.deepcopy(state)

- #bestState = copy.deepcopy(state)

+ bestState = copy.deepcopy(state)

if step // updateWavelength > (step-1) // updateWavelength:

"""Anneals a system at constant temperature and returns the state,

energy, rate of acceptance, and rate of improvement."""

- #prevState = copy.deepcopy(state)

+ prevState = copy.deepcopy(state)

for step in range(steps):

if dE > 0.0 and math.exp(-dE/T) < random.random():

- #state = copy.deepcopy(prevState)

+ state = copy.deepcopy(prevState)

- #prevState = copy.deepcopy(state)

+ prevState = copy.deepcopy(state)

return state, E, float(accepts)/steps, float(improves)/steps