資源簡介
對于。NET開發平臺的,使用遺傳算法實現的項目有參考價值。
代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Text;
using?System.Windows.Forms;
//Download?by?http://www.codefans.net
namespace?main
{
????public?partial?class?Form1?:?Form
????{
????????public?Form1()
????????{
????????????InitializeComponent();
????????}
????????int?_Max_Value?=?31;//定義域上界
????????int?_Min_Value?=?0;//定義域下界
????????int?_chrom_Len?=?5;//染色體長度
????????int?_G_size?=?30;
????????int?_Evolution_Times?=?20;
????????int?_p_det?=?1;
????????double?_Mutation_Rate?=?0.02;
????????string[]?_source_G_Only_One;
????????int?_flag_source_only?=?0;
????????string[]?_old_G;?
????????string[]?_seleted_G;?//選擇到的種群
????????string[]?_new_G;?//交叉后的下一代
????????int[]?_old_value;?
????????double[]?_old_p;
????????double?_best_p?=?0;
????????string?_best_Individual;
????????int?_p_times?=?0;
????????const?int?_p_rate?=?5;
????????string[]?_p1_data;
????????string[]?_p2_data;
????????string[]?_p3_data;
????????string[]?_p4_data;
????????string[]?_p5_data;
????????string[]?_p6_data;
????????string[]?_p7_data;
????????bool?_Flag_Can_Draw_P1?=?false;
????????bool?_Flag_Can_Draw_P2?=?false;
????????bool?_Flag_Can_Draw_P3?=?false;
????????bool?_Flag_Can_Draw_P4?=?false;
????????bool?_Flag_Can_Draw_P5?=?false;
????????bool?_Flag_Can_Draw_P6?=?false;
????????bool?_Flag_Can_Draw_P7?=?false;
????????string[]?_old_G_1;
????????string[]?_old_G_2;
????????string[]?_new_G_1;
????????string[]?_new_G_2;
????????string[]?_select_G_1;
????????string[]?_select_G_2;
????????int[]?_cross_proj;
????????double[]?_seed?=?new?double[100];
????????int?_k_seed?=?0;
????????double?_best_func?=?0;
????????string?_best_all?=?““;
????????string?str_goal=““;
????????int?_sum_time?=?0;
????????int?_sum_1?=?0;
????????int?_sum_2?=?0;
????????int?_sum_3?=?0;
????????int?_sum_4?=?0;
????????int?_sum_5?=?0;
????????int?_sum_6?=?0;
????????int?_sum_7?=?0;
????????//-----------------------------------------------------------------------------------------------------------
????????private?void?_Init_PictureBox(int?mode)
????????{
????????????//-----------------------------------------------
????????????if?(mode?==?1)
????????????{
????????????????_p1_data?=?new?string[_p_times?_G_size];
????????????????//
????????????????pictureBox1.Width?=?_p_rate?*?(_Max_Value?-?_Min_Value?+?2)?*?_p_times;
????????????????pictureBox1.Height?=?_p_rate?*?(_G_size?+?2);
????????????}
????????????//-----------------------------------------------
????????????if?(mode?==?2)
????????????{
????????????????_p2_data?=?new?string[_p_times?_G_size];
????????????????//
????????????????pictureBox2.Width?=?_p_rate?*?(_Max_Value?-?_Min_Value?+?2)?*?_p_times;
????????????????pictureBox2.Height?=?_p_rate?*?(_G_size?+?2);
????????????????pictureBox2.Left?=?pictureBox1.Left;
????????????????pictureBox2.Top?=?pictureBox1
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
-----------?---------??----------?-----??----
???????????????172371????????????????????20
評論
共有 條評論