Esempio n. 1
0
			std::string XMLParserPoco::getChildElementInnerText(std::string name)
			{
				if(_documentLoaded && _selectedNode != nullptr && name != "")
				{
					if(selectChildByName(name))
					{
						std::string innerText = getInnerText();
						selectParent();
						return innerText;
					}
				}
				return "";
			}
Esempio n. 2
0
void doReproduce(){
	struct Chromosome XoverPop[4]; // Small population of 4 individuals
	XoverPop[0] = Population[selectParent()]; // Select parent 1
	XoverPop[1] = Population[selectParent()]; // Select parent 2
	/*** Crossover ***/
	int GeneNr;
	for(GeneNr = 0; GeneNr < GENETIC_PURSUERS;GeneNr++){ // Take one gene from each parent
		XoverPop[2].gene[GeneNr  ] = XoverPop[0].gene[GeneNr];
		XoverPop[3].gene[GeneNr  ] = XoverPop[1].gene[GeneNr];
		XoverPop[2].gene[GeneNr+1] = XoverPop[1].gene[GeneNr+1];
		XoverPop[3].gene[GeneNr+1] = XoverPop[0].gene[GeneNr+1];
		GeneNr++;
	}
	/*** Mutation ***/
	doMutation(&XoverPop[2]); // Mutate the generated individual
	doMutation(&XoverPop[3]); // Mutate the generated individual
	/*** sort to add best individes ***/
	int i = 0;
	for(i=2;i<4;i++)
		calculateFitness(&XoverPop[i]); // Calculate fitness for children
	sortPopulation(XoverPop, 4); // Sort after fitness
	addToNewPopulation(XoverPop[0]); // Add best individual to new population
	addToNewPopulation(XoverPop[1]); // Add second best individual to new population
}