예제 #1
0
 def postprocessing(self, world):
     """Save the tree in file, and its rendering"""
     filename = os.path.join(self.archive_directory, 'tree')
     dot = converter.graphdict_to_dot(self.tree)
     with open(filename, 'w') as fd:
         fd.write(dot)
     if self.render_graph:
         converter.graph_rendering(dot, filename + '.png',
                                   layout=TreeBuilder.GRAPHVIZ_LAYOUT)
예제 #2
0
 def postprocessing(self, world):
     """Save the tree in file, and its rendering"""
     filename = os.path.join(self.archive_directory, 'tree')
     dot = converter.graphdict_to_dot(self.tree)
     with open(filename, 'w') as fd:
         fd.write(dot)
     if self.render_graph:
         converter.graph_rendering(dot,
                                   filename + '.png',
                                   layout=TreeBuilder.GRAPHVIZ_LAYOUT)
예제 #3
0
 def update(self, world, signals):
     """Intercept new individuals creation for create a snapshot
     of their neural networks, in DOT format and PNG picture."""
     if self.do_graph and observer.Signal.NEW_INDIVIDUAL in signals:
         new_indiv, parent, _ = signals[observer.Signal.NEW_INDIVIDUAL]
         gen_filename = partial(self._archive_filename, new_indiv)
         network_versions = (
             ('dot_cln', new_indiv.network_atoms),
             ('dot_all', new_indiv.network_atoms_all)
         )
         for version, network_atoms in network_versions:
             graph = converter.network_atoms_to_dot(network_atoms)
             if self.save_graph:
                 dot_file = gen_filename(version, 'dot')
                 self.save(graph, dot_file)
             if self.render_graph:
                 render_file = gen_filename(version, 'png')
                 converter.graph_rendering(graph, render_file,
                                           layout=Archivist.GRAPHVIZ_LAYOUT)