Exemple #1
0
        def SDPTDoALocate(self, RN1, RN2, TDoA, TDoAStd):
                """
                Apply SDP approximation and localization
                """
                RN1 = cvxm.matrix(RN1)
                RN2 = cvxm.matrix(RN2)
                TDoA = cvxm.matrix(TDoA)
                c       = 3e08                                          
                RDoA     = c*TDoA
                RDoAStd=cvxm.matrix(c*TDoAStd)
                mtdoa,ntdoa=cvxm.size(RN1)
                Im = cvxm.eye(mtdoa)
                Y=cvxm.optvar('Y',mtdoa+1,mtdoa+1)
                t=cvxm.optvar('t',ntdoa,1)
                prob=cvxm.problem(cvxm.minimize(cvxm.norm2(t)))
                prob.constr.append(Y>=0)
                prob.constr.append(Y[mtdoa,mtdoa]==1)
                for i in range(ntdoa):
                    X0=cvxm.matrix([[Im, -cvxm.transpose(RN1[:,i])],[-RN1[:,i], cvxm.transpose(RN1[:,i])*RN1[:,i]]])
                    X1=cvxm.matrix([[Im, -cvxm.transpose(RN2[:,i])],[-RN2[:,i], cvxm.transpose(RN2[:,i])*RN2[:,i]]])
                    prob.constr.append(-RDoAStd[i,0]*t[i]<cvxm.trace(X0*Y)+cvxm.trace(X1*Y)-RDoA[i,0]**2)
                    prob.constr.append(RDoAStd[i,0]*t[i]>cvxm.trace(X0*Y)+cvxm.trace(X1*Y)-RDoA[i,0]**2)
                prob.solve()
                Pval=Y.value
                X_cvx=Pval[:2,-1]

                return X_cvx
Exemple #2
0
        def SDPToALocate(self, RN, ToA, ToAStd):
                """
                Apply SDP approximation and localization
                """
                RN = cvxm.matrix(RN)
                ToA = cvxm.matrix(ToA)
                
                c       = 3e08                                          # Speed of light
                RoA     = c*ToA
                RoAStd  = c*ToAStd
                RoAStd = cvxm.matrix(RoAStd)
                mtoa,ntoa=cvxm.size(RN)
                Im = cvxm.eye(mtoa)
                Y=cvxm.optvar('Y',mtoa+1,mtoa+1)
                t=cvxm.optvar('t',ntoa,1)
                prob=cvxm.problem(cvxm.minimize(cvxm.norm2(t)))
                prob.constr.append(Y>=0)
                prob.constr.append(Y[mtoa,mtoa]==1)
                for i in range(ntoa):
                    X0=cvxm.matrix([[Im, -cvxm.transpose(RN[:,i])],[-RN[:,i], cvxm.transpose(RN[:,i])*RN[:,i]]])
                    prob.constr.append(-t[i]<(cvxm.trace(X0*Y)-RoA[i]**2)*(1/RoAStd[i]))
                    prob.constr.append(t[i]>(cvxm.trace(X0*Y)-RoA[i]**2)*(1/RoAStd[i]))
                prob.solve()
                Pval=Y.value
                X_cvx=Pval[:2,-1]

                return X_cvx
Exemple #3
0
        def SDPRSSLocate(self, RN, PL0, d0, RSS, RSSnp, RSSStd, Rest):

                RoA=self.getRange(RN, PL0, d0, RSS, RSSnp, RSSStd, Rest)
                

                RN=cvxm.matrix(RN)
                RSS=cvxm.matrix(RSS)
                RSSnp=cvxm.matrix(RSSnp)
                RSSStd=cvxm.matrix(RSSStd)
                PL0=cvxm.matrix(PL0)
                RoA=cvxm.matrix(RoA)
                mrss,nrss=cvxm.size(RN)
                
                Si = array([(1/d0**2)*10**((RSS[0,0]-PL0[0,0])/(5.0*RSSnp[0,0])),(1/d0**2)*10**((RSS[1,0]-PL0[1,0])/(5.0*RSSnp[1,0])),(1/d0**2)*10**((RSS[2,0]-PL0[2,0])/(5.0*RSSnp[2,0])),(1/d0**2)*10**((RSS[3,0]-PL0[3,0])/(5.0*RSSnp[3,0]))])
                #Si = array([(1/d0**2)*10**(-(RSS[0,0]-PL0[0,0])/(5.0*RSSnp[0,0])),(1/d0**2)*10**(-(RSS[0,1]-PL0[1,0])/(5.0*RSSnp[0,1])),(1/d0**2)*10**(-(RSS[0,2]-PL0[2,0])/(5.0*RSSnp[0,2])),(1/d0**2)*10**(-(RSS[0,3]-PL0[3,0])/(5.0*RSSnp[0,3]))])
                
                Im = cvxm.eye(mrss)
                Y=cvxm.optvar('Y',mrss+1,mrss+1)
                t=cvxm.optvar('t',nrss,1)

                prob=cvxm.problem(cvxm.minimize(cvxm.norm2(t)))
                prob.constr.append(Y>=0)
                prob.constr.append(Y[mrss,mrss]==1)
                for i in range(nrss):
                    X0=cvxm.matrix([[Im, -cvxm.transpose(RN[:,i])],[-RN[:,i], cvxm.transpose(RN[:,i])*RN[:,i]]])
                    prob.constr.append(-RSSStd[i,0]*t[i]<Si[i]*cvxm.trace(X0*Y)-1)
                    prob.constr.append(RSSStd[i,0]*t[i]>Si[i]*cvxm.trace(X0*Y)-1)
               
                prob.solve()
                
                Pval=Y.value
                X_cvx=Pval[:2,-1]
                
                return X_cvx
Exemple #4
0
def compute_bbox_set_agreement(example_boxes, gold_boxes):
    nExB = len(example_boxes)
    nGtB = len(gold_boxes)
    if nExB == 0:
        if nGtB == 0:
            return 1
        else:
            return 0

    if nGtB == 0:
        print "WARNING: new object"
        return 0

    A = cvxmod.zeros(rows=nExB, cols=nGtB)

    for iBox, ex in enumerate(example_boxes):
        for jBox, gt in enumerate(gold_boxes):
            A[iBox, jBox] = ex.overlap_score(gt)

    S = []
    S2 = []

    for iBox, ex in enumerate(example_boxes):
        S_tmp = [0] * (iBox) * nGtB + [1] * nGtB + [0] * (nExB - iBox -
                                                          1) * nGtB

        S.append(S_tmp)

    for jBox in range(0, nGtB):
        S2_tmp = [0] * nExB * nGtB
        for j2 in range(0, nExB):
            S2_tmp[j2 * nGtB + jBox] = 1

        S2.append(S2_tmp)

    S = cvxmod.transpose(cvxmod.matrix(S, size=(nExB * nGtB, nExB)))
    S2 = cvxmod.transpose(cvxmod.matrix(S2, size=(nExB * nGtB, nGtB)))

    A2 = cvxmod.matrix(A, (1, nExB * nGtB))
    x = cvxmod.optvar('x', rows=nExB * nGtB, cols=1)

    p = cvxmod.problem(cvxmod.maximize(A2 * x))
    p.constr.append(x <= 1)
    p.constr.append(x >= 0)

    p.constr.append(S * x <= 1)
    p.constr.append(S2 * x <= 1)

    p.solve(True)
    overlap = cvxmod.value(p) / max(nExB, nGtB)
    assert (overlap < 1.0001)
    return overlap