//-----------------------------------------------------------------------------------------------------------
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());
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
ga.rar (28个子文件)
ga1
main.sln 901B
main
main.csproj 4KB
Form1.cs 71KB
bin
Debug
main.vshost.exe 6KB
encode.xml 488B
main.exe 52KB
seeda.xml 6KB
main.pdb 88KB
obj
Debug
main.Properties.Resources.resources 180B
main.Form1.resources 180B
Refactor
main.exe 52KB
TempPE
main.pdb 88KB
main.Form_encode.resources 180B
main.csproj.GenerateResource.Cache 964B
main.csproj.FileList.txt 285B
Properties
Resources.Designer.cs 3KB
Settings.settings 249B
Resources.resx 5KB
Settings.Designer.cs 1KB
AssemblyInfo.cs 1KB
Program.cs 463B
Form_encode.designer.cs 10KB
Form1.Designer.cs 31KB
Form_encode.cs 3KB
Form1.resx 6KB
Form_encode.resx 6KB
bak.txt 3KB
main.suo 23KB
共 28 条
- 1
资源评论
- qq_289384372017-09-26压根就没有东西
handong163
- 粉丝: 0
- 资源: 26
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功