コード例 #1
0
    
#Sheaf Construction

#sheafcell=self,dimension,cofaces=[],compactClosure=True,stalkDim=None,metric=None)
#sheaf coface=(self,index,orientation,restriction)

sdim=np.ts.size #number of samples for u & v; n+m. For n or m, use sdim/2

s1=py.Sheaf([py.SheafCell(dimension=1,stalkDim=(sdim/2),cofaces=[]), \
            py.SheafCell(dimension=1,stalkDim=(sdim/2),cofaces=[]), \
            py.SheafCell(dimension=1,stalkDim=(sdim/2),cofaces=[]), \
            py.SheafCell(dimension=1,stalkDim=(sdim/2),cofaces=[]), \
            py.SheafCell \
(dimension=0,stalkDim=sdim,cofaces=[py.SheafCoface(index=0, orientation=1, restriction=py.LinearMorphism(pr1(ts))), \
                                py.SheafCoface(index=1, orientation=1, restriction=py.LinearMorphism(pr2(ts))), \
                                py.SheafCoface(index=3, orientation=1, restriction=py.SetMorphism(eqn1(ts)))]), \
            py.SheafCell \
(dimension=0,stalkDim=sdim,cofaces=[py.SheafCoface(index=0, orientation=-1, restriction=py.LinearMorphism(pr1(ts))), \
                                py.SheafCoface(index=1, orientation=-1, restriction=py.LinearMorphism(pr2(ts))), \
                                py.SheafCoface(index=2, orientation=-1, restriction=py.SetMorphism(eqn2(ts)))]), \
            py.SheafCell \
(dimension=0,stalkDim=(sdim/2),cofaces=[py.SheafCoface(index=0, orientation=1, restriction=py.LinearMorphism(iden(ts))), \
                                py.SheafCoface(index=2, orientation=1, restriction=py.LinearMorphism(ddt(ts)))]), \
            py.SheafCell \
(dimension=0,stalkDim=(sdim/2),cofaces=[py.SheafCoface(index=1, orientation=1, restriction=py.LinearMorphism(iden(ts))), \
                                py.SheafCoface(index=3, orientation=-1, restriction=py.LinearMorphism(ddt(ts)))])])

#How to construct? Taken from search_rescue_test.py

input_data=[py.Section([py.SectionCell(support=0,value=np.array(ts[:(sdim/2)])), # U
                        py.SectionCell(support=1,value=np.array(ts[(sdim/2):]))])] # V
コード例 #2
0
def construct_sheaf():
    global s1
    s1 = ps.Sheaf([
        ps.SheafCell(
            dimension=0,
            compactClosure=True,
            stalkDim=6,
            metric=distance_alt,  # Ignores velocity
            cofaces=[
                ps.SheafCoface(index=2,
                               orientation=1,
                               restriction=ps.LinearMorphism(
                                   np.array([[1, 0, 0, 0, 0, 0],
                                             [0, 1, 0, 0, 0, 0],
                                             [0, 0, 1, 0, 0, 0],
                                             [0, 0, 0, 1, 0, 0],
                                             [0, 0, 0, 0, 1, 0]]))),  # X->U2
                ps.SheafCoface(index=3,
                               orientation=1,
                               restriction=ps.SetMorphism(A)),  # X->U3
                ps.SheafCoface(index=4,
                               orientation=1,
                               restriction=ps.SetMorphism(B)),  # X->U4
                ps.SheafCoface(index=5,
                               orientation=1,
                               restriction=ps.SetMorphism(E))
            ],  # X->U5
            bounds=scene_bounds_0),
        ps.SheafCell(dimension=2,
                     compactClosure=True,
                     stalkDim=3,
                     metric=distance_alt,
                     cofaces=[]),  # U1
        ps.SheafCell(
            dimension=1,
            compactClosure=True,
            stalkDim=5,
            metric=distance_alt,  # Ignores velocity
            cofaces=[
                ps.SheafCoface(index=1,
                               orientation=1,
                               restriction=ps.LinearMorphism(
                                   np.array([[1, 0, 0, 0, 0], [0, 1, 0, 0, 0],
                                             [0, 0, 1, 0, 0]])))
            ]),  # U2->U1
        ps.SheafCell(
            dimension=1,
            compactClosure=True,
            stalkDim=2,
            metric=lambda x, y: min(anglemetric(x[0], y[0]), abs(x[1] - y[1])),
            cofaces=[
                ps.SheafCoface(index=6,
                               orientation=1,
                               restriction=ps.LinearMorphism(np.array(
                                   [[1, 0]]))),  # U3->V1
                ps.SheafCoface(index=8,
                               orientation=1,
                               restriction=ps.LinearMorphism(np.array([[0,
                                                                        1]])))
            ],  # U3->V3
            bounds=[(70, 80), (-pi, pi)]),  # U3->V3
        ps.SheafCell(
            dimension=1,
            compactClosure=True,
            stalkDim=2,
            metric=lambda x, y: min(anglemetric(x[0], y[0]), abs(x[1] - y[1])),
            cofaces=[
                ps.SheafCoface(index=8,
                               orientation=-1,
                               restriction=ps.LinearMorphism(np.array(
                                   [[0, 1]]))),  # U4->V3
                ps.SheafCoface(index=7,
                               orientation=1,
                               restriction=ps.LinearMorphism(np.array([[1,
                                                                        0]])))
            ],  # U4->V2
            bounds=[(60, 70), (-pi, pi)]),  # U4->V2
        ps.SheafCell(
            dimension=1,
            compactClosure=True,
            stalkDim=2,
            metric=distance,
            cofaces=[
                ps.SheafCoface(index=6,
                               orientation=-1,
                               restriction=ps.SetMorphism(C)),  # U5->V1
                ps.SheafCoface(index=7,
                               orientation=-1,
                               restriction=ps.SetMorphism(D))
            ],  # U5->V2
            bounds=[(-55, -75), (40, 50)]),
        ps.SheafCell(dimension=2,
                     compactClosure=True,
                     stalkDim=1,
                     metric=anglemetric,
                     cofaces=[]),  # V1
        ps.SheafCell(dimension=2,
                     compactClosure=True,
                     stalkDim=1,
                     metric=anglemetric,
                     cofaces=[]),  # V2
        ps.SheafCell(dimension=2, compactClosure=True, stalkDim=1, cofaces=[])
    ])  # V3
コード例 #3
0
     dimension=0,
     compactClosure=True,
     stalkDim=6,
     metric=distance_alt,  # Ignores velocity
     cofaces=[
         ps.SheafCoface(index=2,
                        orientation=1,
                        restriction=ps.LinearMorphism(
                            np.array([[1, 0, 0, 0, 0,
                                       0], [0, 1, 0, 0, 0, 0],
                                      [0, 0, 1, 0, 0,
                                       0], [0, 0, 0, 1, 0, 0],
                                      [0, 0, 0, 0, 1, 0]]))),  # X->U2
         ps.SheafCoface(index=3,
                        orientation=1,
                        restriction=ps.SetMorphism(A)),  # X->U3
         ps.SheafCoface(index=4,
                        orientation=1,
                        restriction=ps.SetMorphism(B)),  # X->U4
         ps.SheafCoface(index=5,
                        orientation=1,
                        restriction=ps.SetMorphism(E))
     ]),  # X->U5 
 ps.SheafCell(dimension=2,
              compactClosure=True,
              stalkDim=3,
              metric=distance_alt,
              cofaces=[]),  # U1
 ps.SheafCell(
     dimension=1,
     compactClosure=True,
コード例 #4
0
ファイル: GoodwinProcess.py プロジェクト: kb1dds/goodwin_econ
ts, alpha, beta, sigma, rho, gamma = parseddata_quarterly

sdim = ts.size  #number of samples for u & v; n+m. For n or m, use sdim/2
print "size of time series is " + str(ts.shape)

tsu = ts[:sdim / 2]
tsv = ts[sdim / 2:]

s1=py.Sheaf([py.SheafCell(dimension=1,stalkDim=(sdim/2),cofaces=[]), \
            py.SheafCell(dimension=1,stalkDim=(sdim/2),cofaces=[]), \
            py.SheafCell(dimension=1,stalkDim=(sdim/2),cofaces=[]), \
            py.SheafCell(dimension=1,stalkDim=(sdim/2),cofaces=[]), \
            py.SheafCell \
(dimension=0,stalkDim=sdim,cofaces=[py.SheafCoface(index=0, orientation=1, restriction=py.LinearMorphism(pr1(ts))), \
                                py.SheafCoface(index=1, orientation=1, restriction=py.LinearMorphism(pr2(ts))), \
                                py.SheafCoface(index=3, orientation=1, restriction=py.SetMorphism(lambda x: eqn1(x,alpha,beta,sigma)))]), \
            py.SheafCell \
(dimension=0,stalkDim=sdim,cofaces=[py.SheafCoface(index=0, orientation=-1, restriction=py.LinearMorphism(pr1(ts))), \
                                py.SheafCoface(index=1, orientation=-1, restriction=py.LinearMorphism(pr2(ts))), \
                                py.SheafCoface(index=2, orientation=-1, restriction=py.SetMorphism(lambda x:eqn2(x,alpha,gamma,rho)))]), \
            py.SheafCell \
(dimension=0,stalkDim=(sdim/2),cofaces=[py.SheafCoface(index=0, orientation=1, restriction=py.LinearMorphism(iden(tsu))), \
                                py.SheafCoface(index=2, orientation=1, restriction=py.LinearMorphism(ddt(tsu)))]), \
            py.SheafCell \
(dimension=0,stalkDim=(sdim/2),cofaces=[py.SheafCoface(index=1, orientation=1, restriction=py.LinearMorphism(iden(tsv))), \
                                py.SheafCoface(index=3, orientation=-1, restriction=py.LinearMorphism(ddt(tsv)))])])

input_data = [
    py.Section([
        py.SectionCell(support=0, value=tsu),  # U
        py.SectionCell(support=1, value=tsv),  #V