Esempio n. 1
0
    def load_from_matlab_files( self, index_fname=None,
                                generators_fname=None,
                                matname=None):
        """
        index_fname : path to matrix of map on generators (may have to
        provide internal name of the matlab matrix to extract it from
        meta data. See example below. )

        generators_fname : path to the region --> geneators map.

        Example:
        --------

           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)
        """
        self.index_fname = index_fname
        self.generators_fname = generators_fname
        self.index_map = utils.load_matlab_matrix( self.index_fname, matname )
        self.region2gen = utils.convert_matlab_gens( self.generators_fname )
Esempio n. 2
0
#!/usr/bin/python

import sys
import numpy as np
import scipy.io
from rads.misc import utils
from rads.symbolics.sofic_processor import SoficProcessor


for f in "ap1r2.mat ap2r6.mat ap3r2.mat ap3r4.mat ap4r2.mat ap5r2.mat ap5r3.mat ap6r5.mat ap7r3.mat ap8r2.mat ap8r3.mat ap9r2.mat ap9r3.mat ap11r8.mat ap12r8.mat ap13r8.mat ap14r8.mat ap15r8.mat".split(" "):
    dat = utils.load_matlab_matrix( '/home/raf/Dropbox/projects/plateaus/focm-data/'+f, matname='d')
    print f
    # the [0,0][0,1] is to get the second entry of the cell, i.e. dat.M_inv{2}
    M = dat['M_inv'][0,0][0,1]
    G = utils.cell2dict(dat['G_inv'][0,0][0,1][0])
    sof = SoficProcessor(M,G)
    sof.process()
    print sof
    print 'entropy:', sof.entropy()

# ap1r2.mat
# SoficProcessor on 886 symbols, with 1096 states and 2065 transitions
# entropy: 0.637936814478
# ap2r6.mat
# SoficProcessor on 553 symbols, with 689 states and 1294 transitions
# entropy: 0.637347707344
# ap3r2.mat
# SoficProcessor on 834 symbols, with 999 states and 1870 transitions
# entropy: 0.639166621114
# ap3r4.mat
# SoficProcessor on 649 symbols, with 728 states and 1359 transitions
Esempio n. 3
0
#!/usr/bin/python

import sys
import numpy as np
import scipy.io
from rads.misc import utils
from rads.symbolics.sofic_processor import SoficProcessor


datcell = utils.load_matlab_matrix('/home/raf/Dropbox/projects/plateaus/focm-data/results-9-2-2007/results_apboxprm_b2_d22.mat', matname='D')

ents = np.zeros(datcell.shape)

for i in range(datcell.shape[0]):
    for j in range(datcell.shape[1]):
        M = datcell[i,j][0,2]
        G = utils.cell2dict(datcell[i,j][0,1][0])
        sof = SoficProcessor(M,G)
        sof.process()
        print sof
        ents[i,j] = sof.entropy()
        print 'entropy:', ents[i,j]

np.savetxt('plateaus_ap_b2_22.txt',ents)

# SoficProcessor on 2 symbols, with 6 states and 10 transitions
# entropy: 0.528048909513
# SoficProcessor on 2 symbols, with 6 states and 10 transitions
# entropy: 0.528048909513
# SoficProcessor on 2 symbols, with 6 states and 10 transitions
# entropy: 0.528048909513
Esempio n. 4
0
#print "Drawing all verified semi-conjugate subshifts..."
#re1.draw()

print ""

## EXPECTED OUTPUT for Leslie map files
# >>> Testing with Numpy matices...
# >>> Maximum entropy found:  0.150632111601


##############################
# test matlab functionality
##############################

# load from matrix and dict
print "Testing ability to start off with Matlab matrices..." 
hom_matrix = utils.load_matlab_matrix( fname_mat, matname )
region2gen = utils.convert_matlab_gens( reg_mat )

re2 = RigorousEntropy( index_map=hom_matrix,
                       reg2gen=region2gen )    
re2.prepare_regions()

# drawing the map on regions
print "Drawing the maps on strongly connected components (disjoint regions in the MVM)...\n"
fig = re2.map_on_regions.draw()

re2.compute_entropy()
re2.get_max_entropy()

Esempio n. 5
0
import numpy as np
from rads.misc import utils
from rads.symbolics.sofic_processor import SoficProcessor

if len(sys.argv) < 3:
    print "usage: python test_sofic.py <data file> [<index_map> <generators>]"
    print "where <index_map> and <generators> default to M and G"
    genn = 'G'
    mapn = 'M'
else:
    genn = sys.argv[2]
    mapn = sys.argv[3]
filename = sys.argv[1]

gens = utils.convert_matlab_gens( filename, genname=genn )
index_map = utils.load_matlab_matrix( filename, matname=mapn ).astype(int)
sof = SoficProcessor( index_map, gens, debug=False )
sof.process()
print sof
print sof.entropy()


# for i in range(ca.shape[0]):
#     gens = utils.cell2dict(ca[i,0])
#     sof = SoficProcessor(ca[i,1],gens)
#     sof.process()
#     print sof
#     print sof.entropy()

# ca = utils.load_matlab_matrix( '/home/raf/Dropbox/henon-tipping-14-run-goodruns.mat', matname='e' )
# ents = []
Esempio n. 6
0
#!/usr/bin/python

import sys
import numpy as np
import scipy.io
from rads.misc import utils
from rads.symbolics.sofic_processor import SoficProcessor


dat = utils.load_matlab_matrix( '/home/raf/projects/std/std-eps2-p2-runs/std-eps2-p2-plus34-run-dat.mat', matname='dat')

# the [0,0][0,1] is to get the second entry of the cell, i.e. dat.M_inv{2}
M = dat['M_inv'][0,0][0,1]
G = utils.cell2dict(dat['G_inv'][0,0][0,1][0])
sof = SoficProcessor(M,G)
sof.process()
print sof
print 'entropy:', sof.entropy()
# SoficProcessor on 41 symbols, with 68 states and 127 transitions
# entropy: 0.571595590383
# up from STD: Theorem 4.4. The topological entropy for the standard map for eps = 2 is bounded below by 0.54518888942276.

# 5/7/2017 TODO: minimize?  (point being: we get a better number with a smaller description...)
Esempio n. 7
0
    # A <--> 0, B <--> 1, etc.
    region2gen = { 0 : [0,1],
                   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!!
    #
    ########################