Skip to content

Commit

Permalink
Format output with named parameters.
Browse files Browse the repository at this point in the history
  • Loading branch information
Iain committed Jan 22, 2020
1 parent 781ca15 commit a0dfbd7
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions simanneal/anneal.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,22 @@ def default_update(self, step, T, E, acceptance, improvement):
if step == 0:
print('\n 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="")
print('\r{Temp:12.5f} {Energy:12.2f} {Elapsed:s} '
.format(Temp=T,
Energy=E,
Elapsed=time_string(elapsed)),
file=sys.stderr, end="")
sys.stderr.flush()
else:
remain = (self.steps - step) * (elapsed / step)
print('\r%12.5f %12.2f %7.2f%% %7.2f%% %s %s' %
(T, E, 100.0 * acceptance, 100.0 * improvement,
time_string(elapsed), time_string(remain)), file=sys.stderr, end="")
print('\r{Temp:12.5f} {Energy:12.2f} {Accept:7.2%} {Improve:7.2%} {Elapsed:s} {Remaining:s}'
.format(Temp=T,
Energy=E,
Accept=acceptance,
Improve=improvement,
Elapsed=time_string(elapsed),
Remaining=time_string(remain)),
file=sys.stderr, end="")
sys.stderr.flush()

def anneal(self):
Expand Down

0 comments on commit a0dfbd7

Please sign in to comment.