コード例 #1
0
def construct_3_step_sheaf():
    global s3
    s3=ps.Sheaf([ps.SheafCell(dimension=0,
                              compactClosure=True,
                              stalkDim=6,
                              metric=distance, # Ignores velocity
                              cofaces=[ps.SheafCoface(index=1, 
                                                      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]]))), # A->B
                                       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,2,0,0],
                                                                                              [0,0,0,0,1,0]]))), # A->C
                                       ],
                              ), 
                 ps.SheafCell(dimension=1,
                              compactClosure=True,
                              stalkDim=5,
                              metric=distance,
                              cofaces=[ps.SheafCoface(index=3, 
                                                      orientation=1,
                                                      restriction=ps.LinearMorphism(np.array([[1,0,0,0,0],
                                                                                              [0,1,0,0,0],
                                                                                              [0,0,1,0,0],
                                                                                              [0,0,0,2,0]]))), # B->D
                                       ]),
                 ps.SheafCell(dimension=1,
                              compactClosure=True,
                              stalkDim=5,
                              metric=distance, # Ignores velocity
                              cofaces=[ps.SheafCoface(index=3,
                                                      orientation=1,
                                                      restriction=ps.LinearMorphism(np.array([[1,0,0,0,0],
                                                                                              [0,1,0,0,0],
                                                                                              [0,0,1,0,0],
                                                                                              [0,0,0,1,0]]))), # C->D
                                      ]),
                 ps.SheafCell(dimension=2,
                              compactClosure=True,
                              stalkDim=4,
                              metric=distance,
                              cofaces=[ps.SheafCoface(index=4,
                                                      orientation=1,
                                                      restriction=ps.LinearMorphism(np.array([[1,0,0,0],
                                                                                              [0,1,0,0],
                                                                                              [0,0,1,0],
                                                                                              [0,0,0,1]])))]),
                 ps.SheafCell(dimension=3,
                              compactClosure=True,
                              stalkDim=4,
                              metric=distance,
                              cofaces=[]),
                 ])
コード例 #2
0
    consistency_radii=[s1.consistencyRadius(case) for case in input_data]
    return consistency_radii
    
#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
コード例 #3
0
                     ]),
        ps.SheafCell(dimension=1,
                     cofaces=[
                         ps.SheafCoface(2, -1, np.matrix(1)),
                         ps.SheafCoface(3, 1, np.matrix(1))
                     ]),
        ps.SheafCell(dimension=2, stalkDim=1),
        ps.SheafCell(dimension=2, stalkDim=1)
    ])
    print 'S^2 Sheaf Betti numbers: ' + str(
        (SphSheaf.cobetti(0), SphSheaf.cobetti(1), SphSheaf.cobetti(2)))

    MorCirDisk = ps.SheafMorphism([
        ps.SheafMorphismCell(destinations=[0, 1, 2],
                             maps=[
                                 ps.LinearMorphism(np.matrix(1)),
                                 ps.LinearMorphism(np.matrix(1)),
                                 ps.LinearMorphism(np.matrix(1))
                             ]),
        ps.SheafMorphismCell(destinations=[3],
                             maps=[ps.LinearMorphism(np.matrix(1))]),
        ps.SheafMorphismCell(destinations=[], maps=[])
    ])
    print 'degree 0 induced map S^1->D^2: ' + str(
        ps.inducedMap(DiskSheaf, CircSheaf, MorCirDisk, 0))
    print 'degree 1 induced map S^1->D^2:' + str(
        ps.inducedMap(DiskSheaf, CircSheaf, MorCirDisk, 1))
    print 'degree 2 induced map S^1->D^2:' + str(
        ps.inducedMap(DiskSheaf, CircSheaf, MorCirDisk, 2))

    # Sheaf over a graph with an undirected loop
