Beispiel #1
0
    def prepare_regions( self ):
        """
        Partition the phase space into disjoint, recurrent regions.

        Must have initialized self with index_map matrix and
        region2gen dictionary, or used one of the load_from_* methods
        to initialize these values.
        """
        # returns a DiGraph
        self.map_on_regions = utils.index_map_to_region_map( self.index_map,
                                                             self.region2gen )

        # graph_mis from graphs.algorithms
        scc_list, scc_components, recurrent_regions = graph_mis( self.map_on_regions,
                                                                 return_rsccs=True )
        nbunch = [ scc_components[i] for i in recurrent_regions ]
        self.recurrent_subgraphs = []

        # the actual partition of phase space in graph format
        for n in nbunch:
            # ignore disjoint regions/nodes that have self-loops => no
            # entropy
            if len( n ) == 1:
                continue
            G = DiGraph()
            G.graph = self.map_on_regions.graph.subgraph( n )
            self.recurrent_subgraphs.append( G )

        # construct IndexMapProcessor for each disjoint region
        # assign entropies  of -1 to each recurrent region. 
        for region in self.recurrent_subgraphs:
            self.phase_space.append( [ IndexMapProcessor( self.index_map,
                                                          self.region2gen,
                                                          region,
                                                          debug=self.debug,
                                                          verbose=self.verbose ),
                                      -1  # initial entropy for region
                                       ] )
Beispiel #2
0
                   1 : [2],
                   2 : [3,4]
                   }

    symbols = numpy.matrix( [[0,1,1],
                             [1,0,0],
                             [0,1,1]]
                            )
    map_on_regions = DiGraph()
    map_on_regions.from_numpy_matrix( symbols )

if 1:

    hom_matrix = utils.load_matlab_matrix( 'henon_index.mat', 'hom_matrix' )
    region2gen = utils.convert_matlab_gens( 'henon_gens.mat' )
    map_on_regions = utils.index_map_to_region_map( hom_matrix, region2gen, shift=-1)

if 0:
    hom_matrix = utils.load_matlab_matrix( 'leslie_index.mat', 'hom_matrix' )
    region2gen = utils.convert_matlab_gens( 'leslie_gens.mat' )
    map_on_regions = utils.index_map_to_region_map( hom_matrix, region2gen, shift=-1)


    ########################
    #  
    # APPEARS THAT BAD EDGE SETS ARE BEING THROWN INTO ONE (1) SET. CHECK THIS!!
    #
    ########################

debug = True
verbose = False