How to use the deap.tools.sortNondominated function in deap

To help you get started, we’ve selected a few deap examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nilinswap / neuro-evolution / main1_nll_mse_misc_com.py View on Github external
anost = logbook.stream
		liso = [item.rstrip() for item in anost.split("\t")]
		mse = float(liso[3])

		print(anost)
		stri += anost + '\n'
		print("generation done")
		# file_ob.write(str(logbook.stream))
		# print(len(pop))
		# file_ob.close()

	time5 = time.time()
	print("Overall time", time5 - time4)
	#print(stri)
	print( ' ------------------------------------src done------------------------------------------- ')
	fronts = tools.sortNondominated(pop_src, len(pop_src))

	toolbox.register("mutate", mymutate_tar)
	pareto_front = fronts[0]
	print(pareto_front)
	print("Pareto Front: ")
	st='\n\n'
	pareto_log_fileo = open("./log_folder/log_pareto_main1_nll_mse_misc_com"+str(NGEN)+".txt", "a")
	pareto_logo = open("pareto_front.txt", "a")
	sti = 'source\n\n'
	for i in range(len(pareto_front)):
		print(pareto_front[i].fitness.values)
		st += str(pareto_front[i].fitness.values)+'\n'
		for obj_val in pareto_front[i].fitness.values:
			sti += str(obj_val)+' '
		sti += '\n'
	pareto_log_fileo.write(st + '\n')
github nilinswap / neuro-evolution / main1_perc_nll_mse_misc_com.py View on Github external
anost = logbook.stream
		liso = [item.rstrip() for item in anost.split("\t")]
		mse = float(liso[3])

		print(anost)
		stri += anost + '\n'
		print("generation done")
		# file_ob.write(str(logbook.stream))
		# print(len(pop))
		# file_ob.close()

	time5 = time.time()
	print("Overall time", time5 - time4)
	#print(stri)
	print( ' ------------------------------------src done------------------------------------------- ')
	fronts = tools.sortNondominated(pop_src, len(pop_src))

	toolbox.register("mutate", mymutate_tar)
	pareto_front = fronts[0]
	print(pareto_front)
	print("Pareto Front: ")
	st='\n\n'
	pareto_log_fileo = open("./log_folder/log_pareto_main1_perc_nll_mse_misc_com"+str(NGEN)+".txt", "a")
	to_add_lis = []
	for i in range(len(pareto_front)):
		print(pareto_front[i].fitness.values)
		if(pareto_front[i].fitness.values[-1] <= indim*outdim+2):
			st += str(pareto_front[i].fitness.values)+'\n'
			to_add_lis.append(pareto_front[i])
	pareto_log_fileo.write(st +str(len(to_add_lis))+ '\n\n')
	pareto_log_fileo.close()
	diff = MU - len(to_add_lis)
github nilinswap / neuro-evolution / main.py View on Github external
anost = logbook.stream
		liso = [item.rstrip() for item in anost.split("\t")]
		mse = float(liso[3])

		print(anost)
		stri += anost + '\n'
		print("generation done")
	# file_ob.write(str(logbook.stream))
	# print(len(pop))
	# file_ob.close()

	time5 = time.time()
	print("Overall time", time5 - time4)
	# print(stri)
	print(' ------------------------------------src done------------------------------------------- ')
	fronts = tools.sortNondominated(pop_src, len(pop_src))

	toolbox.register("mutate", mymutate_tar)
	pareto_front = fronts[0]
	print(pareto_front)
	print("Pareto Front: ")
	for i in range(len(pareto_front)):
		print(pareto_front[i].fitness.values)

	return pareto_front, logbook
github nilinswap / neuro-evolution / main1_perc_nll_mse_misc_com.py View on Github external
def test_it_without_bp():
	pop, stats = main()
	stringh = "_without_bp"
	fronts = tools.sortNondominated(pop, len(pop))
	if len(fronts[0]) < 30:
		pareto_front = fronts[0]
	else:

		pareto_front = random.sample(fronts[0], 30)
	print("Pareto Front: ")
	for i in range(len(pareto_front)):
		print(pareto_front[i].fitness.values)

	neter = Neterr(indim, outdim, n_hidden, random)

	print("\ntest: test on one with min validation error", neter.test_err(min(pop, key=lambda x: x.fitness.values[1])))
	tup = neter.test_on_pareto_patch(pareto_front)

	print("\n test: avg on sampled pareto set", tup[0], "least found avg", tup[1])
github nilinswap / neuro-evolution / postmidsem / codes / main_folder / glass / main_bp_without_clustring.py View on Github external
def test_it_without_bp():
    pop, stats = main()
    stringh = "_without_bp"
    fronts = tools.sortNondominated(pop, len(pop))
    if len(fronts[0]) < 30:
        pareto_front = fronts[0]
    else:

        pareto_front = random.sample(fronts[0], 30)
    print("Pareto Front: ")
    for i in range(len(pareto_front)):
        print(pareto_front[i].fitness.values)

    neter = Neterr(indim, outdim, n_hidden, np.random)

    print("\ntest: test on one with min validation error", neter.test_err(min(pop, key=lambda x: x.fitness.values[1])))
    tup = neter.test_on_pareto_patch(pareto_front)

    print("\n test: avg on sampled pareto set", tup[0], "least found avg", tup[1])
github nilinswap / neuro-evolution / main1_perc_nll_mse_misc_com.py View on Github external
def test_it_with_bp(play = 1,NGEN = 100, MU = 4*25, play_with_whole_pareto = 0):

	pop, stats = main( play = play, NGEN = NGEN, MU = MU)
	stringh = "_with_bp_approach2_perc_nll_mse_misc_com"+str(play)+"_"+str(NGEN)
	fronts = tools.sortNondominated(pop, len(pop))

	'''file_ob = open("./log_folder/log_for_graph.txt", "w+")
	for item in fronts[0]:
		st = str(item.fitness.values[0]) + " " + str(item.fitness.values[1])+"\n"
		file_ob.write( st )
	file_ob.close()'''


	if play_with_whole_pareto or len(fronts[0]) < 30 :
		pareto_front = fronts[0]
	else:

		pareto_front = random.sample(fronts[0], 30)

	print("Pareto Front: ")
	for i in range(len(pareto_front)):
github nilinswap / neuro-evolution / postmidsem / codes / main_folder / glass / main.py View on Github external
def test_it_without_bp():
    pop, stats = main(NGEN = 80 , MU = 4 * 25)
    stringh = "_without_bp"
    fronts = tools.sortNondominated(pop, len(pop))
    if len(fronts[0]) < 30:
        pareto_front = fronts[0]
    else:

        pareto_front = random.sample(fronts[0], 30)
    print("Pareto Front: ")
    for i in range(len(pareto_front)):
        print(pareto_front[i].fitness.values)

    neter = Neterr(indim, outdim, n_hidden, np.random)

    print("\ntest: test on one with min validation error", neter.test_err(min(pop, key=lambda x: x.fitness.values[1])))
    tup = neter.test_on_pareto_patch_correctone(pareto_front)

    print("\n test: avg on sampled pareto set", tup)