This repository has been archived on 2026-03-28. You can view files and clone it, but you cannot make any changes to its state, such as pushing and creating new issues, pull requests or comments.
eodev/eo/tutorial/html/eoOneMaxEvalFunc.html

160 lines
7.8 KiB
HTML

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="GENERATOR" content="Mozilla/4.78 [en] (X11; U; Linux 2.4.7-10 i686) [Netscape]">
<title>Templates/eoOneMaxEvalFunc.h</title>
</head>
<body text="#000000" bgcolor="#C3C2B4" link="#0000EE" vlink="#551A8B" alink="#FF0000">
<a href="eoLesson5.html">Back to Lesson 5</a>
- <a href="eoTutorial.html">Tutorial main page </a>- <a href="eoTopDown.html">Top-Down
page</a> - <a href="eoBottomUp.html">Bottom-up page</a> - <a href="eoProgramming.html">Programming
hints</a> - <font face="Arial,Helvetica"><a href="doc/html/index.html">EO
documentation</a></font>
<br>
<hr WIDTH="100%"><!-- -------------- End of header ------------------ --><!-- ----------------------------------------------- -->
<center>
<h1>
<font color="#FF0000">Templates/eoOneMaxEvalFunc.h</font></h1></center>
The places where you have to put some code are on <b><font color="#FF6666">pink
background</font></b>.. Only the the <a href="eoTutorial.html#colors">character
colors have the usual meaning</a>.
<br><a NAME="start"></a>
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
<tr NOSAVE>
<td NOSAVE><tt><font color="#993300">/** -*- mode: c++; c-indent-level:
4; c++-member-init-indent: 8; comment-column: 35; -*-</font></tt>
<p><tt><font color="#993300">The above line is usefulin Emacs-like editors</font></tt>
<br><tt><font color="#993300">*/</font></tt>
<p><tt><font color="#993300">/*</font></tt>
<br><tt><font color="#993300">Template for evaluator in EO, a functor that
computes the fitness of an EO</font></tt>
<br><tt><font color="#993300">==========================================================================</font></tt>
<br><tt><font color="#993300">*/</font></tt>
<p><b><tt><font color="#993300">#ifndef _eoOneMaxEvalFunc_h</font></tt></b>
<br><b><tt><font color="#993300">#define _eoOneMaxEvalFunc_h</font></tt></b>
<p><tt><font color="#993300">// include whatever general include you need</font></tt>
<br><b><tt><font color="#993300">#include &lt;stdexcept></font></tt></b>
<br><b><tt><font color="#993300">#include &lt;fstream></font></tt></b>
<p><tt><font color="#993300">// include the base definition of eoEvalFunc</font></tt>
<br><b><tt><font color="#993300">#include "eoEvalFunc.h"</font></tt></b>
<p><tt><font color="#993300">/**&nbsp;</font></tt>
<br><tt><font color="#993300">&nbsp;Always write a comment in this format
before class definition</font></tt>
<br><tt><font color="#993300">&nbsp;if you want the class to be documented
by Doxygen</font></tt>
<br><tt><font color="#993300">*/</font></tt></td>
</tr>
</table>
<a NAME="eval"></a>
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
<tr>
<td><b><tt><font color="#CC0000">template &lt;class EOT></font></tt></b>
<br><b><tt><font color="#CC0000">class eoOneMaxEvalFunc : public eoEvalFunc&lt;EOT></font></tt></b>
<br><b><tt><font color="#CC0000">{</font></tt></b>
<br><b><tt><font color="#CC0000">public:</font></tt></b>
<br><tt><font color="#CC0000">/// Ctor - no requirement</font></tt></td>
</tr>
</table>
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#FFCCCC" NOSAVE >
<tr>
<td><a NAME="constructor"></a><tt><font color="#CC0000">// START eventually
add or modify the anyVariable argument</font></tt>
<br><b><tt><font color="#CC0000">&nbsp;eoOneMaxEvalFunc()</font></tt></b>
<br><tt><font color="#CC0000"><b>&nbsp;</b> //&nbsp; eoOneMaxEvalFunc(
varType&nbsp; _anyVariable) : anyVariable(_anyVariable)&nbsp;</font></tt>
<br><tt><font color="#CC0000">// END eventually add or modify the anyVariable
argument</font></tt></td>
</tr>
</table>
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
<tr>
<td><b><tt><font color="#CC0000">&nbsp;{</font></tt></b></td>
</tr>
</table>
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#FFCCCC" NOSAVE >
<tr>
<td><tt><font color="#CC0000"><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b> //
START Code of Ctor of an eoOneMaxEvalFunc object</font></tt>
<br><tt><font color="#CC0000"><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b> //
END&nbsp;&nbsp;&nbsp; Code of Ctor of an eoOneMaxEvalFunc object</font></tt></td>
</tr>
</table>
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
<tr>
<td><b><tt><font color="#CC0000">&nbsp;}</font></tt></b>
<p><tt><font color="#CC0000"><b>&nbsp;</b> /** Actually compute the fitness</font></tt>
<br><tt><font color="#CC0000">&nbsp;&nbsp; *</font></tt>
<br><tt><font color="#CC0000">&nbsp;&nbsp; * @param EOT &amp; _eo the EO
object to evaluate</font></tt>
<br><tt><font color="#CC0000">&nbsp;&nbsp; *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
it should stay templatized to be usable&nbsp;</font></tt>
<br><tt><font color="#CC0000">&nbsp;&nbsp; *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
with any fitness type</font></tt>
<br><tt><font color="#CC0000">&nbsp;&nbsp; */</font></tt>
<br><b><tt><font color="#CC0000">&nbsp;void operator()(EOT &amp; _eo)</font></tt></b>
<br><b><tt><font color="#CC0000">&nbsp;{</font></tt></b>
<br><tt><font color="#CC0000"><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b> //
test for invalid to avoid recomputing fitness of unmodified individuals</font></tt>
<br><b><tt><font color="#CC0000">&nbsp;&nbsp;&nbsp;&nbsp; if (_eo.invalid())</font></tt></b>
<br><b><tt><font color="#CC0000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
{</font></tt></b>
<br><tt><font color="#CC0000"><b>double fit;&nbsp;&nbsp;&nbsp;&nbsp;</b>
// to hold fitness value</font></tt></td>
</tr>
</table>
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#FFCCCC" NOSAVE >
<tr>
<td><a NAME="operator"></a><tt><font color="#CC0000"><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b>
// START Code of computation of fitness of the eoOneMax object</font></tt>
<br><tt><font color="#CC0000">// fit = blablabla</font></tt>
<br><tt><font color="#CC0000"><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b> //
END&nbsp;&nbsp;&nbsp; Code of computation of fitness of the eoOneMax object</font></tt></td>
</tr>
</table>
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
<tr>
<td><b><tt><font color="#CC0000">_eo.fitness(fit);</font></tt></b>
<br><b><tt><font color="#CC0000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
}</font></tt></b>
<br><b><tt><font color="#CC0000">&nbsp;}</font></tt></b>
<p><b><tt><font color="#CC0000">private:</font></tt></b></td>
</tr>
</table>
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#FFCCCC" NOSAVE >
<tr>
<td><a NAME="data"></a><tt><font color="#CC0000">// START Private data
of an eoOneMaxEvalFunc object</font></tt>
<br><tt><font color="#CC0000"><b>&nbsp;</b> //&nbsp; varType anyVariable;&nbsp;&nbsp;&nbsp;
// for example ...</font></tt>
<br><tt><font color="#CC0000">// END&nbsp;&nbsp;&nbsp; Private data of
an eoOneMaxEvalFunc object</font></tt></td>
</tr>
</table>
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
<tr>
<td><b><tt><font color="#CC0000">};</font></tt></b>
<br><b><tt><font color="#CC0000">#endif</font></tt></b></td>
</tr>
</table>
<hr WIDTH="100%"><a href="eoLesson5.html">Back to Lesson 5</a> - <a href="eoTutorial.html">Tutorial
main page </a>- <a href="eoTopDown.html">Top-Down page</a> - <a href="eoBottomUp.html">Bottom-up
page</a> - <a href="eoProgramming.html">Programming hints</a> - <font face="Arial,Helvetica"><a href="doc/html/index.html">EO
documentation</a></font>
<hr>
<address>
<a href="mailto:marc.schoenauer@inria.fr">Marc Schoenauer</a></address>
<br><!-- Created: Nov 2000 --><!-- hhmts start -->Last modified: Fri May
3 06:14:25 2002<!-- hhmts end -->
</body>
</html>