91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 117KB
    文件類(lèi)型: .rar
    金幣: 2
    下載: 1 次
    發(fā)布日期: 2021-06-23
  • 語(yǔ)言: C#
  • 標(biāo)簽: C#??tsp??遺傳算法??

資源簡(jiǎn)介

C#tsp遺傳算法;里面有測(cè)試數(shù)據(jù),包含中國(guó)30個(gè)城市的坐標(biāo)數(shù)據(jù)。

資源截圖

代碼片段和文件信息

using?System;
using?System.Collections.Generic;
using?System.Text;
using?System.IO;
???namespace?TSP
{
//數(shù)據(jù)文件格式:
//第一行有兩個(gè)數(shù)據(jù):矩陣行數(shù)??矩陣列數(shù)
//接下來(lái)的行的數(shù)據(jù):行??列??該行該列的元素值
//注意數(shù)據(jù)與數(shù)據(jù)之間是用空格隔開(kāi)的,沒(méi)有給出的矩陣的某些位置的值用0來(lái)代替

class?TestClass
{
public?static?void?TestGa(string?DataFileName)
{
Ga?ga=new?Ga();
ga.GaTsp(DataFileName);
}
public?static?void?TestGa2()
{
RandNumber?rands=new?RandNumber();
Ga?ga=new?Ga();
int?n=36;
double?[]CostMat=new?double[nn];
double?[]vec=new?double[n2];
for(int?i=0;i {
vec[i0]=rands.Rand01();
vec[i1]=rands.Rand01();
}
for(int?i=0;i for(int?j=0;j {
if(i==j)?CostMat[ij]=0.0;
else
{
double?s1=vec[i0]-vec[j0];
double?s2=vec[i1]-vec[j1];
CostMat[ij]=Math.Sqrt(s1*s1+s2*s2);
}
}
ga.GaTsp(CostMat);
LSMat.SaveDataFile(@“d:\c#\tsp\out01.txt“CostMat2);
}
public?static?void?TestLSMat()
{
int?n=6;
double?[]mat=new?double[nn];
for(int?i=0;i for(int?j=0;j {
mat[ij]=(double)(i+1)*(j+1);
}
LSMat.SaveDataFile(@“D:\eeee1.txt“mat1);
double?[]mat2;
mat2=LSMat.LoadDoubleDataFile(@“D:\eeee1.txt“);
for(int?i=0;i {
????????????????Console.Write(“{0}:?“i);
for(int?j=0;j {
Console.Write(“{0}??“mat2[ij]);
}
Console.Write(“\n“);
}
}
public?static?void?Main(string[]?args)
{
????????????TestGa(@“d:\c#\Tsp\data02.txt“);

???????????//?TestGa2();
//TestLSMat();
}
}
/*?下面是TSP問(wèn)題的遺傳算法實(shí)現(xiàn)類(lèi)
?*?*/
class?Ga
{
private?Floyd?minfloyd=new?Floyd();//創(chuàng)建Floyd類(lèi)
private?double?[]Distance;
private?int?N;?//群體規(guī)模
private?int?Length;?//個(gè)體長(zhǎng)度
private?double?Pc;?//交叉概率
private?double?Pm;?//變異概率
private?int?MaxGene;?//最大迭代代數(shù)
public?int?[]MinIndividual;?//當(dāng)前代的最好個(gè)體指針
public?double?MinValue;?//到當(dāng)前代至最好個(gè)體的適應(yīng)度值
private?int?[]Buf;??//群體矩陣
private?int?[]Buf1;?//中間群體矩陣
private?int?[]Buf2;?//中間群體矩陣
private?double?[]FitV;?//群體Buf的每個(gè)個(gè)體的適應(yīng)度
private?double?[]FitV1;//群體Buf1的每個(gè)個(gè)體的適應(yīng)度
private?double?[]FitV2;//群體Buf2的每個(gè)個(gè)體的適應(yīng)度
private?int[]?ppindivi;?//交叉算子中用到的中轉(zhuǎn)向量
private?int[]?pp;//交叉算子中用到的中轉(zhuǎn)向量
private?RandNumber?randnumber=new?RandNumber();//創(chuàng)建一個(gè)隨機(jī)數(shù)類(lèi)
//類(lèi)初始化函數(shù)
public?void?Initialize(string?DataFileNameint?N1double?Pc1double?Pm1int?MaxGene1)
{
minfloyd.MinFloyd(DataFileName);
Distance=minfloyd.GetDistance();
for(int?i=0;i Distance[ii]=0;
N=N1;
Length=Distance.GetLength(0);
Pc=Pc1;
Pm=Pm1;
MaxGene=MaxGene1;
MinValue=double.MaxValue;
Buf=new?int[NLength];
Buf1=new?int[NLength];
Buf2=new?int[NLength];
FitV=new?double[N];
FitV1=new?double[N];
FitV2=new?double[N];
MinIndividual=new?int[Length];
int?[]individual;
for(int?i=0;i {
individual=randnumber.Ran

?屬性????????????大小?????日期????時(shí)間???名稱(chēng)
-----------?---------??----------?-----??----

?????文件??????24213??2011-04-24?19:58??C#tsp遺傳算法\tsp\data01.txt

?????文件????????356??2011-04-25?15:15??C#tsp遺傳算法\tsp\data02.txt

?????文件????????287??2011-04-24?20:07??C#tsp遺傳算法\tsp\eeee1.txt

?????文件??????24371??2011-04-24?13:07??C#tsp遺傳算法\tsp\out01.txt

?????文件??????27093??2011-04-24?21:03??C#tsp遺傳算法\ycshuanfa\Backup\tsp\Program.cs

?????文件???????1153??2011-04-24?02:25??C#tsp遺傳算法\ycshuanfa\Backup\tsp\Properties\AssemblyInfo.cs

?????文件???????1940??2011-04-24?02:31??C#tsp遺傳算法\ycshuanfa\Backup\tsp\tsp.csproj

?????文件???????6418??2011-04-24?21:24??C#tsp遺傳算法\ycshuanfa\Backup\ycshuanfa\Program.cs

?????文件???????1165??2011-04-24?01:47??C#tsp遺傳算法\ycshuanfa\Backup\ycshuanfa\Properties\AssemblyInfo.cs

?????文件???????1952??2011-04-24?01:47??C#tsp遺傳算法\ycshuanfa\Backup\ycshuanfa\ycshuanfa.csproj

?????文件???????1379??2011-04-24?03:03??C#tsp遺傳算法\ycshuanfa\Backup\ycshuanfa.sln

????..A..H.?????14336??2011-04-25?15:20??C#tsp遺傳算法\ycshuanfa\Backup\ycshuanfa.suo

?????文件??????28672??2011-04-24?21:03??C#tsp遺傳算法\ycshuanfa\tsp\bin\Debug\tsp.exe

?????文件??????46592??2011-04-24?21:03??C#tsp遺傳算法\ycshuanfa\tsp\bin\Debug\tsp.pdb

?????文件??????14328??2011-10-28?15:57??C#tsp遺傳算法\ycshuanfa\tsp\bin\Debug\tsp.vshost.exe

?????文件????????490??2007-07-21?01:33??C#tsp遺傳算法\ycshuanfa\tsp\bin\Debug\tsp.vshost.exe.manifest

?????文件????????102??2011-10-28?15:57??C#tsp遺傳算法\ycshuanfa\tsp\obj\Debug\tsp.csproj.FileListAbsolute.txt

?????文件??????28672??2011-04-24?21:03??C#tsp遺傳算法\ycshuanfa\tsp\obj\Debug\tsp.exe

?????文件??????46592??2011-04-24?21:03??C#tsp遺傳算法\ycshuanfa\tsp\obj\Debug\tsp.pdb

?????文件????????443??2011-04-25?15:15??C#tsp遺傳算法\ycshuanfa\tsp\obj\tsp.csproj.FileListAbsolute.txt

?????文件??????27093??2011-04-24?21:03??C#tsp遺傳算法\ycshuanfa\tsp\Program.cs

?????文件???????1153??2011-04-24?02:25??C#tsp遺傳算法\ycshuanfa\tsp\Properties\AssemblyInfo.cs

?????文件???????2111??2011-10-28?15:56??C#tsp遺傳算法\ycshuanfa\tsp\tsp.csproj

?????文件???????5632??2005-12-08?14:51??C#tsp遺傳算法\ycshuanfa\tsp2\bin\Debug\tsp2.vshost.exe

?????文件????????108??2011-04-24?03:19??C#tsp遺傳算法\ycshuanfa\tsp2\obj\tsp2.csproj.FileListAbsolute.txt

?????文件???????9603??2011-04-24?03:02??C#tsp遺傳算法\ycshuanfa\tsp2\Program.cs

?????文件???????1155??2011-04-24?02:53??C#tsp遺傳算法\ycshuanfa\tsp2\Properties\AssemblyInfo.cs

?????文件???????1942??2011-04-24?03:02??C#tsp遺傳算法\ycshuanfa\tsp2\tsp2.csproj

?????文件???????2854??2011-10-28?15:56??C#tsp遺傳算法\ycshuanfa\UpgradeLog.xml

?????文件??????20480??2011-04-25?15:15??C#tsp遺傳算法\ycshuanfa\ycshuanfa\bin\Debug\ycshuanfa.exe

............此處省略49個(gè)文件信息

評(píng)論

共有 條評(píng)論

相關(guān)資源