Prześlij pliki do ''
This commit is contained in:
parent
4856536a29
commit
ffb1c10a03
11
gmo.cpp
11
gmo.cpp
@ -251,7 +251,7 @@ void crossover(string * parents,string * nextGen,int parentsNumber,int nextGenSi
|
||||
}
|
||||
|
||||
|
||||
string * genetic_algorithm(string * population, int populationSize, int parentsNumber) {
|
||||
void genetic_algorithm(string * population, int populationSize, int parentsNumber,string * outcome, int outcomeSize) {
|
||||
|
||||
int iteration,i;
|
||||
for(iteration=0;iteration<5;iteration++) {
|
||||
@ -269,23 +269,22 @@ string * genetic_algorithm(string * population, int populationSize, int parentsN
|
||||
}
|
||||
delete[] nextGen;
|
||||
}
|
||||
string vegetablesForPlanting[20];
|
||||
ranking(population,vegetablesForPlanting,populationSize,20);
|
||||
|
||||
return vegetablesForPlanting;
|
||||
ranking(population,outcome,populationSize,outcomeSize);
|
||||
}
|
||||
int main() {
|
||||
|
||||
|
||||
srand(time(0));
|
||||
|
||||
int i;
|
||||
int populationSize = 500;
|
||||
int parentsNumber = populationSize - 5;
|
||||
string * population = new string[populationSize];
|
||||
|
||||
generatePopulation(population,populationSize);
|
||||
|
||||
string * vegetablesForPlanting = genetic_algorithm(population, populationSize, parentsNumber);
|
||||
string vegetablesForPlanting[20];
|
||||
genetic_algorithm(population, populationSize, parentsNumber,vegetablesForPlanting, 20);
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user