个体位置轨迹产生的算法
Moving in a Neighborhood(MN) algorithm
论文An Anonymous Communication Techniques using Dummies for Location-based Services 中提到的,根据用户前一时刻的位置,产生下一时刻的位置的算法,可以用户模拟用户或者dummy轨迹产生的方法

import random

class dummy:
    def __init__(self):
        self.x = 0
        self.y = 0
        self.t = 0

def MovingInNeighborhood(m,n):

    dummyPretemp = dummy() # 前一时刻用户位置及时间信息
    dummyNexttemp = dummy() # 后一时刻用户位置及时间信息

    # 用户位置及时间 初始化
    dummyPretemp.x = 0
    dummyPretemp.y = 0
    dummyPretemp.t = 0
    # 生成下一位置及时间信息
    dummyNexttemp.x = random.randint( dummyPretemp.x - m, dummyPretemp.x + m )
    dummyNexttemp.y = random.randint( dummyPretemp.y - m, dummyPretemp.y + m )
    dummyNexttemp.t = dummyPretemp.t + 1 

    dummyNext= [ dummyNexttemp.x, dummyNexttemp.y, dummyNexttemp.t ]        
    dummyNext = [ dummyNext ]   

    i = 0
    for i in range(n):  
        print i
        print dummyNext     
        dummyPretemp = dummyNexttemp
        # 生成下一位置及时间信息
        dummyNexttemp.x = random.randint( dummyPretemp.x - m, dummyPretemp.x + m )
        dummyNexttemp.y = random.randint( dummyPretemp.y - m, dummyPretemp.y + m )
        dummyNexttemp.t = dummyPretemp.t + 1

        dummyNext.append( [ dummyNexttemp.x, dummyNexttemp.y, dummyNexttemp.t ] )
        i = i + 1

#print dummyA.x

MovingInNeighborhood(3,3)

SecondLife
1.9k 声望252 粉丝