while total_round > 0: ## caculate goal_index if round_index == 0: goal_selection_flag = numpy.ones(7) searched_violation_pattern.append(goal_selection_flag) search_round = search_round_list[int(sum(goal_selection_flag))] # search_round = 50 if total_round < search_round: search_round = total_round # total_round = total_round - search_round Configuration = TurnRightConfigure(goal_selection_flag, population, search_round, round_index, target_dir) vars_file_name = Configuration.file_dir_var results_file_name = Configuration.file_dir_eval else: # print(round_index, sum(pattern_count)) fileList = os.listdir(results_file_name) fileList.sort() for i in range(population * search_round): textname = results_file_name + '/' + fileList[i] # print(textname) result = numpy.loadtxt(textname) evaluation.append(result) goal_flag = numpy.zeros((7), dtype=int)
for row in csv_file: priority_list.append(row) priority_list = [[float(x) for x in row] for row in priority_list] priority_list = numpy.array(priority_list) violation_pattern_to_search = [] pattern_count = numpy.zeros(priority_list.shape[0]) evaluation = [] searched_violation_pattern = [] for round_idx in range(total_round): if round_idx == 0: goal_index = 0 Configuration = TurnRightConfigure(goal_index, population, search_round, target_dir, round_idx) vars_file_name = Configuration.file_dir_var results_file_name = Configuration.file_dir_eval searched_violation_pattern.append(goal_index) else: fileList = os.listdir(results_file_name) fileList.sort() for i in range(population * search_round): textname = results_file_name + '/' + fileList[i] # print(textname) result = numpy.loadtxt(textname) evaluation.append(result) goal_flag = numpy.zeros((7), dtype=int) for j in range(7): if result[j] < target_value_threshold[j]:
# searched_violation_pattern = numpy.loadtxt("searched_violation_pattern_0.txt") while total_second > 0: # for round_index in range (total_round): if round_index == 0: goal_index = 0 goal_selection_flag = priority_list[goal_index] if total_second < search_second: search_round = total_second # total_round = total_round - search_round # total_round = total_round - search_round Configuration = TurnRightConfigure(goal_index, population, target_dir, round_index) vars_file_name = Configuration.file_dir_var results_file_name = Configuration.file_dir_eval searched_violation_pattern.append(goal_index) else: fileList = os.listdir(results_file_name) fileList.sort() for i in range(population * search_round): textname = results_file_name + '/' + fileList[i] # print(textname) result = numpy.loadtxt(textname) evaluation.append(result) goal_flag = numpy.zeros((7), dtype=int) for j in range(7): if result[j] < target_value_threshold[j]:
# -*- coding: utf-8 -*- from multiprocessing import Pool from Settings.TurnRightConfigure import TurnRightConfigure from MyScenario.TurnRight import create_run_scenario_turnright_random import os import time data_folder = os.getcwd() + '/TurnRight_Datalog_' + str( time.strftime("%Y_%m_%d_%H")) if not os.path.exists(data_folder): os.mkdir(data_folder) if __name__ == "__main__": target_dir = data_folder Configuration = TurnRightConfigure(target_dir) pool = Pool(processes=Configuration.ProcessNum) res_l = [] for i in range(Configuration.maxIterations): res = pool.apply_async(create_run_scenario_turnright_random, (Configuration, )) res_l.append(res) # print("==============================>") pool.close() pool.join()