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

📄 iprecode.htm

📁 遗传算法GPE_release_v1.0.tar
💻 HTM
📖 第 1 页 / 共 4 页
字号:
        <font face="Courier New">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">//check the available 
        methods</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">( 
        availableMethods.Empty ) {</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"> 
        ArgumentException( &quot;The collection of methods 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 empty.&quot;, &quot;availableMethods&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">foreach( 
        MethodInfo method in</font><font SIZE="2"><font face="Courier New"> 
        availableMethods ) {</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">if</font><font SIZE="2"><font face="Courier New">( 
        !CheckMethod( method ) ) {</font></p>
        <p style="margin-top: 0; margin-bottom: 0">
        <font face="Courier New" size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        </font></font><font SIZE="2" face="Courier New">
        throw new</font><font face="Courier New" SIZE="2"> 
        ArgumentException( String.Format( &quot;The collection of methods 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;&nbsp;&nbsp;&nbsp; </font>
        <font SIZE="2"><font face="Courier New">&nbsp;ActionPerceptionTree.GenerateRandomTree 
        method contained a method, '{0}', that </font>
        <font face="Courier New" size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        </font><font face="Courier New">cannot be used to create a node.&quot;, 
        method.Name ), &quot;availableMethods&quot; );</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">}</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">return</font><font SIZE="2"><font face="Courier New"> 
        GenerateRandomTree( 1, r, availableMethods, maxDepth, maxWidth + 1 );</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" size="2">&nbsp;&nbsp;&nbsp; </font></font></p>
        <p style="margin-top: 0; margin-bottom: 0">&nbsp;</p>
        <p style="margin-top: 0; margin-bottom: 0">
        <font SIZE="2" face="Courier New">private static 
        ActionPerceptionTree GenerateRandomTree( int</font><font face="Courier New" SIZE="2"> 
        currentDepth, </font></p>
        <font SIZE="2">
        <p style="margin-top: 0; margin-bottom: 0"><font face="Courier New">&nbsp; 
        Random r, ReadOnlyMethodInfoCollection availableMethods, </font></font>
        <font SIZE="2" face="Courier New">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">//create new tree and 
        fill with 'width' number of elements</p>
        </font><font SIZE="2">
        <p style="margin-top: 0; margin-bottom: 0">
        <font face="Courier New" size="2">&nbsp;&nbsp;&nbsp; </font>
        <font face="Courier New">ActionPerceptionTree newTree = </font></font>
        <font SIZE="2" face="Courier New">new</font><font SIZE="2"><font face="Courier New"> 
        ActionPerceptionTree();</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">int</font><font SIZE="2"><font face="Courier New"> 
        width = r.Next( 1, maxWidth );</font></p>
        <p style="margin-top: 0; margin-bottom: 0">
        <font face="Courier New" size="2">&nbsp;&nbsp;&nbsp; </font>
        <font face="Courier New">PerceptionNode p;</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">for( int</font><font SIZE="2"><font face="Courier New"> 
        index = 0; index &lt; width; ++index ) {</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">//add 
        random node</p>
        </font><font SIZE="2">
        <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">newTree.Children.Add( </font></p>
        <p style="margin-top: 0; margin-bottom: 0">
        <font face="Courier New" size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
        </font>
        <font face="Courier New">ActionPerceptionNode.CreateNode( 
        availableMethods[r.Next( 0,</font></p>
        <p style="margin-top: 0; margin-bottom: 0">
        <font face="Courier New" size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        </font><font face="Courier New">&nbsp;availableMethods.Count )]) </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">);</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">//if 
        this is not the final depth, and if this added node is a perception 
        node, </p>
        </font><font SIZE="2">
        <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">// 
        generate trees for it at the next depth level</p>
        </font><font SIZE="2">
        <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">if( 
        currentDepth &lt; maxDepth&amp;&amp;(p = newTree.Children[index] as PerceptionNode) 
        != null){ </font></p>
        <p style="margin-top: 0; margin-bottom: 0">
        <font face="Courier New" size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //treeChoice 
        determines which subtrees to generate:</p>
        </font><font SIZE="2">
        <p style="margin-top: 0; margin-bottom: 0">
        <font face="Courier New" size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        </font></font><font SIZE="2" face="Courier New">// 0 = 
        true tree, 1 = false tree, 2 = both trees, 3 = neither tree</p>
        </font><font SIZE="2">
        <p style="margin-top: 0; margin-bottom: 0">
        <font face="Courier New" size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        </font></font><font SIZE="2" face="Courier New">int</font><font SIZE="2"><font face="Courier New"> 
        treeChoice = r.Next( 0, 4 );</font></p>
        <p style="margin-top: 0; margin-bottom: 0">
        <font face="Courier New" size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        </font></font><font SIZE="2" face="Courier New">if</font><font SIZE="2"><font face="Courier New">( 
        treeChoice == 0 || treeChoice == 2 ) {</font></p>
        <p style="margin-top: 0; margin-bottom: 0">
        <font face="Courier New" size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        </font><font face="Courier New">p.TrueTree.Children.AddRange( </font>
        </p>
        <p style="margin-top: 0; margin-bottom: 0">
        <font face="Courier New" size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        </font><font face="Courier New">&nbsp; GenerateRandomTree( currentDepth 
        + 1, r, availableMethods, maxDepth, maxWidth</font></p>
        <p style="margin-top: 0; margin-bottom: 0">
        <font face="Courier New" size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        </font><font face="Courier New">&nbsp;&nbsp;&nbsp;&nbsp; ).Children</font></p>
        <p style="margin-top: 0; margin-bottom: 0">
        <font face="Courier New" size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        </font></font><font SIZE="2" face="Courier New">if</font><font SIZE="2"><font face="Courier New">( 
        treeChoice == 1 || treeChoice == 2 ) {</font></p>
        <p style="margin-top: 0; margin-bottom: 0">
        <font face="Courier New" size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        </font><font face="Courier New">p.FalseTree.Children.AddRange( </font>
        </p>
        <p style="margin-top: 0; margin-bottom: 0">
        <font face="Courier New" size="2">&nbsp;&nbsp;&nbsp; </font>&nbsp;
        <font face="Courier New" size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        </font><font face="Courier New">GenerateRandomTree( currentDepth + 1, r, 
        availableMethods, maxDepth, maxWidth</font></p>
        <p style="margin-top: 0; margin-bottom: 0">
        <font face="Courier New" size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        </font><font face="Courier New">&nbsp; ).Children</font></p>
        <p style="margin-top: 0; margin-bottom: 0">
        <font face="Courier New" size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&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;&nbsp;&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 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">return</font><font SIZE="2"><font face="Courier New"> 
        newTree;</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 CheckMethod method verifies that the 
  given method can be used in this implementation of IPrecodeTree.</font></p>
  <div align="center">
    <center>
    <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="90%" id="AutoNumber4">
      <tr>

⌨️ 快捷键说明

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