C语言多元函数的遗传算法 遗传算法多元函数最优解原理( 六 )


best_val = population[POPSIZE].fitness;
fprintf(galog, "\n%5d,%6.3f, %6.3f, %6.3f \n\n", generation,
best_val, avg, stddev);
}
/**************************************************************/
/* Main function: Each generation involves selecting the best */
/* members, performing crossovermutation and then*/
/* evaluating the resulting population, until the terminating */
/* condition is satisfied*/
/**************************************************************/
void main(void)
{
int i;
if ((galog = fopen("galog.txt","w"))==NULL)
{
exit(1);
}
generation = 0;
fprintf(galog, "\n generationbestaveragestandard \n");
fprintf(galog, " numbervalue fitnessdeviation \n");
initialize();
evaluate();
keep_the_best();
while(generationMAXGENS)
{
generation++;
select();
crossover();
mutate();
report();
evaluate();
elitist();
}
fprintf(galog,"\n\n Simulation completed\n");
fprintf(galog,"\n Best member: \n");
for (i = 0; iNVARS; i++)
{
fprintf (galog,"\n var(%d) = %3.3f",i,population[POPSIZE].gene[i]);
}
fprintf(galog,"\n\n Best fitness = %3.3f",population[POPSIZE].fitness);
fclose(galog);
printf("Success\n");
}
/***************************************************************/
【C语言多元函数的遗传算法 遗传算法多元函数最优解原理】C语言多元函数的遗传算法的介绍就聊到这里吧,感谢你花时间阅读本站内容 , 更多关于遗传算法多元函数最优解原理、C语言多元函数的遗传算法的信息别忘了在本站进行查找喔 。

推荐阅读