• c语言算法练习题 > 解TSP问题的遗传算法C语言程序
  • 解TSP问题的遗传算法C语言程序

    免费下载 下载该文档 文档格式:DOC   更新时间:2005-11-01   下载次数:0   点击次数:2
    文档基本属性
    文档语言:Simplified Chinese
    文档格式:doc
    文档作者:lanway
    关键词:
    主题:
    备注:
    点击这里显示更多文档属性
    co_min=0;
    if((oldpop=(struct pp *)farmalloc(maxpop*sizeof(struct pp)))==NULL)
    {printf("memory requst fail!\n");exit(0);}
    if((dd=(float *)farmalloc(maxstring*maxstring*sizeof(float)))==NULL)
    {printf("memory requst fail!\n");exit(0);}
    if((newpop=(struct pp *)farmalloc(maxpop*sizeof(struct pp)))==NULL)
    {printf("memory requst fail!\n");exit(0);}
    if((p1=(struct pp *)farmalloc(sizeof(struct pp)))==NULL)
    {printf("memory requst fail!\n");exit(0);}
    for(k=0;k for(k=0;k printf("Enter Result Data Filename:");
    gets(fname);
    if((fp=fopen(fname,"w+"))==NULL)
    {printf("cannot open file\n");exit(0);}
    gen=0;
    randomize();
    initialize();
    fputs("this is result of the TSP problem:",fp);
    fprintf(fp,"city: %2d psize: %3d Ref.TSP_path: %f\n",lchrom,popsize,refpd);
    fprintf(fp,"Pc: %f Pm: %f Seed: %f\n",pcross,pmutation,seed);
    fprintf(fp,"X site:\n");
    for(k=0;k {if((k%16)==0) fprintf(fp,"\n");
    fprintf(fp,"%5d",x[k]);
    }
    fprintf(fp,"\n Y site:\n");
    for(k=0;kmaxold)
    {maxold=max;
    co_min=0;
    }
    fm[gen%200]=100.0*oldpop[maxpp].x/ff;
    report(gen,oldpop);
    gotoxy(30,25);
    ttt=clock()/18.2;
    tt=ttt/60;
    printf("Run Clock: %2d: %2d: %4.2f",tt/60,tt%60,ttt-tt*60.0);
    printf("Min=%6.4f Nm:%d\n",min,co_min);
    }while((genmaxold)
    {maxold=max;
    co_min=0;

    上一页下一页

  • 下载地址 (推荐使用迅雷下载地址,速度快,支持断点续传)
  • 免费下载 DOC格式下载
  • 您可能感兴趣的
  • pid算法c语言程序  c语言算法编程100例  c语言经典算法100例  c语言常用算法  c语言快速排序算法  c语言经典算法大全  c语言算法大全  c语言算法  c语言常用算法源代码