Skip to content

Commit

Permalink
Merge pull request #220 from p-lauer/patch-8
Browse files Browse the repository at this point in the history
Updated the statistics output
  • Loading branch information
thouska authored May 28, 2019
2 parents 6ca3801 + bebb9f2 commit 300d58b
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions spotpy/algorithms/_algorithm.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,11 @@ def __init__(self, spot_setup, dbname=None, dbformat=None, dbinit=True,

if breakpoint == 'read' or breakpoint == 'readandwrite':
print('Reading backupfile')
try:
open(self.dbname+'.break')
except FileNotFoundError:
print('Backupfile not found')
self.dbappend = True
self.breakdata = self.read_breakdata(self.dbname)

# Now a repeater (ForEach-object) is loaded
# A repeater is a convinent wrapper to repeat tasks
Expand Down Expand Up @@ -355,11 +358,17 @@ def read_breakdata(self, dbname):
Reason: In case of incomplete optimizations, old data can be restored. '''
import pickle
with open(dbname+'.break', 'rb') as breakfile:
return pickle.load(breakfile)
work,backuptime,repos,obmin,obmax=pickle.load(breakfile)
self.status.starttime=self.status.starttime-backuptime
self.status.rep=repos
self.status.objectivefunction_min=obmin
self.status.objectivefunction_max=obmax
return work

def write_breakdata(self, dbname, work):
''' Write data to a pickle file if a breakpoint has been set.'''
import pickle
work=(work,self.status.last_print-self.status.starttime,self.status.rep,self.status.objectivefunction_min,self.status.objectivefunction_max)
with open(str(dbname)+'.break', 'wb') as breakfile:
pickle.dump(work, breakfile)

Expand Down

0 comments on commit 300d58b

Please sign in to comment.