⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 population.htm

📁 遗传算法GPE_release_v1.0.tar
💻 HTM
📖 第 1 页 / 共 2 页
字号:
<html>

<head>
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Genetic Programming FAQ</title>
</head>

<body>

<div id="nsbanner">
  <table cellSpacing="0" cellPadding="0" width="100%" border="0">
    <tr>
      <td>
      <div id="bannerrow1">
        <table class="bannerparthead" cellSpacing="0">
          <tr id="hdr">
            <td class="runninghead" style="font-size: 70%">
            <font face="Arial"><a class="show" id="design_toggle" title="Show or hide design notes" href="../../index.html"><img src="../../Images/Icons/G.png" width="14" height="14" border="0" align="middle"/></a> Genetic Programming Engine FAQ</font></td>
          </tr>
        </table>
      </div>
      <div id="TitleRow">
        <h1 class="dtH1" style="font-size: 85%; left: 5px; position: relative">
        <font face="Arial">Creating the .CS Files for Individuals in a Population</font></h1>
      </div>
      </td>
      <td vAlign="top" align="right">
      <font face="Arial">
      <img src="../../Images/Icons/GP_blue.png" width="191" height="39"></font></td>
    </tr>
  </table>
</div>
<div id="nstext">
  <h4 class="dtH4"><font face="Arial"><span style="font-weight: 400">A 
  population represents a collection of individual programs to be tested by the
  </span>GPEngine<span style="font-weight: 400">.&nbsp; It is a collection of
  </span>IndividualInfos<span style="font-weight: 400"> or individuals before 
  they are compiled.&nbsp; The Population class is responsible for generating 
  the .CS code files for individuals in a population.&nbsp; Populations are 
  identified by their generation number with 0 being the first generation.</span></font></h4>
  <p class="dtH4"><font face="Arial">The Population method initializes a new 
  instance of the Population class with the specified generation number.</font></p>
	<div align="center">
      <center>
      <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="90%" id="AutoNumber1">
        <tr>
          <td width="100%"><font SIZE="2">
          <p style="margin-top: 0; margin-bottom: 0"><font face="Courier New">
          public Population( int generation ) {</font></p>
          <p style="margin-top: 0; margin-bottom: 0"><font face="Courier New">&nbsp;&nbsp;&nbsp; 
          Generation = generation;</font></p>
          <p style="margin-top: 0; margin-bottom: 0"><font face="Courier New">}</font></font></td>
        </tr>
      </table>
      </center>
  </div>
  <p class="dtH4"><font face="Arial">The Generation method gets and sets the the 
  number of the generation this Population represents.&nbsp; Valid values are 
  integers greater than or equal to 0.</font></p>
	<div align="center">
      <center>
      <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="90%" id="AutoNumber2">
        <tr>
          <td width="100%"><font SIZE="2">
          <p style="margin-top: 0; margin-bottom: 0"><font face="Courier New">
          public int Generation {</font></p>
          <p style="margin-top: 0; margin-bottom: 0"><font face="Courier New">&nbsp;&nbsp;&nbsp; 
          get {</font></p>
          <p style="margin-top: 0; margin-bottom: 0"><font face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
          return m_Generation;</font></p>
          <p style="margin-top: 0; margin-bottom: 0"><font face="Courier New">&nbsp;&nbsp;&nbsp; 
          }</font></p>
          <p style="margin-top: 0; margin-bottom: 0"><font face="Courier New">&nbsp;&nbsp;&nbsp; 
          set {</font></p>
          <p style="margin-top: 0; margin-bottom: 0"><font face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
          if( value &lt; 0 ) {</font></p>
          <p style="margin-top: 0; margin-bottom: 0"><font face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          </font></font><font SIZE="2" face="Courier New">throw new 
          ArgumentOutOfRangeException( &quot;value&quot;, value, &quot;The generation number 
          passed</font></p>
          <p style="margin-top: 0; margin-bottom: 0"><font SIZE="2">
          <font face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
          to Population.constructor was less than zero&quot; );</font></p>
          <p style="margin-top: 0; margin-bottom: 0"><font face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
          }</font></p>
          <p style="margin-top: 0; margin-bottom: 0"><font face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
          m_Generation = value;</font></p>
          <p style="margin-top: 0; margin-bottom: 0"><font face="Courier New">&nbsp;&nbsp;&nbsp; 
          }</font></p>
          <p style="margin-top: 0; margin-bottom: 0"><font face="Courier New">}</font></p>
          <p style="margin-top: 0; margin-bottom: 0"><font face="Courier New">
          private int m_Generation;</font></font></td>
        </tr>
      </table>
      </center>
  </div>
  <p class="dtH4"><font face="Arial">The BaseClass method gets the type of the 
  IIndividual's <i>Base Class</i> in the Population.&nbsp; </font></p>
	<div align="center">
      <center>
      <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="90%" id="AutoNumber3">
        <tr>
          <td width="100%"><font SIZE="2">
          <p style="margin-top: 0; margin-bottom: 0"><font face="Courier New">
          public Type BaseClass {</font></p>
          <p style="margin-top: 0; margin-bottom: 0"><font face="Courier New">&nbsp;&nbsp;&nbsp; 
          get {</font></p>
          <p style="margin-top: 0; margin-bottom: 0"><font face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
          return m_BaseClass;</font></p>
          <p style="margin-top: 0; margin-bottom: 0"><font face="Courier New">&nbsp;&nbsp;&nbsp; 
          }</font></p>
          <p style="margin-top: 0; margin-bottom: 0"><font face="Courier New">}</font></p>
          <p style="margin-top: 0; margin-bottom: 0"><font face="Courier New">
          private Type m_BaseClass;</font></font></td>
        </tr>
      </table>
      </center>
  </div>
  <p class="dtH4"><font face="Arial">The CodeFile method gets the name of the 
  generated code file before GenerateCodeFile (see below) is called and the full 
  path to the file after GenerateCodeFile is called. </font></p>
	<div align="center">
      <center>
      <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="90%" id="AutoNumber4">
        <tr>
          <td width="100%"><font SIZE="2">
          <p style="margin-top: 0; margin-bottom: 0"></font>
          <font SIZE="2" face="Courier New">public string</font><font SIZE="2"><font face="Courier New"> 
          CodeFile {</font></p>
          <p style="margin-top: 0; margin-bottom: 0"><font face="Courier New">&nbsp;&nbsp;&nbsp;
          </font></font><font SIZE="2" face="Courier New">get</font><font SIZE="2"><font face="Courier New"> 
          {</font></p>
          <p style="margin-top: 0; margin-bottom: 0"><font face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          </font></font><font SIZE="2" face="Courier New">if( m_CodeFile == null</font><font SIZE="2"><font face="Courier New"> 
          ) {</font></p>
          <p style="margin-top: 0; margin-bottom: 0"><font face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
          m_CodeFile = String.Format( &quot;{0}_Generation{1}.cs&quot;, BaseClass.Name, 
          Generation );</font></p>
          <p style="margin-top: 0; margin-bottom: 0"><font face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
          }</font></p>
          <p style="margin-top: 0; margin-bottom: 0"><font face="Courier New">&nbsp;&nbsp;&nbsp;
          </font></font><font SIZE="2" face="Courier New">return</font><font SIZE="2"><font face="Courier New"> 
          m_CodeFile;</font></p>
          <p style="margin-top: 0; margin-bottom: 0"><font face="Courier New">&nbsp;&nbsp;&nbsp; 
          }</font></p>
          <p style="margin-top: 0; margin-bottom: 0"><font face="Courier New">}</font></p>
          <p style="margin-top: 0; margin-bottom: 0"></font>
          <font SIZE="2" face="Courier New">private string m_CodeFile;</font></td>
        </tr>
      </table>
      </center>
  </div>
  <p class="dtH4"><font face="Arial">The GenerateCodeFile method creates the .CS 
  files that represent individuals.&nbsp; The IPrecodeTree of each 
  IndividualInfo in the Population is converted into computer code.&nbsp; This 
  is then saved in a file in the directory specified by the <i>OutputDirectory
  </i>parameter.&nbsp; The file is named by the <b>IIndividual</b> <i>Base Class</i> 
  name plus the number of the current generation.&nbsp; If <i>includeTested </i>
  is set to true, code for previously tested individuals is regenerated.&nbsp;
  </font></p>
	<div align="center">
      <center>
      <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="90%" id="AutoNumber5">
        <tr>
          <td width="100%"><font SIZE="2">
          <p style="margin-top: 0; margin-bottom: 0"><font face="Courier New">
          public</font></font><font SIZE="2" face="Courier New"> string[] 
          GenerateCodeFile( string outputDirectory, bool</font><font SIZE="2"><font face="Courier New"> 
          includeTested ) {</font></p>
          <p style="margin-top: 0; margin-bottom: 0"><font face="Courier New">&nbsp;&nbsp;&nbsp;
          </font></font><font SIZE="2" face="Courier New">//check that there are 
          individuals to generate code for</p>
          <p style="margin-top: 0; margin-bottom: 0">&nbsp;&nbsp;&nbsp; if</font><font SIZE="2"><font face="Courier New">( 
          Empty ) {</font></p>
          <p style="margin-top: 0; margin-bottom: 0"><font face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          </font></font><font SIZE="2" face="Courier New">throw new 
          InvalidOperationException( &quot;Population.GenerateCodeFile Cannot 
          generate</font></p>
          <p style="margin-top: 0; margin-bottom: 0">
          <font SIZE="2" face="Courier">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          </font><font face="Courier New" SIZE="2">&nbsp;code</font><font SIZE="2"><font face="Courier New"> 
          for empty Population.&quot; );</font></p>
          <p style="margin-top: 0; margin-bottom: 0"><font face="Courier New">&nbsp;&nbsp;&nbsp; 
          }</font></p>
          <p style="margin-top: 0; margin-bottom: 0"><font face="Courier New">&nbsp;&nbsp;&nbsp;
          </font></font><font SIZE="2" face="Courier New">//check output 
          directory</p>
          <p style="margin-top: 0; margin-bottom: 0">&nbsp;&nbsp;&nbsp; if( 
          outputDirectory == null</font><font SIZE="2"><font face="Courier New"> 
          ) {</font></p>
          <p style="margin-top: 0; margin-bottom: 0"><font face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          </font></font><font SIZE="2" face="Courier New">throw new 
          ArgumentNullException( &quot;outputDirectory&quot;, &quot;The output directory passed</font></p>
          <p style="margin-top: 0; margin-bottom: 0">
          <font SIZE="2" face="Courier">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
          </font><font face="Courier New" SIZE="2">&nbsp;to</font><font SIZE="2"><font face="Courier New"> 
          Population.GenerateCodeFile was null.&quot; );</font></p>
          <p style="margin-top: 0; margin-bottom: 0"><font face="Courier New">&nbsp;&nbsp;&nbsp; 
          }</font></p>
          <p style="margin-top: 0; margin-bottom: 0">&nbsp;</p>
          <p style="margin-top: 0; margin-bottom: 0"><font face="Courier New">&nbsp;&nbsp;&nbsp;
          </font></font><font SIZE="2" face="Courier New">//create a code 
          compile unit to generate the code</p>
          </font><font SIZE="2">
          <p style="margin-top: 0; margin-bottom: 0"><font face="Courier New">&nbsp;&nbsp;&nbsp; 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -