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

📄 iprecode.htm

📁 遗传算法GPE_release_v1.0.tar
💻 HTM
📖 第 1 页 / 共 4 页
字号:
<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">How to Write IPrecodeTree for Different Problems</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">The 
  IPrecodeTree represents the operations performed by an </span>IIndividual<span style="font-weight: 400"> 
  before they are converted to actual computer code.&nbsp; The IPrecodeTree 
  gives the </span>GPEngine<span style="font-weight: 400"> access to the 
  implementation-specific genetic operations of mutation and recombination.&nbsp; 
  Precode classes provide an abstract tree representation of the code that will 
  be written to each IIndividual's Test method.&nbsp; The IPrecodeTree can be 
  seen as a tree containing nodes which contain lines of code.&nbsp; These nodes 
  can be mutated and recombined to form new nodes.&nbsp; See &quot;Getting Started&quot; 
  for more information on mutation and recombination.&nbsp; The 
  Action-Perception (AP) tree is currently the Precode tree defined.&nbsp; The 
  AP tree handles the <i>void Method()</i> and the <i>bool Method()</i>.&nbsp; 
  Future improvements include support for various methods such as <i>int 
  Method()</i>, <i>int Method( int )</i>, <i>int Method( int, int )</i>, etc.&nbsp;
  </span></font></h4>
  <p class="dtH4"><font face="Arial">The MutationPoints method gets the number 
  of mutation points in this instance.&nbsp; See &quot;Getting Started&quot; for more 
  information on mutation.&nbsp; </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">int 
        MutationPoints {</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">}</font></font></td>
      </tr>
    </table>
    </center>
  </div>
  <h4 class="dtH4">&nbsp;</h4>
  <p><font face="Arial">The RecombinationPoints method gets the number of 
  recombination points in this instance.&nbsp; See &quot;Getting Started&quot; for more 
  information on recombination.&nbsp; </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">int 
        RecombinationPoints {</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">}</font></font></td>
      </tr>
    </table>
    </center>
  </div>
  <h4 class="dtH4">&nbsp;</h4>
  <p class="dtH4"><font face="Arial">The GenerateRandomTree method, using the 
  specified methods, generates a random Precode tree within the depth and width 
  constraints specified in the <b>EngineOptions</b>.&nbsp; After verifying that 
  the random number and available methods are not null and that the maximum 
  depth and width are greater than zero, a random tree is generated with the 
  valid methods.</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">
        IPrecodeTree GenerateRandomTree( Random r, ReadOnlyMethodInfoCollection 
        availableMethods, </font></font></p>
        <p style="margin-top: 0; margin-bottom: 0">&nbsp;<font SIZE="2" face="Courier New"> 
        int maxDepth, int</font><font face="Courier New" SIZE="2"> 
        maxWidth );</font></td>
      </tr>
    </table>
    </center>
  </div>
  <h4 class="dtH4" style="margin-top: 0; margin-bottom: 0">&nbsp;</h4>
  <div align="center">
    <center>
    <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="90%" id="AutoNumber8">
      <tr>
        <td width="100%"><font SIZE="2">
        <p style="margin-top: 0; margin-bottom: 0"></font>
        <font SIZE="2" face="Courier New">public 
        IPrecodeTree GenerateRandomTree( Random r, ReadOnlyMethodInfoCollection</font></p>
        <p style="margin-top: 0; margin-bottom: 0">
        <font face="Courier New" size="2">&nbsp;</font><font SIZE="2" face="Courier New"> 
        availableMethods, int 
        maxDepth, int</font><font SIZE="2"><font face="Courier New"> 
        maxWidth ) {</font></p>
        <p style="margin-top: 0; margin-bottom: 0">
        <font face="Courier New" size="2">&nbsp;&nbsp; &nbsp;</font></font><font SIZE="2" face="Courier New">//check 
        that random number and methods are not null</p>
        </font><font SIZE="2">
        <p style="margin-top: 0; margin-bottom: 0">
        <font face="Courier New" size="2">&nbsp;&nbsp;&nbsp; </font></font>
        <font SIZE="2" face="Courier New">if( 
        r == null</font><font SIZE="2"><font face="Courier New"> 
        ) {</font></p>
        <p style="margin-top: 0; margin-bottom: 0">
        <font face="Courier New" size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        </font></font><font SIZE="2" face="Courier New">
        throw new</font><font face="Courier New" SIZE="2"> 
        ArgumentNullException( &quot;r&quot;, &quot;The random number passed to</font></p>
        <p style="margin-top: 0; margin-bottom: 0">
        <font face="Courier New" size="2">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; </font>
        <font SIZE="2"><font face="Courier New">&nbsp;ActionPerceptionTree.GenerateRandomTree 
        method was null.&quot; );</font></p>
        <p style="margin-top: 0; margin-bottom: 0">
        <font face="Courier New" size="2">&nbsp;&nbsp;&nbsp; </font>
        <font face="Courier New">}</font></p>
        <p style="margin-top: 0; margin-bottom: 0">
        <font face="Courier New" size="2">&nbsp;&nbsp;&nbsp; </font></font>
        <font SIZE="2" face="Courier New">if( 
        availableMethods == null</font><font SIZE="2"><font face="Courier New"> 
        ) {</font></p>
        <p style="margin-top: 0; margin-bottom: 0">
        <font face="Courier New" size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        </font></font><font SIZE="2" face="Courier New">
        throw new</font><font face="Courier New" SIZE="2"> 
        ArgumentNullException( &quot;availableMethods&quot;, &quot;The collection of methods 
        passed</font></p>
        <p style="margin-top: 0; margin-bottom: 0">
        <font face="Courier New" size="2">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; </font>
        <font SIZE="2"><font face="Courier New">&nbsp;to 
        ActionPerceptionTree.GenerateRandomTree method was null.&quot; );</font></p>
        <p style="margin-top: 0; margin-bottom: 0">
        <font face="Courier New" size="2">&nbsp;&nbsp;&nbsp; </font>
        <font face="Courier New">}</font></p>
        <p style="margin-top: 0; margin-bottom: 0">
        <font face="Courier New" size="2">&nbsp;&nbsp;&nbsp; </font></font>
        <font SIZE="2" face="Courier New">//check that depth and 
        width are in range</p>
        </font><font SIZE="2">
        <p style="margin-top: 0; margin-bottom: 0">
        <font face="Courier New" size="2">&nbsp;&nbsp;&nbsp; </font></font>
        <font SIZE="2" face="Courier New">if</font><font SIZE="2"><font face="Courier New">( 
        maxDepth &lt;= 0 ) {</font></p>
        <p style="margin-top: 0; margin-bottom: 0">
        <font face="Courier New" size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        </font></font><font SIZE="2" face="Courier New">
        throw new</font><font face="Courier New" SIZE="2"> 
        ArgumentOutOfRangeException( &quot;maxDepth&quot;, maxDepth, &quot;The maximum depth 
        passed</font></p>
        <p style="margin-top: 0; margin-bottom: 0">
        <font face="Courier New" size="2">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; </font>
        <font face="Courier New" SIZE="2">&nbsp;to 
        ActionPerceptionTree.GenerateRandomTree method was less than or </font>
        </p>
        <p style="margin-top: 0; margin-bottom: 0">
        <font face="Courier New" size="2">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font>
        <font SIZE="2"><font face="Courier New">equal to zero.&quot;);</font></p>
        <p style="margin-top: 0; margin-bottom: 0">
        <font face="Courier New" size="2">&nbsp;&nbsp;&nbsp; </font>
        <font face="Courier New">}</font></p>
        <p style="margin-top: 0; margin-bottom: 0">
        <font face="Courier New" size="2">&nbsp;&nbsp;&nbsp; </font></font>
        <font SIZE="2" face="Courier New">if</font><font SIZE="2"><font face="Courier New">( 
        maxWidth &lt;= 0 ) {</font></p>
        <p style="margin-top: 0; margin-bottom: 0">
        <font face="Courier New" size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        </font></font><font SIZE="2" face="Courier New">
        throw new</font><font face="Courier New" SIZE="2"> 
        ArgumentOutOfRangeException( &quot;maxWidth&quot;, maxWidth, &quot;The maximum width 
        passed</font></p>
        <p style="margin-top: 0; margin-bottom: 0">
        <font face="Courier New" size="2">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; </font>
        <font face="Courier New" SIZE="2">&nbsp;to 
        ActionPerceptionTree.GenerateRandomTree method was less than or equal
        </font></p>
        <p style="margin-top: 0; margin-bottom: 0">
        <font face="Courier New" size="2">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; </font>
        <font SIZE="2">

⌨️ 快捷键说明

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