//-----------------------------------------------------------------------------------------------------------
private void Form1_Load(object sender, EventArgs e)
{
//fx=x^2
//x:0,30
//30=16+8+4+2+0
//30=11110
_old_G[0] = "01100";
_old_G[1] = "00001";
_old_G[2] = "00011";
_old_G[3] = "00101";
_Select();
_Cross_Over();
return;
//
int x1 = 12;
int x2 = 1;
int x3 = 3;
int x4 = 5;
string s1 = "01100";
string s2 = "00001";
string s3 = "00011";
string s4 = "00101";
double fm = func(x1) + func(x2) + func(x3) + func(x4);
double p1 = func(x1) / fm;
double p2 = func(x2) / fm;
double p3 = func(x3) / fm;
double p4 = func(x4) / fm;
//MessageBox.Show(p1.ToString() + "," + p2.ToString() + "," + p3.ToString() + "," + p4.ToString() + "," + (p1 + p2 + p3 + p4).ToString());
string[] chosen_str = new string[4];
// 选择
for (int i = 0; i <= 3; i++)
{
double p = get_rnd_double_from_0_to_1(GetRandomSeed());
if (p >= 0 && p < p1)
{
chosen_str[i] = s1;
// MessageBox.Show("12");
}
else
{
if (p >= p1 && p < p1 + p2)
{
chosen_str[i] = s2;
// MessageBox.Show("1");
}
else
{
if (p >= p1 + p2 && p < p1 + p2 + p3)
{
chosen_str[i] = s3;
// MessageBox.Show("3");
}
else
{
chosen_str[i] = s4;
// MessageBox.Show("5");
}
}
}
}
//MessageBox.Show(chosen_str[0]);
//交叉
int pos1 = get_rnd_int_from(0, 4, GetRandomSeed());
int pos2 = get_rnd_int_from(0, 4, GetRandomSeed());
string fa_1 = "";
string fa_2 = "";
string mo_1 = "";
string mo_2 = "";
for (int i = 0; i < pos1 + 1; i++)
{
fa_1 = fa_1 + s1[i].ToString();
mo_1 = mo_1 + s2[i].ToString();
}
for (int i = pos1 + 1; i <= 4; i++)
{
fa_2 = fa_2 + s1[i].ToString();
mo_2 = mo_2 + s2[i].ToString();
}
//MessageBox.Show(fa_1.ToString() + "," + fa_2.ToString());
string new_s1 = fa_1 + mo_2;
string new_s2 = mo_1 + fa_2;
byte b1 = Convert.ToByte(new_s1, 2);
byte b2 = Convert.ToByte(new_s2, 2);
MessageBox.Show(b1.ToString() + "," + b2.ToString());
}
没有合适的资源?快使用搜索试试~ 我知道了~
C#遗传算法(常用7种遗传算法源码实例)
共78个文件
cs:27个
exe:6个
resources:5个
4星 · 超过85%的资源 需积分: 50 584 下载量 60 浏览量
2011-03-31
23:55:33
上传
评论 8
收藏 426KB RAR 举报
温馨提示
该资源包含了常用的7种C#遗传算法源码实例集,和遗传算法C#五子棋游戏程序
资源推荐
资源详情
资源评论
收起资源包目录
c#遗传算法.rar (78个子文件)
c#遗传算法
遗传算法C#五子棋游戏程序
GoBangProject
GoBangProject.sln 929B
GoBangProject
structs
Chess.cs 1KB
ChessRule.cs 10KB
ChessPoint.cs 7KB
HistoryRecord.cs 705B
Form1.cs 7KB
bin
Debug
Release
五子棋.vshost.exe.manifest 490B
五子棋.vshost.exe 14KB
五子棋.exe 93KB
五子棋.pdb 86KB
obj
Debug
TempPE
Release
GoBangProject.Properties.Resources.resources 52KB
GoBangProject.csproj.GenerateResource.Cache 1002B
五子棋.exe 93KB
五子棋.pdb 86KB
GoBangProject.Form1.resources 4KB
TempPE
Properties.Resources.Designer.cs.dll 5KB
GoBangProject.csproj.FileListAbsolute.txt 1KB
Resources
white.gif 835B
black.gif 803B
head.JPG 3KB
chess.jpg 46KB
black.jpg 15KB
white.jpg 14KB
Funny.cs 3KB
Properties
Resources.Designer.cs 4KB
Settings.settings 249B
Resources.resx 7KB
Settings.Designer.cs 1KB
AssemblyInfo.cs 1KB
GeneticAlgorithm
AIOperator.cs 9KB
AIRule.cs 10KB
ProbabilityExcute.cs 1KB
TestCrossOver.cs 2KB
Genome.cs 4KB
GeneticAlgorithm.cs 9KB
CrossOver.cs 6KB
Program.cs 589B
Conf.cs 1KB
Form1.Designer.cs 18KB
Form1.resx 12KB
GoBangProject.csproj 5KB
favicon.ico 4KB
GoBangProject.suo 42KB
常用的7种C#遗传算法源码实例集
洪越源代码--更多免费精品商业源码.url 124B
ga1
main.sln 902B
main
main.csproj 4KB
Form1.cs 71KB
bin
Debug
main.vshost.exe 14KB
main.vshost.exe.manifest 490B
main.exe 43KB
main.pdb 80KB
obj
Debug
main.Properties.Resources.resources 180B
main.Form1.resources 180B
main.exe 43KB
TempPE
Properties.Resources.Designer.cs.dll 5KB
main.pdb 80KB
main.Form_encode.resources 180B
main.csproj.FileListAbsolute.txt 1023B
main.csproj.GenerateResource.Cache 911B
Properties
Resources.Designer.cs 3KB
Settings.settings 249B
Resources.resx 5KB
Settings.Designer.cs 1KB
AssemblyInfo.cs 1KB
Program.cs 500B
Form_encode.designer.cs 10KB
Form1.Designer.cs 31KB
Form_encode.cs 3KB
Form1.resx 6KB
Form_encode.resx 6KB
bak.txt 3KB
_UpgradeReport_Files
UpgradeReport.xslt 12KB
UpgradeReport_Plus.gif 71B
UpgradeReport.css 3KB
UpgradeReport_Minus.gif 69B
main.suo 23KB
UpgradeLog.XML 5KB
www.wei2008.com.txt 2KB
共 78 条
- 1
huangsong_265
- 粉丝: 0
- 资源: 10
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
- 5
- 6
前往页