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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? form1.cs

?? 遺傳算法求解車輛路徑問題
?? CS
字號:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

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

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

			//
			// TODO: 在 InitializeComponent 調用后添加任何構造函數代碼
			//
		}

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

		#region Windows 窗體設計器生成的代碼
		/// <summary>
		/// 設計器支持所需的方法 - 不要使用代碼編輯器修改
		/// 此方法的內容。
		/// </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(264, 16);
			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(208, 72);
			this.outputTextBox.Multiline = true;
			this.outputTextBox.Name = "outputTextBox";
			this.outputTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Both;
			this.outputTextBox.Size = new System.Drawing.Size(248, 200);
			this.outputTextBox.TabIndex = 1;
			this.outputTextBox.Text = "";
			// 
			// Form1
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(680, 326);
			this.Controls.Add(this.outputTextBox);
			this.Controls.Add(this.button1);
			this.Name = "Form1";
			this.Text = "Form1";
			this.ResumeLayout(false);

		}
		#endregion

		/// <summary>
		/// 應用程序的主入口點。
		/// </summary>
		[STAThread]
		static void Main() 
		{
			Application.Run(new Form1());
		}
		public class pp                            //此程序是2002年6月的計算機集成制造系統的程序的改進
		{
			public int cityNum=50;//原始的城市數
			public int cNumber=51;//插入站點后的城市數
			public int vehicleNumber=5;
			public int vehicleCapacity=160;// 車的容量
			public int maxTime=1000;//maximize iteration;
			public int popSize=5;//maximize population
			public int jrand;//creative randomnumber
			public int bestChroms;
			public double pCross=0.85;// probability of chrom crossover
			public double pMutation=0.03;// probability of chrom mutation
			public double[] oldrand=new double[200];
		}
        pp disp=new pp();
		private void calculate(ref double[] distance,ref double[] demand,ref double[] polarAngle)
		{
			int[] xcoordate={30,37,49,52,20,40,21,17,31,52,51,42,31,5,12,36,52,27,17,13,57,62,42,16,8,7,27,30,43,58,58,
								37,38,46,61,62,63,32,45,59,5,10,21,5,30,39,32,25,25,48,56};
			int[] ycoordate={40,52,49,64,26,30,47,63,62,33,21,41,32,25,42,16,41,23,33,13,58,42,57,57,52,38,68,48,67,48,
								27,69,46,10,33,63,69,22,35,15,6,17,10,64,15,10,39,32,55,28,37};
			int[] initdemand={0,7,30,16,9,21,15,19,23,11,5,19,29,23,21,10,15,3,41,9,28,8,8,16,10,28,7,15,
								 14,6,19,11,12,23,26,17,6,9,15,14,7,27,13,11,16,10,5,25,17,18,10};
			for(int i=0;i<disp.cNumber;i++)
			{
				for(int j=0;j<disp.cNumber;j++)
				{
					distance[i*disp.cNumber+j]=Math.Sqrt(Math.Pow((xcoordate[i]-xcoordate[j]),2)+Math.Pow((ycoordate[i]-
						ycoordate[j]),2));
				}
				demand[i]=initdemand[i];
			}
			int[] polarXCoordate=new int[disp.cityNum];
			int[] polarYCoordate=new int[disp.cityNum];
			for(int i=1;i<xcoordate.Length;i++)
			{
				polarXCoordate[i-1]=xcoordate[i]-xcoordate[0];
				polarYCoordate[i-1]=ycoordate[i]-ycoordate[0];
			}
			for(int i=0;i<polarXCoordate.Length;i++)
			{
				double polar;
				polar=Math.Pow(polarXCoordate[i],2)+Math.Pow(polarYCoordate[i],2);
				if((polarXCoordate[i]>=0)&&(polarYCoordate[i]>=0))
				{
					polarAngle[i]=Math.Asin(polarYCoordate[i]/polar)*360/Math.PI;
				}
				if((polarXCoordate[i]<0)&&(polarYCoordate[i]>=0))
				{
					polarAngle[i]=180-Math.Asin(polarYCoordate[i]/polar)*360/Math.PI;
				}
				if((polarXCoordate[i]<0)&&(polarYCoordate[i]<0))
				{
					polarAngle[i]=180-Math.Asin(polarYCoordate[i]/polar)*360/Math.PI;
				}
				if((polarXCoordate[i]>=0)&&(polarYCoordate[i]<0))
				{
					polarAngle[i]=360+Math.Asin(polarYCoordate[i]/polar)*360/Math.PI;
				}
			}
		}
		private void quickSort(ref double[] distance,int startPos,int endPos)
		{
			int i,j;
			double number;
			number=distance[startPos];
			i=startPos;
			j=endPos;
			
			while(i<j)
			{
				while((distance[j]>=number)&&(i<j))
				{
					--j;
				}
				distance[i]=distance[j];
				while((distance[i]<=number)&&(i<j))
				{
					++i;
				}
				distance[j]=distance[i];
			}
			distance[i]=number;
			if(i-1>startPos)
			{
				quickSort(ref distance,startPos,i-1);
			}
			if(endPos>i+1)
			{
				quickSort(ref distance,i+1,endPos);
			}
		}
		pp initp=new pp();
		private void initiation(double[] distance,double[] demand,ref int[] numberOfVehicle,
			ref int[,,] routeLength,ref int[,,] chroms)
		{
			for(int i=0;i<chroms.GetLength(0);i++)
			{
				double[] cost=new double[initp.cNumber];
				double[] beforeOfquickSort=new double[initp.cNumber];
				int[] customerIndex=new int[initp.cNumber];
				int[] tempChroms=new int[initp.cityNum];
				Random randNumber=new Random();//create a new start point
				int firstCustomer;
				firstCustomer=randNumber.Next(1,initp.cNumber);
				for(int j=1;j<cost.Length;j++)
				{
					cost[j]=distance[firstCustomer*initp.cNumber+j];
                    beforeOfquickSort[j]=cost[j];
				}
                quickSort(ref cost,1,initp.cNumber-1);
				
				for(int j=1;j<cost.Length;j++)
				{
					for(int k=1;k<cost.Length;k++)
					{
						if((cost[j]-beforeOfquickSort[k]<1e-5)&&(cost[j]-beforeOfquickSort[k]>-1e-5))
						{
							customerIndex[j]=k;
							beforeOfquickSort[k]=-1;
							break;
						}
					}
				}
				
				int unroutedCustomerOfNumber=initp.cNumber;
				int routedCustomer=0;
				int routeOfNumber=0;
				while(routedCustomer<initp.cityNum)
				{
					double totalVehicleCapacity=0.0;
					bool reapeatCapacity=false;
					int startNumberOfCustomer;
					if(unroutedCustomerOfNumber>3)
					{
						startNumberOfCustomer=3;
					}
					else 
					{
						startNumberOfCustomer=unroutedCustomerOfNumber-1;
					}
					for(int k=1;k<=startNumberOfCustomer;k++)
					{
                        totalVehicleCapacity+=demand[customerIndex[k]];
						if(totalVehicleCapacity>=initp.vehicleCapacity)
						{
							reapeatCapacity=true;
							break;
						}
                        routedCustomer++;
	                    routeLength[i,routeOfNumber,0]++;
						chroms[i,numberOfVehicle[i],routeLength[i,routeOfNumber,0]]=customerIndex[k];
						tempChroms[k]=customerIndex[k];
					}

					double[] tempCost=new double[initp.cityNum];
					for(int k=4;k<unroutedCustomerOfNumber;k++)
					{
						for(int j=1;j<k-1;j++)
						{
							tempCost[j]=distance[customerIndex[j]*initp.cNumber+customerIndex[k]]
								+distance[customerIndex[k]*initp.cNumber+customerIndex[j+1]]
								-distance[customerIndex[j]*initp.cNumber+customerIndex[j+1]];
						}
						tempCost[k-1]=distance[customerIndex[1]*initp.cNumber+customerIndex[k]]
							+distance[customerIndex[k]*initp.cNumber+customerIndex[k-1]]
							-distance[customerIndex[1]*initp.cNumber+customerIndex[k-1]];
						double minimize;
						int flag=1;
						minimize=tempCost[1];
						for(int t=2;t<k;t++)
						{
							if(minimize-tempCost[t]>1e-8)
							{
								minimize=tempCost[t];
								flag=t;
							}
						}
						totalVehicleCapacity+=demand[customerIndex[k]];
						if(totalVehicleCapacity>=initp.vehicleCapacity)
						{
							reapeatCapacity=true;
							break;
						}
						if(flag<k-1)
						{
							routedCustomer++;
                            routeLength[i,routeOfNumber,0]++;
							chroms[i,numberOfVehicle[i],flag+1]=customerIndex[k];
							for(int t=flag+2;t<=k;t++)
							{
								chroms[i,numberOfVehicle[i],t]=tempChroms[t-1];
							}
						}
						else
						{
							routeLength[i,routeOfNumber,0]++;
							routedCustomer++;
							chroms[i,numberOfVehicle[i],flag+1]=customerIndex[k];
						}
						for(int t=1;t<=k;t++)
						{
							tempChroms[t]=chroms[i,numberOfVehicle[i],t];
						}
					}
//                    outputTextBox.Text+="routLength="+routeLength[i,routeOfNumber,0]+" ";
//                    outputTextBox.Text+="numberOfVehicle="+numberOfVehicle[i]+" ";
					if(reapeatCapacity==true)
					{   
						numberOfVehicle[i]++;
						
						int[] unSelectCustomer=new int[initp.cityNum];
						int unSelectNumber=1;
						
						for(int t=routeLength[i,routeOfNumber,0]+1;t<unroutedCustomerOfNumber;t++)
						{
							unSelectCustomer[unSelectNumber++]=customerIndex[t];
						}
						routeOfNumber=numberOfVehicle[i];
                        unroutedCustomerOfNumber=initp.cNumber-routedCustomer;
						Random reapeatRandNumber=new Random();
						int reapeatNewRoute;
						reapeatNewRoute=unSelectCustomer[reapeatRandNumber.Next(1,unroutedCustomerOfNumber)];
						double[] newCost=new double[unroutedCustomerOfNumber];
						double[] newBeforeOfquickSort=new double[unroutedCustomerOfNumber];
						for(int j=1;j<newCost.Length;j++)
						{
							newCost[j]=distance[reapeatNewRoute*initp.cNumber+unSelectCustomer[j]];
							newBeforeOfquickSort[j]=newCost[j];
						}
						quickSort(ref newCost,1,unroutedCustomerOfNumber-1);
						for(int j=1;j<newCost.Length;j++)
						{
							for(int k=1;k<newCost.Length;k++)
							{
								if((newCost[j]-newBeforeOfquickSort[k]<1e-5)&&(newCost[j]-newBeforeOfquickSort[k]>-1e-5))
								{
									customerIndex[j]=unSelectCustomer[k];
									newBeforeOfquickSort[k]=-1;
									break;
								}
							}
						}
//						for(int j=1;j<newCost.Length;j++)
//						{
//							outputTextBox.Text+=customerIndex[j]+" ";
//						}
//                        outputTextBox.Text+="*************************************";
					}
				}
			}
		}
        pp displayp=new pp();
		private void button1_Click(object sender, System.EventArgs e)
		{
			outputTextBox.Text="";
			double[] distance=new double[displayp.cNumber*displayp.cNumber];
			double[] demand=new double[displayp.cNumber];
			double[] polarAngle=new double[displayp.cityNum];
			calculate(ref distance,ref demand,ref polarAngle);
			
			int[,,] chroms=new int[displayp.popSize,2*displayp.vehicleNumber,displayp.cityNum];
			int[] numberOfVehicle=new int[2*displayp.vehicleNumber];
			int[,,] routeLength=new int[displayp.popSize,2*displayp.vehicleNumber,1];
            initiation(distance,demand,ref numberOfVehicle, ref routeLength,ref chroms);
            outputTextBox.Text+="*************************************";
//			for(int i=0;i<chroms.GetLength(0);i++)
//			{
//				for(int j=0;j<=numberOfVehicle[i];j++)
//				{
//					for(int k=1;k<=routeLength[i,j,0];k++)
//					{
//                         outputTextBox.Text+=chroms[i,j,k]+" ";
//					}
//                    outputTextBox.Text+="*************************************";
//				}
//				outputTextBox.Text+="/////////////////////////////////////";
//			}
		}
	}
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
青青草视频一区| 亚洲午夜国产一区99re久久| 中文字幕一区二区三| 成人免费高清在线观看| 国产三级精品在线| 91啪在线观看| 亚洲狠狠爱一区二区三区| 4438亚洲最大| 精品系列免费在线观看| 国产香蕉久久精品综合网| fc2成人免费人成在线观看播放| 成人欧美一区二区三区| 欧美日韩国产天堂| 六月丁香综合在线视频| 欧美国产在线观看| 91国在线观看| 久久成人免费网| 国产精品入口麻豆九色| 欧美午夜精品久久久久久孕妇 | 国产福利一区二区三区在线视频| 国产日韩视频一区二区三区| 91免费版在线| 久久精品国内一区二区三区| 中文字幕一区二区三区四区 | 麻豆一区二区三区| 久久久久久久久久久久久久久99 | 久久69国产一区二区蜜臀| 国产欧美一区二区精品性| 91久久香蕉国产日韩欧美9色| 日韩av中文字幕一区二区| 国产亚洲视频系列| 国产视频一区二区在线观看| 91色.com| 国产一区二区成人久久免费影院| 亚洲日穴在线视频| 日韩精品一区二区三区视频播放| 99精品国产91久久久久久| 麻豆一区二区在线| 亚洲激情校园春色| 久久精品欧美一区二区三区麻豆| 色综合久久久网| 国产乱子轮精品视频| 亚洲午夜精品在线| 国产精品国产a级| 欧美成人性福生活免费看| 色狠狠综合天天综合综合| 国产精品一区二区男女羞羞无遮挡| 亚洲综合在线免费观看| 久久精品欧美日韩| 欧美年轻男男videosbes| www.性欧美| 国产成人综合亚洲91猫咪| 奇米影视7777精品一区二区| 亚洲乱码国产乱码精品精小说 | 91麻豆精品91久久久久久清纯| 不卡一区在线观看| 国内精品在线播放| 蜜臀av一级做a爰片久久| 亚洲自拍偷拍欧美| 中文字幕一区二区三区在线观看 | 久久先锋资源网| 日韩一区二区三区免费看 | 午夜精品一区在线观看| 亚洲欧美国产高清| 国产精品久久久久永久免费观看| 精品成人私密视频| 日韩精品一区在线| 欧美一卡二卡三卡| 欧美裸体bbwbbwbbw| 欧美私人免费视频| 欧美日韩一区中文字幕| 欧美在线免费播放| 91麻豆国产精品久久| 9i在线看片成人免费| 99精品久久只有精品| 91丝袜高跟美女视频| 99视频精品在线| 91麻豆福利精品推荐| 色综合色综合色综合| 欧洲国产伦久久久久久久| 色婷婷亚洲一区二区三区| 色偷偷一区二区三区| 欧美日韩在线电影| 欧美乱妇20p| 欧美一级欧美三级在线观看| 91精品久久久久久久久99蜜臂| 欧美一级电影网站| 精品国产伦一区二区三区观看方式 | 国产精品灌醉下药二区| 成人免费一区二区三区视频 | 亚洲va欧美va人人爽| 日韩中文字幕不卡| 麻豆成人av在线| 国产一区在线不卡| 成人美女在线观看| 色国产综合视频| 91精品国产综合久久精品app| 日韩一区二区电影在线| 久久先锋影音av鲁色资源| 国产精品国产三级国产有无不卡| 亚洲免费观看高清在线观看| 日韩国产欧美在线播放| 国产一区二区三区不卡在线观看| 成人久久18免费网站麻豆| 色天天综合久久久久综合片| 91精品国产91热久久久做人人 | 一本一本大道香蕉久在线精品| 欧美性生活影院| 日韩欧美国产一区在线观看| 国产欧美日韩久久| 亚洲二区视频在线| 国产精品综合在线视频| 色婷婷久久综合| 欧美α欧美αv大片| 中文字幕一区视频| 日本sm残虐另类| 99精品国产热久久91蜜凸| 欧美电视剧免费全集观看| 亚洲精品国产第一综合99久久| 免费黄网站欧美| 色综合天天做天天爱| 日韩免费观看高清完整版在线观看| 亚洲欧洲色图综合| 久久精品国产亚洲高清剧情介绍 | 三级欧美在线一区| 高清成人免费视频| 7777女厕盗摄久久久| 成人欧美一区二区三区视频网页 | 99精品一区二区| 日韩欧美在线网站| 国产久卡久卡久卡久卡视频精品| 91啪九色porn原创视频在线观看| 日韩美女视频在线| 一区二区三区日本| 国产a久久麻豆| 欧美一区二区三区在线看| 国产精品久久久一本精品| 久88久久88久久久| 欧美三区在线视频| ㊣最新国产の精品bt伙计久久| 极品美女销魂一区二区三区| 欧美性一二三区| 亚洲欧美日韩国产另类专区| 国产精品羞羞答答xxdd| 欧美一区二区私人影院日本| 亚洲综合成人在线| 97精品电影院| 国产精品国产三级国产a | 久久99国产乱子伦精品免费| 在线中文字幕不卡| 《视频一区视频二区| 丁香五精品蜜臀久久久久99网站| 精品福利一区二区三区免费视频| 日韩精品久久久久久| 欧美日韩国产一区| 亚洲狠狠爱一区二区三区| 色综合久久久久网| 亚洲人123区| 色丁香久综合在线久综合在线观看| 中文字幕一区二区三区视频| 欧美精品一区二区三区蜜桃视频| 日本大胆欧美人术艺术动态| 欧美伦理电影网| 日本美女视频一区二区| 日韩一区二区三免费高清| 秋霞电影网一区二区| 91精品婷婷国产综合久久性色| 亚洲欧美激情插| 色狠狠桃花综合| 亚洲美女精品一区| 91国产视频在线观看| 一区二区三区不卡视频| 91麻豆高清视频| 亚洲美女区一区| 欧美少妇xxx| 日韩激情av在线| 日韩精品一区二区三区蜜臀| 国产一区二区精品久久| 中文字幕精品三区| 91视频在线看| 婷婷开心激情综合| 欧美一区二区福利视频| 国产综合色视频| 中文天堂在线一区| 91成人网在线| 蜜桃精品视频在线| 国产欧美日本一区二区三区| jlzzjlzz亚洲女人18| 亚洲国产日韩一区二区| 在线播放一区二区三区| 狠狠色丁香久久婷婷综| 中文字幕va一区二区三区| 一本色道久久综合亚洲91| 午夜国产精品影院在线观看| 日韩欧美的一区二区| 成人h动漫精品一区二区| 一卡二卡欧美日韩| 日韩精品资源二区在线| 粉嫩高潮美女一区二区三区| 一区二区激情小说|