global nodes, visualization_nodes_text visualization_nodes_text = [] for node in nodes: visualization_node_text = ax.text(node['x'], node['y'], '') visualization_nodes_text.append(visualization_node_text) ani = animation.FuncAnimation(fig, visualize_animate, interval=param_animation_frame_interval, blit=False) plt.show() object_manager_ = ObjectManager() round_num = 1 if using_last_system_state == True: UAV, nodes = object_manager_.read_objects_file('.tmp_state') else: UAV, nodes = object_manager_.create_objects(config) object_manager_.save_objects_file(UAV, nodes, '.tmp_state') path_x = [UAV['current_x']] path_y = [UAV['current_y']] # visualization # set up figure and animation fig = plt.figure(figsize=(12, 6)) gs = gridspec.GridSpec(1, 3, width_ratios=[9, 4, 1], wspace=0.5) ax = fig.add_subplot(gs[0], xlim=(-3, config.param_ground_width+3), ylim=(-3, config.param_ground_height+3)) ax_nodes = fig.add_subplot(gs[1]) ax_UAV = fig.add_subplot(gs[2]) # field ax.grid() visualization_path, = ax.plot([], [], '-', lw=2)
config.param_ground_width = size config.param_ground_height = size config.param_UAV_localization_time = localization_time config.param_UAV_charging_power_transfer_rate = transfer_rate config.param_network_type = net_type config.param_UAV_hovering_power_consumption_rate = hovering_rate 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