遗传算法求Y=X*X最大值,求指导.
来源:学生作业帮 编辑:搜搜考试网作业帮 分类:英语作业 时间:2024/06/04 19:18:56
遗传算法求Y=X*X最大值,求指导.
/* This is a simple genetic algorithm implementation where the\x05\x05 */
/* evaluation function takes positive values only and the\x05\x05 */
/* fitness of an individual is the same as the value of the\x05\x05 */
/* objective function\x05\x05\x05\x05\x05\x05\x05 */
//
void main(void)
{
\x05int\x05i;
\x05if ((galog = fopen("galog.txt","w"))==NULL)
\x05{
\x05\x05exit(1);
\x05}
\x05generation = 0;
\x05fprintf(galog,"\n generation best average standard \n");
\x05fprintf(galog," number value fitness deviation \n");
\x05initialize();
\x05evaluate();
\x05keep_the_best();
\x05while (generation < MAXGENS)
\x05{
\x05\x05generation++;
\x05\x05select();
\x05\x05crossover();
\x05\x05mutate();
\x05\x05evaluate();
\x05\x05report();
\x05\x05//evaluate();
\x05\x05elitist();
\x05}
\x05fprintf(galog,"\n\n Simulation completed\n");
\x05fprintf(galog,"\n Best member:\n");
\x05for (i = 0; i < NVARS; i++)
\x05{
\x05\x05fprintf (galog,"\n var(%d) = %3.6f",i,population[POPSIZE].gene[i]);
\x05}
\x05fprintf(galog,"\n\n Best fitness = %3.6f",population[POPSIZE].fitness);
\x05fclose(galog);
\x05printf("Success\n");
}
/* evaluation function takes positive values only and the\x05\x05 */
/* fitness of an individual is the same as the value of the\x05\x05 */
/* objective function\x05\x05\x05\x05\x05\x05\x05 */
//
void main(void)
{
\x05int\x05i;
\x05if ((galog = fopen("galog.txt","w"))==NULL)
\x05{
\x05\x05exit(1);
\x05}
\x05generation = 0;
\x05fprintf(galog,"\n generation best average standard \n");
\x05fprintf(galog," number value fitness deviation \n");
\x05initialize();
\x05evaluate();
\x05keep_the_best();
\x05while (generation < MAXGENS)
\x05{
\x05\x05generation++;
\x05\x05select();
\x05\x05crossover();
\x05\x05mutate();
\x05\x05evaluate();
\x05\x05report();
\x05\x05//evaluate();
\x05\x05elitist();
\x05}
\x05fprintf(galog,"\n\n Simulation completed\n");
\x05fprintf(galog,"\n Best member:\n");
\x05for (i = 0; i < NVARS; i++)
\x05{
\x05\x05fprintf (galog,"\n var(%d) = %3.6f",i,population[POPSIZE].gene[i]);
\x05}
\x05fprintf(galog,"\n\n Best fitness = %3.6f",population[POPSIZE].fitness);
\x05fclose(galog);
\x05printf("Success\n");
}
遗传算法求Y=X*X最大值,求指导.
求C代码:遗传算法求函数最大值f(x)=x^2 x 从0到30
遗传算法matlab编程求函数最大值?
利用遗传算法求解区间[0,31]上的二次函数y=x*x的最大值
利用遗传算法求解区间【0,31】上的二次函数y=x*x的最大值
基于MATLAB的遗传算法程序 对函数y=(x)1^2-(x)2^2+3 求解全局最大值.
请教用遗传算法求函数f(x)=2sinx+1/3sin(3x)的最大值的matlab程序.
求最大值时,遗传算法相对梯度算法的优势
遗传算法求解请问在MALAB中怎么找出需要的遗传算法数据比如:1【问题】求f(x)=x+10*sin(5x)+7*cos
y=|x+1|/x^2+2求函数最大值
求函数y=2x+1/x 的最大值
遗传算法求函数最大值,总能得到收敛结果吗?