Skip to content

User specified initial population #24

@ababaritECN

Description

@ababaritECN

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;
		}
		(...)
	}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions