def get_current_clusters(self) -> List[Cluster]: clusters = self._database_connector.find_many( "clusters", { "alive": True } ) return [Transformator.decode_Cluster(c) for c in clusters]
def get_cluster_by_representative(self, genome_id: ObjectId): cluster = Transformator.decode_Cluster( self._database_connector.find_one( "clusters", { "representative": genome_id } ) ) return cluster
def archive_cluster(self, cluster_id: ObjectId) -> dict: cluster = Transformator.decode_Cluster( self._database_connector.find_one_by_id( "clusters", cluster_id ) ) cluster.alive = False return self._database_connector.update_one( "clusters", cluster_id, Transformator.encode_Cluster( cluster ) )
def update_fitness_for_cluster( self, cluster_id: ObjectId, cluster_fitness: float ): cluster = Transformator.decode_Cluster( self._database_connector.find_one_by_id( "clusters", cluster_id ) ) cluster.offspring = cluster_fitness return self._database_connector.update_one( "clusters", cluster_id, Transformator.encode_Cluster( cluster ) )
def update_max_population_for_cluster( self, cluster_id: ObjectId, cluster_max_population: int ): cluster = Transformator.decode_Cluster( self._database_connector.find_one_by_id( "clusters", cluster_id ) ) cluster.offspring = cluster_max_population return self._database_connector.update_one( "clusters", cluster_id, Transformator.encode_Cluster( cluster ) )