📄 environmentverifier.htm
字号:
<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">Verifying the Environment</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>
<p><font face="Arial">The EnvironmentVerifier verifies that the collection of EnvironmentReferences passed to its constructor
each have the appropriate characteristics and implement all required members for an
<b>IEnvironment</b> class used by the <b>GPEngine</b>. It initializes a new instance of the EnvironmentVerifier class with the specified
EnvironmentReferences and determines if there is an invalid element.<p></div>
<div id="nstext">
<div align="center">
<center>
<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>
<font SIZE="2" face="Courier New">public</font><font SIZE="2"><font face="Courier New">
EnvironmentVerifier( EnvironmentReference[] environments ) {</font></p>
<p style="margin-top: 0; margin-bottom: 0"><font face="Courier New">
</font></font><font SIZE="2" face="Courier New">//do basic checks</p>
</font><font SIZE="2">
<p style="margin-top: 0; margin-bottom: 0"><font face="Courier New">
</font></font><font SIZE="2" face="Courier New">if( environments ==
null</font><font SIZE="2"><font face="Courier New"> ) {</font></p>
<p style="margin-top: 0; margin-bottom: 0"><font face="Courier New">
</font></font><font SIZE="2" face="Courier New">throw new</font><font face="Courier New" SIZE="2">
ArgumentNullException( "environments", "The array of environment</font></p>
<p style="margin-top: 0; margin-bottom: 0">
<font face="Courier New" SIZE="2">
</font><font SIZE="2"><font face="Courier New"> references passed
to EnvironmentVerifier.constructor was null." );</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">
</font></font><font SIZE="2" face="Courier New">if</font><font SIZE="2"><font face="Courier New">(
environments.Length == 0 ) {</font></p>
<p style="margin-top: 0; margin-bottom: 0"><font face="Courier New">
</font></font><font SIZE="2" face="Courier New">throw new</font><font face="Courier New" SIZE="2">
ArgumentException( "The array of environment references passed to</font></p>
<p style="margin-top: 0; margin-bottom: 0">
<font face="Courier New" SIZE="2">
</font><font SIZE="2"><font face="Courier New"> EnvironmentVerifier.constructor
was empty.", "environments" );</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">
</font></font><font SIZE="2" face="Courier New">//instantiate each
reference</p>
</font><font SIZE="2">
<p style="margin-top: 0; margin-bottom: 0"><font face="Courier New">
EnvironmentCollection envs = </font></font>
<font SIZE="2" face="Courier New">null</font><font SIZE="2"><font face="Courier New">;</font></p>
<p style="margin-top: 0; margin-bottom: 0"><font face="Courier New">
</font></font><font SIZE="2" face="Courier New">try</font><font SIZE="2"><font face="Courier New">
{</font></p>
<p style="margin-top: 0; margin-bottom: 0"><font face="Courier New">
envs = Tester.CreateEnvironments( environments );</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">
</font></font><font SIZE="2" face="Courier New">catch</font><font SIZE="2"><font face="Courier New">(
ArgumentException e ) {</font></p>
<p style="margin-top: 0; margin-bottom: 0"><font face="Courier New">
</font></font><font SIZE="2" face="Courier New">throw new</font><font face="Courier New" SIZE="2">
ArgumentException( "The array of environment references passed to</font></p>
<p style="margin-top: 0; margin-bottom: 0">
<font face="Courier New" SIZE="2">
</font><font face="Courier New" SIZE="2"> EnvironmentVerifier.constructor
had at least one invalid element.",</font></p>
<p style="margin-top: 0; margin-bottom: 0">
<font face="Courier New" SIZE="2">
</font><font SIZE="2"><font face="Courier New"> "environments", e
);</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">
</font></font><font SIZE="2" face="Courier New">//everything checks
out</p>
</font><font SIZE="2">
<p style="margin-top: 0; margin-bottom: 0"><font face="Courier New">
m_Environments = </font></font><font SIZE="2" face="Courier New">new</font><font SIZE="2"><font face="Courier New">
ReadOnlyEnvironmentReferenceCollection( environments );</font></p>
<p style="margin-top: 0; margin-bottom: 0"><font face="Courier New">
m_InstantiatedEnvironments = </font></font>
<font SIZE="2" face="Courier New">new</font><font SIZE="2"><font face="Courier New">
ReadOnlyEnvironmentCollection( envs );</font></p>
<p style="margin-top: 0; margin-bottom: 0"><font face="Courier New">}</font></font></td>
</tr>
</table>
</center>
</div>
</center>
<p class="dtH4" align="left"><font face="Arial">The Environments method gets the verified collection of EnvironmentReferences.</font></p>
</div>
<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>
<font SIZE="2" face="Courier New">public</font><font SIZE="2"><font face="Courier New">
ReadOnlyEnvironmentReferenceCollection Environments {</font></p>
<p style="margin-top: 0; margin-bottom: 0"><font face="Courier New">
</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><font SIZE="2" face="Courier New">return</font><font SIZE="2"><font face="Courier New">
m_Environments;</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">}</font></p>
<p style="margin-top: 0; margin-bottom: 0"></font>
<font SIZE="2" face="Courier New">private</font><font SIZE="2"><font face="Courier New">
ReadOnlyEnvironmentReferenceCollection m_Environments;</font></font></td>
</tr>
</table>
</center>
</div>
<p class="dtH4" align="left">The InstantiatedEnvironments method gets the collection of instantiated IEnvironments referenced by Environments.
<br>
<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>
<font SIZE="2" face="Courier New">public</font><font SIZE="2"><font face="Courier New">
ReadOnlyEnvironmentCollection InstantiatedEnvironments {</font></p>
<p style="margin-top: 0; margin-bottom: 0"><font face="Courier New">
</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><font SIZE="2" face="Courier New">return</font><font SIZE="2"><font face="Courier New">
m_InstantiatedEnvironments;</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">}</font></p>
<p style="margin-top: 0; margin-bottom: 0"></font>
<font SIZE="2" face="Courier New">private</font><font face="Courier New" SIZE="2">
ReadOnlyEnvironmentCollection m_InstantiatedEnvironments;</font></td>
</tr>
</table>
</center>
</div>
<p class="dtH4"> </p>
<h4 class="dtH4"><font face="Arial">See Also</font></h4>
<p>
<a href="../GPE.htm">GPEngine</a> | <a href="../ProblemSpace/Environment.htm">
IEnvironment</a></p>
<hr>
<div id="footer">
<font face="Arial">
<a href="http://www.opensource.org/" target="_top">
<img style="padding-bottom: 5px" src="http://opensource.org/trademarks/open_source_button.png" align="left" border="0"></a>
This software licensed under the
<a href="http://opensource.org/licenses/afl-2.1.php" target="_top">Academic
Free License version 2.1</a>. (<a href="../../afl-2.1.txt">Plain
text</a>)</font></div>
</div>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -