Skip to content

Commit

Permalink
remove commented out code
Browse files Browse the repository at this point in the history
  • Loading branch information
perrygeo committed Aug 15, 2014
1 parent f0d833f commit b3cafc9
Showing 1 changed file with 0 additions and 16 deletions.
16 changes: 0 additions & 16 deletions simanneal/anneal.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,8 @@ def anneal(self):
# Note initial state
T = self.Tmax
E = self.energy()
# copy
# prevState = self.state[:]
prevState = self.copy_state(self.state)
prevEnergy = E
# copy
#bestState = self.state[:]
bestState = self.copy_state(self.state)
bestEnergy = E
trials, accepts, improves = 0, 0, 0
Expand All @@ -136,22 +132,16 @@ def anneal(self):
trials += 1
if dE > 0.0 and math.exp(-dE / T) < random.random():
# Restore previous state
# copy
# state = prevState[:]
self.state = self.copy_state(prevState)
E = prevEnergy
else:
# Accept new state and compare to best state
accepts += 1
if dE < 0.0:
improves += 1
# copy
# prevState = self.state[:]
prevState = self.copy_state(self.state)
prevEnergy = E
if E < bestEnergy:
# copy
# bestState = self.state[:]
bestState = self.copy_state(self.state)
bestEnergy = E
if self.updates > 1:
Expand All @@ -178,8 +168,6 @@ def run(T, steps):
"""Anneals a system at constant temperature and returns the state,
energy, rate of acceptance, and rate of improvement."""
E = self.energy()
# copy
# prevState = self.state[:]
prevState = self.copy_state(self.state)
prevEnergy = E
accepts, improves = 0, 0
Expand All @@ -188,16 +176,12 @@ def run(T, steps):
E = self.energy()
dE = E - prevEnergy
if dE > 0.0 and math.exp(-dE / T) < random.random():
# copy
# self.state = prevState[:]
self.state = self.copy_state(prevState)
E = prevEnergy
else:
accepts += 1
if dE < 0.0:
improves += 1
# copy
# prevState = self.state[:]
prevState = self.copy_state(self.state)
prevEnergy = E
return E, float(accepts) / steps, float(improves) / steps
Expand Down

0 comments on commit b3cafc9

Please sign in to comment.