Adding the Lesson5 - how to create your own genotype
This commit is contained in:
parent
b407bf5e81
commit
c5e225551a
14 changed files with 2476 additions and 72 deletions
192
eo/tutorial/html/eoOneMax_complete.html
Normal file
192
eo/tutorial/html/eoOneMax_complete.html
Normal file
|
|
@ -0,0 +1,192 @@
|
|||
<!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/eoOneMax_complete.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/eoOneMax_complete.h</font></h1></center>
|
||||
The user-defined code is on <b><font color="#FF6666">pink background</font></b>..
|
||||
Only the the <a href="eoTutorial.html#colors">character colors have the
|
||||
usual meaning</a>.
|
||||
<p><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>
|
||||
<br><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 creating a new representation
|
||||
in EO</font></tt>
|
||||
<br><tt><font color="#993300">================================================</font></tt>
|
||||
<br><tt><font color="#993300">*/</font></tt>
|
||||
<p><b><tt><font color="#993300">#ifndef _eoOneMax_h</font></tt></b>
|
||||
<br><b><tt><font color="#993300">#define _eoOneMax_h</font></tt></b>
|
||||
<br> </td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#FFCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><tt><font color="#000000">/** </font></tt>
|
||||
<br><tt><font color="#000000">* A simple example class for bitstring (is
|
||||
NOT supposed to be used :-)</font></tt>
|
||||
<br><tt><font color="#000000">*/</font></tt></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td></td>
|
||||
</tr>
|
||||
</table>
|
||||
<a NAME="representation"></a>
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><b><tt><font color="#999900">template< class FitT></font></tt></b>
|
||||
<br><b><tt><font color="#999900">class eoOneMax: public EO<FitT> {</font></tt></b>
|
||||
<br><b><tt><font color="#999900">public:</font></tt></b>
|
||||
<br><tt><font color="#999900"><b> </b> /** Deafult Ctor: nothing to
|
||||
be done */</font></tt>
|
||||
<br><b><tt><font color="#999900"> eoOneMax() {}</font></tt></b>
|
||||
<p><b><tt><font color="#999900"> virtual string className() const
|
||||
{ return "eoOneMax"; }</font></tt></b>
|
||||
<br> </td>
|
||||
</tr>
|
||||
</table>
|
||||
<a NAME="output"></a>
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><tt><font color="#3366FF"><b> </b> /** printing... */</font></tt>
|
||||
<br><b><tt><font color="#3366FF"> void printOn(ostream&
|
||||
_os) const</font></tt></b>
|
||||
<br><b><tt><font color="#3366FF"> {</font></tt></b>
|
||||
<br><tt><font color="#3366FF"><b> </b>
|
||||
// First write the fitness</font></tt>
|
||||
<br><b><tt><font color="#3366FF">
|
||||
EO<FitT>::printOn(_os);</font></tt></b>
|
||||
<br><b><tt><font color="#3366FF">
|
||||
_os << ' ';</font></tt></b></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#FFCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><b><tt><font color="#3366FF">
|
||||
_os << b.size() << ' ' ;</font></tt></b>
|
||||
<br><b><tt><font color="#3366FF">
|
||||
for (unsigned i=0; i<b.size(); i++)</font></tt></b>
|
||||
<br><b><tt><font color="#3366FF">
|
||||
_os << b[i] << ' ' ;</font></tt></b></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><b><tt><font color="#3366FF"> }</font></tt></b>
|
||||
<p><tt><font color="#3366FF"><b> </b> /** reading... </font></tt>
|
||||
<br><tt><font color="#3366FF"> * of course, your readFrom must
|
||||
be able to read what printOn writes!!!</font></tt>
|
||||
<br><tt><font color="#3366FF"> */</font></tt>
|
||||
<br><b><tt><font color="#3366FF"> void readFrom(istream& _is)</font></tt></b>
|
||||
<br><b><tt><font color="#3366FF"> {</font></tt></b>
|
||||
<br><tt><font color="#3366FF"><b> </b> //
|
||||
of course you should read the fitness first!</font></tt>
|
||||
<br><b><tt><font color="#3366FF"> EO<FitT>::readFrom(_is);</font></tt></b></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#FFCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><b><tt><font color="#3366FF"> unsigned s;</font></tt></b>
|
||||
<br><b><tt><font color="#3366FF"> _is >> s;</font></tt></b>
|
||||
<br><b><tt><font color="#3366FF"> b.resize(s);</font></tt></b>
|
||||
<br><b><tt><font color="#3366FF"> for (unsigned
|
||||
i=0; i<s; i++)</font></tt></b>
|
||||
<br><b><tt><font color="#3366FF">
|
||||
{</font></tt></b>
|
||||
<br><b><tt><font color="#3366FF">
|
||||
bool bTmp;</font></tt></b>
|
||||
<br><b><tt><font color="#3366FF">
|
||||
_is >> bTmp;</font></tt></b>
|
||||
<br><b><tt><font color="#3366FF">
|
||||
b[i] = bTmp;</font></tt></b>
|
||||
<br><b><tt><font color="#3366FF">
|
||||
} </font></tt></b></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><b><tt><font color="#3366FF"> }</font></tt></b></td>
|
||||
</tr>
|
||||
</table>
|
||||
<a NAME="representation"></a>
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#FFCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><tt><font color="#999900"><b> </b> // brute setting (we could
|
||||
also have defined a Ctor from a vector<bool>)</font></tt>
|
||||
<br><b><tt><font color="#999900"> void setB(vector<bool> &
|
||||
_b)</font></tt></b>
|
||||
<br><b><tt><font color="#999900"> {</font></tt></b>
|
||||
<br><b><tt><font color="#999900"> b=_b;</font></tt></b>
|
||||
<br><b><tt><font color="#999900"> }</font></tt></b>
|
||||
<p><tt><font color="#999900"><b> </b> // brute accessing (we could
|
||||
also define operator[] ...)</font></tt>
|
||||
<br><b><tt><font color="#999900"> const vector<bool> & B()</font></tt></b>
|
||||
<br><b><tt><font color="#999900"> {</font></tt></b>
|
||||
<br><b><tt><font color="#999900"> return b;</font></tt></b>
|
||||
<br><b><tt><font color="#999900"> }</font></tt></b></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td>
|
||||
<br><tt><font color="#999900"><b>private: </b> //
|
||||
put all data here</font></tt></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#FFCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><b><tt><font color="#999900"> std::vector<bool> b;</font></tt></b></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table BORDER=0 CELLSPACING=0 COLS=1 WIDTH="100%" BGCOLOR="#CCCCCC" NOSAVE >
|
||||
<tr>
|
||||
<td><b><tt><font color="#999900">};</font></tt></b>
|
||||
<p><b><tt><font color="#999900">#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: Sat May
|
||||
4 06:02:46 2002<!-- hhmts end -->
|
||||
</body>
|
||||
</html>
|
||||
Reference in a new issue