📄 frmparam.cs
字号:
this.sat.Name = "sat";
this.sat.Size = new System.Drawing.Size(104, 21);
this.sat.TabIndex = 55;
this.sat.Text = "20";
//
// label7
//
this.label7.Location = new System.Drawing.Point(192, 128);
this.label7.Name = "label7";
this.label7.TabIndex = 54;
this.label7.Text = "SA初始温度";
//
// gapm
//
this.gapm.Location = new System.Drawing.Point(32, 224);
this.gapm.Name = "gapm";
this.gapm.Size = new System.Drawing.Size(104, 21);
this.gapm.TabIndex = 59;
this.gapm.Text = "0.1";
//
// label6
//
this.label6.Location = new System.Drawing.Point(32, 208);
this.label6.Name = "label6";
this.label6.TabIndex = 58;
this.label6.Text = "GA变异率";
//
// gapc
//
this.gapc.Location = new System.Drawing.Point(32, 184);
this.gapc.Name = "gapc";
this.gapc.Size = new System.Drawing.Size(104, 21);
this.gapc.TabIndex = 57;
this.gapc.Text = "0.8";
//
// label9
//
this.label9.Location = new System.Drawing.Point(32, 168);
this.label9.Name = "label9";
this.label9.TabIndex = 56;
this.label9.Text = "GA交叉率";
//
// ganp
//
this.ganp.Location = new System.Drawing.Point(32, 144);
this.ganp.Name = "ganp";
this.ganp.Size = new System.Drawing.Size(104, 21);
this.ganp.TabIndex = 62;
this.ganp.Text = "50";
//
// label10
//
this.label10.Location = new System.Drawing.Point(32, 128);
this.label10.Name = "label10";
this.label10.TabIndex = 61;
this.label10.Text = "GA种群个数";
//
// label11
//
this.label11.Location = new System.Drawing.Point(192, 88);
this.label11.Name = "label11";
this.label11.TabIndex = 60;
this.label11.Text = "SA叠代次数";
//
// saendn
//
this.saendn.Location = new System.Drawing.Point(192, 184);
this.saendn.Name = "saendn";
this.saendn.Size = new System.Drawing.Size(104, 21);
this.saendn.TabIndex = 63;
this.saendn.Text = "20";
//
// label3
//
this.label3.Location = new System.Drawing.Point(192, 168);
this.label3.Name = "label3";
this.label3.TabIndex = 64;
this.label3.Text = "SA终止叠代次数";
//
// sadownt
//
this.sadownt.Location = new System.Drawing.Point(192, 224);
this.sadownt.Name = "sadownt";
this.sadownt.Size = new System.Drawing.Size(104, 21);
this.sadownt.TabIndex = 65;
this.sadownt.Text = "0.99";
//
// label12
//
this.label12.Location = new System.Drawing.Point(192, 208);
this.label12.Name = "label12";
this.label12.TabIndex = 66;
this.label12.Text = "SA温度下降速度";
//
// frmparam
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(400, 269);
this.Controls.Add(this.sadownt);
this.Controls.Add(this.label12);
this.Controls.Add(this.saendn);
this.Controls.Add(this.label3);
this.Controls.Add(this.ganp);
this.Controls.Add(this.label10);
this.Controls.Add(this.gapm);
this.Controls.Add(this.label6);
this.Controls.Add(this.gapc);
this.Controls.Add(this.label9);
this.Controls.Add(this.sat);
this.Controls.Add(this.label7);
this.Controls.Add(this.tnum);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.gan);
this.Controls.Add(this.rdata);
this.Controls.Add(this.cdata);
this.Controls.Add(this.label5);
this.Controls.Add(this.label8);
this.Controls.Add(this.label4);
this.Controls.Add(this.label2);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.label1);
this.Controls.Add(this.san);
this.Controls.Add(this.label11);
this.Name = "frmparam";
this.Text = "参数设置";
this.ResumeLayout(false);
}
#endregion
public void GetParamset(out PARAMETER param)
{
param.CourseFile=this.cdata.Text;
param.RoomFile=this.rdata.Text;
param.TimeSolt=Int32.Parse(this.tnum.Text);
param.gn=Int32.Parse (this.gan.Text);
param.gpc=(float)Decimal.Parse(this.saendn.Text);
param.gpm=(float)Decimal.Parse(this.gapm.Text);
param.gpn=Int32.Parse(this.ganp.Text);
param.sendn=Int32.Parse(this.saendn.Text);
param.sn=Int32.Parse(this.san.Text);
param.st=(float)Decimal.Parse(this.sat.Text);
param.sdownt=(float)Decimal.Parse(this.sadownt.Text);
param.cms=Int32.Parse(this.textBox1.Text);
param.course=new int[200,100];
param.room=new int[3];
param.nroom=0;
param.coursenum=0;
param.D =new int[param.coursenum,param.coursenum];
param.check=true;
FileStream strm;
try//读取课程文件
{
strm=new FileStream(param.CourseFile,FileMode.Open,FileAccess.ReadWrite);
StreamReader sr;
sr=new StreamReader(strm);
string temp = "";
int i=0;
temp = sr.ReadLine();
while(temp!="end")
{
int j=0;
string tt="";
foreach(char t in temp)
{
if (t!=',')
{
tt+=t;
}
else
{
param.course[i,j]=Int32.Parse(tt);
j++;
tt="";
}
}
i++;
temp = sr.ReadLine();
}
param.coursenum=i;
strm.Flush();
strm.Close();
}
catch(Exception e)
{
MessageBox.Show(e.Message,"erro");
MessageBox.Show("不能打开文件,请重新设置参数","erro");
}
try//读取考场数据文件
{
strm=new FileStream(param.RoomFile,FileMode.Open,FileAccess.ReadWrite);
StreamReader sr=new StreamReader(strm);
string temp = "";
int i=0;
temp = sr.ReadLine();
while(temp!="end")
{
string tt="";
foreach(char t in temp)
{
if(t!=',')
{
tt+=t;
}
}
param.room[i]=(int) Int32.Parse(tt);
i++;
temp = sr.ReadLine();
}
param.nroom=param.room[0]+param.room[1]*2+param.room[2]*4;
strm.Flush();
sr.Close();
}
catch(Exception e)
{
MessageBox.Show(e.Message,"erro");
MessageBox.Show("不能打开文件,请重新设置参数","erro");
}
param.D =new int[param.coursenum,param.coursenum];//参数D设置
for(int i=0;i<param.coursenum;i++)
{
int [] tt=new int [100];
for(int t=1;t<100;t++) tt[t-1]=param.course[i,t];
foreach(int a in tt)
{
if(a==0) break;
for(int j=i;j<param.coursenum;j++)
{
int [] kk=new int [100];
for(int k=1;k<100;k++) kk[k-1]=param.course[j,k];
foreach(int b in kk)
{
if(b==0) break;
if(a==b) param.D[i,j]+=1;
}
}
}
}
string str1="";
try//创建param.d文件
{
strm=new FileStream("paramd.txt",FileMode.OpenOrCreate,FileAccess.Write);
strm.SetLength(0);
StreamWriter sr=new StreamWriter (strm);
for(int i=0;i<param.coursenum;++i)
{
for(int j=0;j<param.coursenum;++j)
{str1+=param.D[i,j].ToString() +" ";}
str1+="\r\n";
}
sr.WriteLine(str1);
sr.WriteLine("end");
sr.Flush();
//MessageBox.Show("create about file have finished!","congradulation");
strm.Flush();
strm.Close();
}
catch(Exception ee)
{
MessageBox.Show(ee.Message,"erro");
MessageBox.Show("不能打开文件,请重新设置参数","erro");
}
//MessageBox.Show(str1,"param.d");
}
private void button1_Click(object sender, System.EventArgs e)
{
this.Close();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -