with open('../libs/All_shapes_334.pic','r') as f:
				all_shapes = pickle.load(f)
			boundary = list(all_shapes[zone]['boundary'][0].exterior.coords)
			assert boundary[0]==boundary[-1]

			with open(_result_dir + '/trajectories/bounds/' + G.name + '_bound_latlon.dat', 'w') as f:
				for x, y in boundary:
					f.write(str(x) + '\t' + str(y) + '\n')

			print "Finding best capacity factor..."
			capacity_factor, rejected_flights, H = find_good_scaling_capacity(G, _result_dir + "/networks/" + name_G + '_flights_selected.pic', target=target_rejected_flights)
			print "Found best capacity factor:", capacity_factor, "(rejected fraction", rejected_flights, "of flights)"
			#print "Capacities:", {n:H.node[n]['capacity'] for n in H.nodes()}

			write_down_capacities(H, save_file=_result_dir + '/trajectories/capacities/' + G.name + '_capacities_rec_rej' + str(target_rejected_flights) + '_new.dat')
			#print "Capacities saved as", _result_dir + '/trajectories/capacities/' + G.name + '_capacities_rec_rej' + str(target_rejected_flights) + '_new.dat' 
			
			if zone in targets_eff_per_ACC.keys():
				for eff_target in targets_eff_per_ACC[zone]:
					for i in range(n_iter):
						counter(i, n_iter, message="Doing simulations...")
						name_results = name_sim(name_G) + '_eff_' + str(eff_target) + '_rej' + str(target_rejected_flights) + '_new_' + str(i) + '.dat'
						with silence(True):
							trajs, stats = generate_traffic(deepcopy(G), save_file=_result_dir + '/trajectories/M1/' + name_results,
												record_stats_file=_result_dir + '/trajectories/M1/' + name_results.split('.dat')[0] + '_stats.dat',
												file_traffic=_result_dir + "/networks/" + name_G + '_flights_selected.pic',
												put_sectors=True,
												remove_flights_after_midnight=True,
												capacity_factor=capacity_factor,
												rectificate={'eff_target':eff_target, 'inplace':False, 'hard_fixed':False, 'remove_nodes':True, 'resample_trajectories':True}
			boundary = list(all_shapes[country]['boundary'][0].exterior.coords)
			assert boundary[0]==boundary[-1]

			with open(result_dir + '/trajectories/bounds/' + G.name + '_bound_latlon.dat', 'w') as f:
				for x, y in boundary:
					f.write(str(x) + '\t' + str(y) + '\n')

			# --------------------------------------------------------------------------------------

			paras_control = {'bootstrap_mode':True, 'bootstrap_only_time':True, 'ACtot':ACtot}
			#print "Finding best capacity factor..."
			#capacity_factor, rejected_flights, H = find_good_scaling_capacity(G, result_dir + "/networks/" + name_G + '_flights_selected.pic', 
			#	target=target_rejected_flights,  silent=True, **paras_control)
			#print "Found best capacity factor:", capacity_factor, "(rejected fraction", rejected_flights, "of flights)"
			
			write_down_capacities(G, save_file=result_dir + '/trajectories/capacities/' + G.name + '_capacities_no_target_rej.dat')
			
			for i in range(n_iter):
				counter(i, n_iter, message="Doing simulations...")
				name_results = name_sim(name_G) + '_rej' + str(target_rejected_flights) + '_ACtot' + str(ACtot) + '_' + str(i) + '.dat'
				
				with silence(True):

					trajs, stats = generate_traffic(deepcopy(G), save_file= result_dir + '/trajectories/M1/' + name_results,
										record_stats_file=result_dir + '/trajectories/M1/' + name_results.split('.dat')[0] + '_stats.dat',
										file_traffic=result_dir + "/networks/" + name_G + '_flights_selected.pic',
										put_sectors=True,
										remove_flights_after_midnight=True,
										capacity_factor=1.,
										**paras_control)
				#print "Ratio rejected:", stats['rejected_flights']/float(stats['flights'])