def visualize_animate(i):
	global visualization_UAV, visualization_nodes_text, visualization_path, path_x, path_y
	global UAV_energy_efficient_bar
	global UAV, nodes, round_num

	# visualize the field
	visualization_UAV.set_data(UAV['current_x'], UAV['current_y'])
	if path_x[-1] != UAV['current_x'] or path_y[-1] !=  UAV['current_y']:
		path_x.append(UAV['current_x'])
		path_y.append(UAV['current_y'])
	visualization_path.set_data(path_x, path_y)
	for node_index in range(len(visualization_nodes_text)):
		visualization_nodes_text[node_index].set_text('%d:' % node_index + '(%.2lf)' % nodes[node_index]['power'])

	# make it easier to make videos
	# if i == 0:
	# 	time.sleep(10)

	# visualize the UAV
	for rect in UAV_energy_bar:
		rect.set_height(UAV['power'])

	# visualize the sensor nodes
	for bars, node in zip(nodes_energy_bar_list, nodes):
		for rect in bars:
			rect.set_height(node['power'])

	left = param_animation_frame_skip_num + 1
	while left > 0 and is_valid_node_network(nodes) and is_valid_UAV(UAV):
		nodes_next_second(nodes)
		UAV_AI.next_second(UAV, nodes, charge_mode, path_mode, 1.0, params)
		round_num += 1
		left -= 1
Esempio n. 2
0
											config.param_UAV_charging_power_consumption_rate = charging_rate
											config.param_UAV_base_distance = base_distance
											config.param_UAV_power_capacity = UAV_power_capacity
											network_type_str = str(num) + '_' + str(size) + '_' + str(size) \
												+ '_' + str(net_type) + '_' + str(localization_time) \
												+ '_' + str(transfer_rate) + '_' + str(task_threshold) \
												+ '_' + str(hovering_rate) + '_' + str(charging_rate) \
												+ '_' + str(base_distance) + '_' + str(UAV_power_capacity)
											print 'Network Type: ' + network_type_str							
											UAV_new, nodes_new = object_manager_.create_objects(config)

											# single flight
											if is_single_flight == True:
												# lower bound
												nodes = copy.deepcopy(nodes_new)
												lower_bound = UAV_AI.compute_lifetime_lower_bound(nodes)
												print 'Lifetime lower Bound', lower_bound
												res_file.write(network_type_str + ',' + 'lower_bound' + ',' + str(lower_bound) + '\n')	

												# start the experiment
												for charge_mode in param_charge_mode:
													for path_mode in param_path_mode:
														# filter invalid combination
														if is_valid_combination(charge_mode, path_mode) == False:
															continue
														UAV_mode = path_mode + '_' + charge_mode
														print 'UAV Mode: ' + UAV_mode
														UAV = copy.deepcopy(UAV_new)
														nodes = copy.deepcopy(nodes_new)
														# a hack for combination experiment
														# for node in nodes: