资源简介

c++代码 解决车辆调度问题 遗传算法

资源截图

代码片段和文件信息

#include “ga.h“
main()
{   
    outfile.open(“result.dat“ios::out);
InitializeIE();     //Import
outfile<<“\n ----------------------------------------------------- “;
outfile<<“\n The numbers of Import=“<        <<“\n The loading vehicle probility=“<        <<“\n The VehicleLoad=“<    <<“\n The vehicle speed=“<    <<“\n The max generation=“<    <<“\n The early exit probility=“< outfile<<“\n ----------------------------------------------------- “;
InitializeData();   //parameter
InitializeReport(); //print parameter
InitializeMemory();  //初始oldpop
gen=0;
Initializepop();
if (avgfitness/maxfitness success=false;
else success=true;
while((gen {
gen++;
select();
generate();
ComputeFitness(newpop);
Statistics(newpop);
Report();
p1=oldpop;
oldpop=newpop;
newpop=p1;
}// end while 结束遗传操作
outfile<<“\n ----------------THE BEST PATH IS----------------- “;
outfile<<“\n -----------------------------------------------------\n “;
for (int j=0;j outfile< outfile<<“\n ----------------------------------------------------- “;
outfile<<“\n ----------------------------------------------------- “;
for (j=0;j {
delete[] oldpop[j].chrom;
oldpop[j].chrom=0;
delete[] newpop[j].chrom;
newpop[j].chrom=0;
//delete[] p1[j].chrom;
// p1[j].chrom=0;
}
delete[] bestfit.chrom;
bestfit.chrom=0;
delete[] oldpop;
    oldpop=0;
delete[] newpop;
    newpop=0;
p1=0;
delete[] dd;
dd=0;
delete[] ff;
ff=0;
delete[] PtrIP;
PtrIP=0;
return 0;
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2015-08-04 20:37  程序\
     目录           0  2015-08-04 20:37  程序\Debug\
     文件      614443  2005-06-15 13:35  程序\Debug\ga.exe
     文件      865640  2005-06-15 13:35  程序\Debug\ga.ilk
     文件      429324  2005-06-15 13:35  程序\Debug\ga.obj
     文件     2542892  2005-06-15 13:35  程序\Debug\ga.pch
     文件     1180672  2005-06-15 13:35  程序\Debug\ga.pdb
     文件           0  2005-06-27 08:32  程序\Debug\result.dat
     文件       91136  2005-06-15 13:35  程序\Debug\vc60.idb
     文件      118784  2005-06-15 13:35  程序\Debug\vc60.pdb
     文件        1730  2005-06-15 13:43  程序\ga.cpp
     文件        3469  2005-06-15 13:43  程序\ga.dsp
     文件         529  2005-06-15 13:43  程序\ga.dsw
     文件       18802  2005-06-20 16:53  程序\ga.h
     文件       58368  2005-06-15 13:43  程序\ga.ncb
     文件       48640  2005-06-15 13:43  程序\ga.opt
     文件        1083  2005-06-15 13:35  程序\ga.plg
     文件        2708  2005-06-15 13:29  程序\head.h
     文件       49912  2005-06-15 13:38  程序\result.dat
     文件       47963  2005-06-17 09:52  程序\result1.txt

评论

共有 条评论