(self, initial_state)
return states
Generates states (attribute pairs) - the most promising first, i.e.
        states within clusters, following by states among clusters.

        :param initial_state: initial state; None if this is the first call
        :return: generator of tuples of states
Generates states (attribute pairs) - the most promising first, i.e.
        states within clusters, following by states among clusters.
Generates states ( attribute pairs ) - the most promising first i . e . states within clusters following by states among clusters .
def get_states(self, initial_state):
        """
        Generates states (attribute pairs) - the most promising first, i.e.
        states within clusters, following by states among clusters.

        :param initial_state: initial state; None if this is the first call
        :return: generator of tuples of states
        """
        if self.clusters is None:
            self.clusters = self.get_clusters_of_attributes()
        clusters = self.clusters

        # combinations within clusters
        states0 = chain.from_iterable(combinations(cluster.instances, 2)
                                      for cluster in clusters)
        if self.n_clusters == 1:
            return states0

        # combinations among clusters - closest clusters first
        centroids = [c.centroid for c in clusters]
        centroids_combs = np.array(list(combinations(centroids, 2)))
        distances = np.linalg.norm((centroids_combs[:, 0] -
                                    centroids_combs[:, 1]), axis=1)
        cluster_combs = list(combinations(range(len(clusters)), 2))
        states = ((min((c1, c2)), max((c1, c2))) for i in np.argsort(distances)
                  for c1 in clusters[cluster_combs[i][0]].instances
                  for c2 in clusters[cluster_combs[i][1]].instances)
        states = chain(states0, states)

        if initial_state is not None:
            while next(states) != initial_state:
                pass
            return chain([initial_state], states)
        return states
def get_states ( self , initial_state ) : if self . clusters is None : self . clusters = self . get_clusters_of_attributes ( ) clusters = self . clusters # combinations within clusters states0 = chain . from_iterable ( combinations ( cluster . instances , 2 ) for cluster in clusters ) if self . n_clusters == 1 : return states0 # combinations among clusters - closest clusters first centroids = [ c . centroid for c in clusters ] centroids_combs = np . array ( list ( combinations ( centroids , 2 ) ) ) distances = np . linalg . norm ( ( centroids_combs [ : , 0 ] - centroids_combs [ : , 1 ] ) , axis = 1 ) cluster_combs = list ( combinations ( range ( len ( clusters ) ) , 2 ) ) states = ( ( min ( ( c1 , c2 ) ) , max ( ( c1 , c2 ) ) ) for i in np . argsort ( distances ) for c1 in clusters [ cluster_combs [ i ] [ 0 ] ] . instances for c2 in clusters [ cluster_combs [ i ] [ 1 ] ] . instances ) states = chain ( states0 , states ) if initial_state is not None : while next ( states ) != initial_state : pass return chain ( [ initial_state ] , states ) return states