コード例 #1
0
ファイル: try.py プロジェクト: technocore-tip/Swarm_Project
    #print(robot)
    while distance>0.5:
        loc_x = -x_total/40.0
        loc_y = -y_total/40.0
        lock.acquire()
        #print(robot.id,loc_x,loc_y,distance)
        lock.release()
        robot.move(loc_x,loc_y)
        x_total,y_total = relative_distance(robot,robots)
        distance = distance_magnitude(x_total,y_total)
        time.sleep(0.1)

def simulate_meeting_point(robots):
	#run simulation using multithreading
    for robot in robots:
        dynamics_meeting_point(robot,robots)
#        worker = threading.Thread(target=dynamics_meeting_point,args=(robot,robots))
#        print(worker)
#        worker.setDaemon(True)
#        worker.start()



if __name__ == '__main__':
	#main program
	win = draw_windows(1024,1024) #draw window with width = 700 and height = 600
	robots = draw_swarm(70,win) #draw 7 swarm in win
	win.getMouse() #blocking call
	simulate_meeting_point(robots) #start simulation meeting point
	win.getMouse()
コード例 #2
0
plotter = VisdomLinePlotter(env_name="Swarm_Simulation")
simulation_time = time.time()

trial_no="TURK1 s2"

N=100
rho_bar, sigma =10,100
mu=100
l=5*rho_bar
times=pow(2,-8)

rho_k,patches = normal_distribution(rho_bar,sigma,trial_no)
particles=list()

win = draw_windows(1024,1024,trial_no) #draw window with width = 700 and height = 600.
robots = draw_swarm(N,win,l,rho_k,patches) #draw N swarm in win
win.getMouse() #blocking call

for i in range(1,N+1,1):
    particles.append([i,rho_k[i-1]])


#pairwise_list= list(combinations(particles,2))
pairwise_list = random.sample(particles, 2)
#mt_shuffle()

step=0

rho_kmean =np.mean(rho_k)# second term of the energy function
combination= (N*(N-1))/2