コード例 #4
0
# 6: V1 = S1 (theta1)
# 7: V2 = S1 (theta2)
# 8: V3 = R (t)

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 
    ps.SheafCell(dimension=2,
                 compactClosure=True,
                 stalkDim=3,
コード例 #5
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
コード例 #6
0
              ps.SheafCell(dimension=1,cofaces=[ps.SheafCoface(2,1,np.matrix(1))]),
              ps.SheafCell(dimension=2,stalkDim=1)])
    print 'Disk Betti numbers: ' + str((DiskSheaf.betti(0),DiskSheaf.betti(1),DiskSheaf.betti(2)))

    # A 2-sphere
    SphSheaf=ps.Sheaf([ps.SheafCell(dimension=0,cofaces=[
              ps.SheafCoface(1,-1,np.matrix(1)),
              ps.SheafCoface(1,1,np.matrix(1))]),
              ps.SheafCell(dimension=1,cofaces=[
              ps.SheafCoface(2,-1,np.matrix(1)),
              ps.SheafCoface(3,1,np.matrix(1))]),
              ps.SheafCell(dimension=2,stalkDim=1),
              ps.SheafCell(dimension=2,stalkDim=1)])
    print 'S^2 Betti numbers: ' + str((SphSheaf.betti(0),SphSheaf.betti(1),SphSheaf.betti(2)))

    MorCirDisk=ps.SheafMorphism([ps.SheafMorphismCell(destinations=[0,1,2],maps=[ps.LinearMorphism(np.matrix(1)),ps.LinearMorphism(np.matrix(1)),ps.LinearMorphism(np.matrix(1))]),
                                 ps.SheafMorphismCell(destinations=[3],maps=[ps.LinearMorphism(np.matrix(1))]),
                                 ps.SheafMorphismCell(destinations=[],maps=[])])
    print 'degree 0 induced map S^1->D^2: ' + str(ps.inducedMap(DiskSheaf,CircSheaf,MorCirDisk,0))
    print 'degree 1 induced map S^1->D^2:' + str(ps.inducedMap(DiskSheaf,CircSheaf,MorCirDisk,1))
    print 'degree 2 induced map S^1->D^2:' + str(ps.inducedMap(DiskSheaf,CircSheaf,MorCirDisk,2))

    # Sheaf over a graph with an undirected loop
    LoopSheaf=ps.Sheaf([ps.SheafCell(dimension=0,cofaces=[
        ps.SheafCoface(2,1,np.matrix([1,0])),
        ps.SheafCoface(3,1,np.matrix([0,0])),
        ps.SheafCoface(4,-1,np.matrix([1,1]))]),
        ps.SheafCell(dimension=0,cofaces=[
        ps.SheafCoface(2,-1,np.matrix([1,0])),
        ps.SheafCoface(3,-1,np.matrix([0,1])),
        ps.SheafCoface(5,1,np.matrix([1,1]))]),
コード例 #7
0
#U2=PxF
#U3=WxF
#U4=WxP
#V1=P
#V2=F
#V3=W
#difference between LINEAR morphism and SET morphism
s1 = ps.Sheaf([
    ps.SheafCell(
        dimension=0,
        compactClosure=True,
        stalkDim=2,  #THIS IS THE NUMBER OF COLUMNS ?!?!
        cofaces=[
            ps.SheafCoface(index=4,
                           orientation=1,
                           restriction=ps.LinearMorphism(
                               np.array([[1.0, 0], [0, 1.0]]))),  #X>U3 ?!?!?!
            ps.SheafCoface(index=5,
                           orientation=-1,
                           restriction=ps.LinearMorphism(
                               np.array([[0, 0], [1.0, 0], [0, 1.0], [0, 0]])))
        ]),  #X>U4
    ps.SheafCell(
        dimension=0,
        compactClosure=True,
        stalkDim=
        4,  #WHICH INDEX OF COLUMNS IS THIS REFERRING TO, THE SEED OR THE FINALS
        cofaces=[
            ps.SheafCoface(index=4,
                           orientation=1,
                           restriction=ps.LinearMorphism(
                               np.array([[1.0, 1.0, 0, 0],