Skip to content

Commit

Permalink
updates to stderr
Browse files Browse the repository at this point in the history
  • Loading branch information
perrygeo committed Feb 12, 2017
1 parent 70183a0 commit 2e79630
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions simanneal/anneal.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,16 +120,17 @@ def update(self, step, T, E, acceptance, improvement):

elapsed = time.time() - self.start
if step == 0:
print(' Temperature Energy Accept Improve Elapsed Remaining')
sys.stdout.write('\r%12.2f %12.2f %s ' %
(T, E, time_string(elapsed)))
sys.stdout.flush()
print(' Temperature Energy Accept Improve Elapsed Remaining',
file=sys.stderr)
print('\r%12.5f %12.2f %s ' %
(T, E, time_string(elapsed)), file=sys.stderr, end="\r"),
sys.stderr.flush()
else:
remain = (self.steps - step) * (elapsed / step)
sys.stdout.write('\r%12.2f %12.2f %7.2f%% %7.2f%% %s %s' %
(T, E, 100.0 * acceptance, 100.0 * improvement,
time_string(elapsed), time_string(remain))),
sys.stdout.flush()
print('\r%12.5f %12.2f %7.2f%% %7.2f%% %s %s\r' %
(T, E, 100.0 * acceptance, 100.0 * improvement,
time_string(elapsed), time_string(remain)), file=sys.stderr, end="\r"),
sys.stderr.flush()

def anneal(self):
"""Minimizes the energy of a system by simulated annealing.
Expand Down

0 comments on commit 2e79630

Please sign in to comment.