Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User specified initial population #24

Open
ababaritECN opened this issue Apr 17, 2024 · 0 comments
Open

User specified initial population #24

ababaritECN opened this issue Apr 17, 2024 · 0 comments

Comments

@ababaritECN
Copy link

Hi,
I believe that the code does not work properly when providing a used defined initial population.
According to my tests, whatever the size of the user defined population, it adds a number of additional random individuals equal to the size of the population. This is because N_add is not modified.
Here is quick fix:

void init_population(thisGenerationType &generation0)
	{
		(...)
		// Evaluate and add the user defined population
		for(const GeneType &solution:user_initial_solutions)
		{
			thisChromosomeType X;
			X.genes=solution;
			bool accepted=init_population_try(generation0,X,-1);
			//** Fix
			if (accepted) {N_add-=1;} // User defined individual is accepted, thus we must reduce by 1 the number of random individuals to be added.
			//** End of fix
			(void) accepted; // unused parametre
			if(generation0.chromosomes.size()>=population)
				break;
		}
		(...)
	}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant