@@ -43,7 +43,7 @@ def __init__(self, generation_interval=100, time_interval_seconds=300,
43
43
def start_generation (self , generation ):
44
44
self .current_generation = generation
45
45
46
- def end_generation (self , config , population , species_set ):
46
+ def post_evaluate (self , config , population , species_set , best_genome ):
47
47
checkpoint_due = False
48
48
49
49
if self .time_interval_seconds is not None :
@@ -57,23 +57,23 @@ def end_generation(self, config, population, species_set):
57
57
checkpoint_due = True
58
58
59
59
if checkpoint_due :
60
- self .save_checkpoint (config , population , species_set , self .current_generation )
60
+ self .save_checkpoint (config , population , species_set , best_genome , self .current_generation )
61
61
self .last_generation_checkpoint = self .current_generation
62
62
self .last_time_checkpoint = time .time ()
63
63
64
- def save_checkpoint (self , config , population , species_set , generation ):
64
+ def save_checkpoint (self , config , population , species_set , best_genome , generation ):
65
65
""" Save the current simulation state. """
66
66
filename = '{0}{1}' .format (self .filename_prefix , generation )
67
67
print ("Saving checkpoint to {0}" .format (filename ))
68
68
69
69
with gzip .open (filename , 'w' , compresslevel = 5 ) as f :
70
- data = (generation , config , population , species_set , random .getstate ())
70
+ data = (generation , config , population , species_set , best_genome , random .getstate ())
71
71
pickle .dump (data , f , protocol = pickle .HIGHEST_PROTOCOL )
72
72
73
73
@staticmethod
74
74
def restore_checkpoint (filename ):
75
75
"""Resumes the simulation from a previous saved point."""
76
76
with gzip .open (filename ) as f :
77
- generation , config , population , species_set , rndstate = pickle .load (f )
77
+ generation , config , population , species_set , best_genome , rndstate = pickle .load (f )
78
78
random .setstate (rndstate )
79
- return Population (config , (population , species_set , generation ))
79
+ return Population (config , (population , species_set , best_genome , generation ))
0 commit comments