亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? form1.cs

?? 模擬退火和遺傳算法混和求解車輛路徑問題的程序
?? CS
字號:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace WindowsApplication24zhang
{
	/// <summary>
	/// Form1 的摘要說明。
	/// </summary>
	public class Form1 : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Button button1;
		private System.Windows.Forms.TextBox outputTextBox;
		/// <summary>
		/// 必需的設(shè)計器變量。
		/// </summary>
		private System.ComponentModel.Container components = null;

		public Form1()
		{
			//
			// Windows 窗體設(shè)計器支持所必需的
			//
			InitializeComponent();

			//
			// TODO: 在 InitializeComponent 調(diào)用后添加任何構(gòu)造函數(shù)代碼
			//
		}

		/// <summary>
		/// 清理所有正在使用的資源。
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if (components != null) 
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows 窗體設(shè)計器生成的代碼
		/// <summary>
		/// 設(shè)計器支持所需的方法 - 不要使用代碼編輯器修改
		/// 此方法的內(nèi)容。
		/// </summary>
		private void InitializeComponent()
		{
			this.button1 = new System.Windows.Forms.Button();
			this.outputTextBox = new System.Windows.Forms.TextBox();
			this.SuspendLayout();
			// 
			// button1
			// 
			this.button1.Location = new System.Drawing.Point(272, 32);
			this.button1.Name = "button1";
			this.button1.Size = new System.Drawing.Size(112, 32);
			this.button1.TabIndex = 0;
			this.button1.Text = "display";
			this.button1.Click += new System.EventHandler(this.button1_Click);
			// 
			// outputTextBox
			// 
			this.outputTextBox.Location = new System.Drawing.Point(216, 96);
			this.outputTextBox.Multiline = true;
			this.outputTextBox.Name = "outputTextBox";
			this.outputTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Both;
			this.outputTextBox.Size = new System.Drawing.Size(264, 200);
			this.outputTextBox.TabIndex = 1;
			this.outputTextBox.Text = "";
			// 
			// Form1
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(680, 342);
			this.Controls.Add(this.outputTextBox);
			this.Controls.Add(this.button1);
			this.Name = "Form1";
			this.Text = "Form1";
			this.ResumeLayout(false);

		}
		#endregion

		/// <summary>
		/// 應(yīng)用程序的主入口點。
		/// </summary>
		[STAThread]
		static void Main() 
		{
			Application.Run(new Form1());
		}

		public class pp                            //此程序是2002年6月的計算機集成制造系統(tǒng)的程序的改進
		{
			public int cityNum=30;//原始的城市數(shù)
			public int cNumber=31;//插入站點后的城市數(shù)
			public int vehicleNumber=10;
			public int vehicleCapacity=20;// 車的容量
			public int maxTime=200;//maximize iteration;
			public int popSize=80;//maximize population
			public int jrand;//creative randomnumber
			public int bestChroms;
			public double pCross=0.8;// probability of chrom crossover
			public double pMutation=0.03;// probability of chrom mutation
			public double[] oldrand=new double[100];
		}
		pp initPop=new pp();
		private void InitCity(pp initPop,ref int[,] chroms,Random seed)
		{
			int i,j;
			int number;
			Random rand=new Random(seed.Next());
			for(i=0;i<chroms.GetLength(0);i++)
			{
				for(j=0;j<chroms.GetLength(1);j+=3)
				{
					number=rand.Next(3);
					if(number==0)
					{
						chroms[i,j]=1;
						chroms[i,j+1]=0;
						chroms[i,j+2]=0;
					}
					if(number==1)
					{
						chroms[i,j]=0;
						chroms[i,j+1]=1;
						chroms[i,j+2]=0;
					}
					if(number==2)
					{
						chroms[i,j]=0;
						chroms[i,j+1]=0;
						chroms[i,j+2]=1;
					}
				}
			}
		}
		pp distancePop=new pp();
		private void cityDistance(pp distancePop,ref int[,] distance)
		{
			int[,] initDistance={{0,8,17},{0,4,8},{0,5,10},{0,12,23},{0,7,14},{0,6,13},{0,5,10},{0,6,12},{0,7,14},{0,3,6}};
			for(int i=0;i<distance.GetLength(0);i++)
			{
				for(int j=0;j<distance.GetLength(1);j++)
				{
					distance[i,j]=initDistance[i,j];
				}
			}
		}

		pp fitnessPop=new pp();
		private void chromsFitness(pp fitnessPop,int[,] chroms,int[,] distance,ref double[] cost,ref double[] fitness)
		{

			for(int i=0;i<chroms.GetLength(0);i++)
			{
				double totalCost=0.0;
				int t=0;
				for(int j=0;j<chroms.GetLength(1);j+=3)
				{
					t=j/3;
					if(j==0)
					{
						if(chroms[i,j]==1)
						{
							totalCost+=distance[t,2];
						}
						if(chroms[i,j+1]==1)
						{
							totalCost+=distance[t,1];
						}
						if(chroms[i,j+2]==1)
						{
							totalCost+=distance[t,0];
						}
					}
					else
					{
						if(chroms[i,j]==1)
						{
							totalCost+=(distance[t,2]+distance[t-1,2]*chroms[i,j-3]+distance[t-1,1]*chroms[i,j-2]);
						}
						if(chroms[i,j+1]==1)
						{
							totalCost+=(distance[t,1]+distance[t-1,2]*chroms[i,j-3]+distance[t-1,1]*chroms[i,j-2]);
						}
						if(chroms[i,j+2]==1)
						{
							totalCost+=(distance[t,0]+distance[t-1,2]*chroms[i,j-3]+distance[t-1,1]*chroms[i,j-2]);
						}
					}
				}
				cost[i]=totalCost;
				fitness[i]=1.0/cost[i];
			}
		}

		pp testrand1=new pp();
		void randomize1(ref pp testrand1,int seed)
		{
			int i;
			Random randomNumber=new Random(seed);
			for(i=0;i<testrand1.popSize;i++)
			{
				testrand1.oldrand [i]=randomNumber.NextDouble();
			}
			testrand1.jrand=0;
		}

		pp testrand2=new pp();
		double random1(ref pp testrand2,int seed)
		{
			if(testrand2.jrand>=testrand2.popSize)
			{
				testrand2.jrand=0;
				randomize1(ref testrand2,seed);
			}
			return testrand2.oldrand[testrand2.jrand++];
		}
		pp selectPop=new pp();
		public int chromsSelect(pp selectPop,double[] fitness,int seed)//染色體的選擇操作
		{
			int i;
			double sumfitness;
			double maxmizeFitness;
			sumfitness=fitness[0];
			maxmizeFitness=fitness[0];
			for(i=1;i<fitness.Length;i++)
			{
				if(fitness[i]-maxmizeFitness>1e-6)
					selectPop.bestChroms=i;
				sumfitness+=fitness[i];
			}
				
			double rand1,partsum=0.0;
			int j=0;

			randomize1(ref selectPop,seed);
			rand1=random1(ref selectPop,seed)*sumfitness;
			do
			{
				partsum=partsum+fitness[j];
				j=j+1;
			}while((partsum-rand1<1e-6)&&(j<selectPop.popSize));
			return j-1;
		}
		//染色體的交叉
		pp popCross=new pp();
		private void chromsCross(double[] fitness, pp popCross,ref int[,] chroms,Random seed)
		{
			int i,j;
			int t1,t2;
			
			Random rand=new Random(seed.Next());
			for(i=0;i<chroms.GetLength(0);i+=2)
			{
				if(i==0)
				{
					t1=chromsSelect(popCross,fitness,seed.Next());
					t2=popCross.bestChroms;
				}
				else
				{
					t1=chromsSelect(popCross,fitness,seed.Next());
					t2=chromsSelect(popCross,fitness,seed.Next());
				}
				double rpc;
				rpc=rand.NextDouble();
				if(rpc<=popCross.pCross)
				{
					int[] temp1=new int[popCross.cityNum];
					int[] temp2=new int[popCross.cityNum];
					int cross1,cross2;
					for(j=0;j<chroms.GetLength(1);j++)
					{
						temp1[j]=chroms[t1,j];
						temp2[j]=chroms[t2,j];
					}
					int crossnumber=rand.Next(9);
                    cross1=crossnumber*3;
					cross2=rand.Next(crossnumber+1,10)*3;
					for( j=cross1;j<cross2;j++)
					{
						chroms[t1,j]=temp2[j];
						chroms[t2,j]=temp1[j];
					}
				}
			}
		}
		pp popMutation=new pp();
		private void chromsMutation(pp popMutation,ref int[,] chroms,Random seed)
		{
			int i;
			int m1;
			int[] temp=new int[popMutation.cityNum];
			Random rand =new Random(seed.Next());
			for(i=0;i<chroms.GetLength(0);i++)
			{
				if(rand.NextDouble()<=popMutation.pMutation)
				{
					m1=rand.Next(9)*3;
					if(chroms[i,m1]==1)
					{
						chroms[i,m1+2]=1;
						chroms[i,m1]=0;
					}
					if(chroms[i,m1+1]==1)
					{
						chroms[i,m1+2]=1;
						chroms[i,m1+1]=0;
					}	
				}
			}
		}
		private void chromsGeneration()
		{
			pp chromsPopulation=new pp();
			Random seed=new Random();
			int[,] chroms=new int[chromsPopulation.popSize,chromsPopulation.cityNum];
			InitCity(chromsPopulation,ref chroms,seed);
//			for(int i=0;i<chroms.GetLength(0);i++)
//			{
//				for(int j=0;j<chroms.GetLength(1);j++)
//				{
//					if(j%3==0)
//					{
//						outputTextBox.Text+="/";
//					}
//					outputTextBox.Text+=chroms[i,j];
//				}
//               outputTextBox.Text+="*********************************************";
//			}

			int[,] distance=new int[10,3];
			cityDistance(chromsPopulation,ref distance);

			double[] fitness=new double[chromsPopulation.popSize];
			double[] cost=new double[chromsPopulation.popSize];
			chromsFitness(chromsPopulation,chroms,distance,ref cost,ref fitness);
			chromsCross(fitness,chromsPopulation,ref chroms,seed);
			chromsMutation(chromsPopulation,ref chroms,seed);
			chromsFitness(chromsPopulation,chroms,distance,ref cost,ref fitness);

			int best=0;
			int bestGeneration=0;
			double bestSolution=cost[0];
			int[] bestChroms=new int[chromsPopulation.cityNum];

			for(int i=0;i<cost.Length;i++)
			{
				if(cost[i]-bestSolution<1e-6)
				{
					bestSolution=cost[i];
					best=i;
				}
			}
			for(int j=0;j<bestChroms.Length;j++)
			{
				bestChroms[j]=chroms[best,j];
			}
		
			int times;
			times=0;
			while(times<chromsPopulation.maxTime)
			{
				chromsCross(fitness,chromsPopulation,ref chroms,seed);
				chromsMutation(chromsPopulation,ref chroms,seed);
				chromsFitness(chromsPopulation,chroms,distance,ref cost,ref fitness);
				bool repeat=false;
				for(int i=0;i<cost.Length;i++)
				{
					if(cost[i]-bestSolution<1e-6)
					{
						bestSolution=cost[i];
						best=i;
						repeat=true;
					}
				}
				if(repeat==true)
				{
					for(int j=0;j<bestChroms.Length;j++)
					{
						bestChroms[j]=chroms[best,j];
					}
					bestGeneration=times;
				}
				times++;
			}
			outputTextBox.Text+="\n"+"bestSolution="+bestSolution+" ";
			outputTextBox.Text+="*********************************************";
			for(int i=0;i<bestChroms.Length;i++)
			{
				if(i%3==0)
				{
					outputTextBox.Text+="/";
				}
				outputTextBox.Text+=bestChroms[i]+" ";
			}
			outputTextBox.Text+="*********************************************";
			outputTextBox.Text+="bestGeneration="+bestGeneration+" ";
		}
		private void button1_Click(object sender, System.EventArgs e)
		{
			outputTextBox.Text="";
			System.DateTime d = System.DateTime.Now;
			chromsGeneration();
			outputTextBox.Text+=System.DateTime.Now.Subtract(d)+" ";
		}
	}
}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久欧美一区二区| 国产一区二区0| 久久精品国产77777蜜臀| gogogo免费视频观看亚洲一| 欧美一区二区三区四区五区| 午夜精品久久久久久久| 风间由美性色一区二区三区| 91精品国产综合久久精品图片 | 日韩午夜三级在线| 亚洲激情欧美激情| 高清国产午夜精品久久久久久| 91精品黄色片免费大全| 亚洲欧美激情插 | 蜜桃视频在线观看一区二区| 91精彩视频在线| 国产区在线观看成人精品| 秋霞电影网一区二区| 在线观看91精品国产入口| 日韩久久一区二区| 成人午夜又粗又硬又大| 久久精品亚洲麻豆av一区二区| 卡一卡二国产精品| 欧美不卡一区二区三区四区| 亚洲va国产va欧美va观看| 色综合久久久久久久久| 亚洲青青青在线视频| 91视频在线观看| 1区2区3区欧美| 91视频一区二区三区| 中文字幕一区二区三区蜜月| 7777精品久久久大香线蕉| 樱桃视频在线观看一区| 色综合天天天天做夜夜夜夜做| 国产精品麻豆视频| av爱爱亚洲一区| 亚洲精品日韩综合观看成人91| 91尤物视频在线观看| 亚洲欧美一区二区三区极速播放 | 26uuu色噜噜精品一区二区| 免费成人性网站| 精品精品国产高清一毛片一天堂| 麻豆成人久久精品二区三区红 | 成人爱爱电影网址| 欧美韩国日本综合| 91在线观看免费视频| 亚洲高清不卡在线观看| 欧美一区二区在线视频| 国产精品自拍av| 成人欧美一区二区三区| 色综合天天综合网天天狠天天| 亚洲一区二区三区在线| 91精品国产色综合久久| 国产一区二区视频在线| 国产精品久久久久久久久晋中 | 国产精品日日摸夜夜摸av| 99免费精品在线| 亚洲成人激情自拍| 日韩美女天天操| zzijzzij亚洲日本少妇熟睡| 亚洲精品国产精华液| 日韩亚洲欧美在线观看| 成人高清av在线| 亚洲大片在线观看| 国产亚洲一本大道中文在线| av在线综合网| 美女免费视频一区| 日韩理论片一区二区| 日韩免费电影网站| 91在线视频观看| 免费观看成人鲁鲁鲁鲁鲁视频| 中文在线免费一区三区高中清不卡| 91视频观看视频| 国内外成人在线视频| 亚洲日本护士毛茸茸| 欧美xxxxx牲另类人与| 一本大道久久a久久精品综合| 欧美aaa在线| 亚洲人123区| 久久亚洲影视婷婷| 欧美在线观看视频一区二区| 国产盗摄精品一区二区三区在线| 丝袜诱惑制服诱惑色一区在线观看| 久久精品亚洲麻豆av一区二区| 欧美日韩国产另类一区| 成人app软件下载大全免费| 理论电影国产精品| 亚洲国产欧美一区二区三区丁香婷| 国产色产综合色产在线视频| 欧美一区二区三区免费在线看| 一本大道久久精品懂色aⅴ| 国产成人激情av| 久久99精品国产91久久来源| 爽爽淫人综合网网站| 亚洲三级在线免费观看| 国产欧美一区二区精品性色| 欧美mv日韩mv| 日韩丝袜美女视频| 欧美日本免费一区二区三区| 一本一本大道香蕉久在线精品| 高清日韩电视剧大全免费| 国产一区二区三区综合| 麻豆国产精品官网| 青草国产精品久久久久久| 亚洲制服欧美中文字幕中文字幕| 国产精品日日摸夜夜摸av| 久久久精品黄色| 久久亚洲捆绑美女| 久久色中文字幕| 久久久综合激的五月天| 久久综合丝袜日本网| 精品免费国产一区二区三区四区| 欧美日韩在线观看一区二区| 在线精品视频一区二区三四 | 成人aa视频在线观看| 国产 日韩 欧美大片| 成人18精品视频| 94-欧美-setu| 欧美吻胸吃奶大尺度电影| 欧美日韩aaa| 日韩免费一区二区| 精品国内片67194| 国产亚洲欧洲一区高清在线观看| 久久久久久99久久久精品网站| 国产三级久久久| 综合激情成人伊人| 亚洲激情欧美激情| 日日摸夜夜添夜夜添国产精品| 首页综合国产亚洲丝袜| 美女视频网站久久| 国产揄拍国内精品对白| 国产999精品久久久久久绿帽| 国产iv一区二区三区| 91亚洲永久精品| 6080日韩午夜伦伦午夜伦| 欧美成人三级电影在线| 国产精品妹子av| 亚洲国产精品久久久男人的天堂| 日韩激情在线观看| 国产福利不卡视频| 一本色道久久综合亚洲91| 欧美丰满一区二区免费视频| www久久精品| 一区二区三区四区视频精品免费 | 国产日韩在线不卡| 亚洲激情综合网| 久久 天天综合| 色域天天综合网| 欧美一区二区黄| 韩国v欧美v日本v亚洲v| 成人午夜视频福利| 欧美另类z0zxhd电影| 国产欧美一区二区精品婷婷 | 亚洲一区免费视频| 久久精品99国产精品| 成人av片在线观看| 欧美肥妇free| 国产精品成人网| 老鸭窝一区二区久久精品| 99vv1com这只有精品| 欧美成人欧美edvon| 一区二区三区在线观看动漫| 国产一区二区三区最好精华液| 色欧美乱欧美15图片| 国产日产精品1区| 日本视频中文字幕一区二区三区| 成人激情小说乱人伦| 精品国产亚洲一区二区三区在线观看| 日韩毛片在线免费观看| 国产精品系列在线播放| 在线综合视频播放| 亚洲人成人一区二区在线观看| 精品一区中文字幕| 欧美日韩一二三区| 亚洲伦理在线免费看| 本田岬高潮一区二区三区| 精品国产3级a| 美脚の诱脚舐め脚责91| 精品婷婷伊人一区三区三| 最新国产精品久久精品| 国产精品一区在线| 精品国产乱码久久久久久闺蜜| 午夜电影网亚洲视频| 欧美性受xxxx黑人xyx性爽| 中文字幕av免费专区久久| 久国产精品韩国三级视频| 91精品国产欧美日韩| 午夜在线电影亚洲一区| 欧美亚日韩国产aⅴ精品中极品| 亚洲欧洲精品一区二区三区| 粉嫩高潮美女一区二区三区| 久久精品一区二区三区不卡 | 88在线观看91蜜桃国自产| 一区二区成人在线视频| 97se亚洲国产综合在线| 亚洲天堂精品在线观看| 91丨porny丨户外露出| 亚洲视频中文字幕| 91黄色激情网站| 亚洲精品视频免费看| 欧美综合欧美视频|