# get chromeosome chromosome_list = [str(x) for x in s.chromosome_bits] chromosome = ''.join(chromosome_list) with open(testing_output_path, 'a', encoding='utf-8') as f: print("testing_output_path :", testing_output_path) #sys.exit(0) f.write( "\n==========================================================================================\n" ) f.write("name: {}\n".format(s.name)) f.write(chromosome + '\n') f.write('profit: {}\n'.format(s.profit)) f.write('fitness: {}\n'.format(s.fitness)) f.write('stock return..\n') f.write('-------------------------------------------------\n') for result_tuple in sorted(s.classification_result_list, key=lambda x: x[0]): f.write( str(result_tuple[0]) + ',' + str(result_tuple[1]) + '\n') f.write('-------------------------------------------------\n') f.write('feature_dict\n') json.dump(s.feature_dict, f, indent=4) f.write( "\n==========================================================================================\n" ) # clear the solution for buy or sell Solution._clear()