Paradiseo-eo sources added
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@40 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
bc1f453978
commit
c3aec878e5
3609 changed files with 342772 additions and 0 deletions
69
trunk/paradiseo-eo/doc/html/t-eolottery_8cpp-source.html
Normal file
69
trunk/paradiseo-eo/doc/html/t-eolottery_8cpp-source.html
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
|
||||
<title>EO: t-eolottery.cpp Source File</title>
|
||||
<link href="doxygen.css" rel="stylesheet" type="text/css">
|
||||
</head><body>
|
||||
<!-- Generated by Doxygen 1.3.9.1 -->
|
||||
<div class="qindex"> <form class="search" action="search.php" method="get">
|
||||
<a class="qindex" href="main.html">Main Page</a> | <a class="qindex" href="modules.html">Modules</a> | <a class="qindex" href="namespaces.html">Namespace List</a> | <a class="qindex" href="hierarchy.html">Class Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical List</a> | <a class="qindex" href="annotated.html">Class List</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="namespacemembers.html">Namespace Members</a> | <a class="qindex" href="functions.html">Class Members</a> | <a class="qindex" href="pages.html">Related Pages</a> | <span class="search"><u>S</u>earch for <input class="search" type="text" name="query" value="" size="20" accesskey="s"/></span></form></div>
|
||||
<div class="nav">
|
||||
<a class="el" href="dir_000002.html">test</a></div>
|
||||
<h1>t-eolottery.cpp</h1><div class="fragment"><pre class="fragment">00001 <span class="comment">//-----------------------------------------------------------------------------</span>
|
||||
00002 <span class="comment">// t-eolottery.cpp</span>
|
||||
00003 <span class="comment">//-----------------------------------------------------------------------------</span>
|
||||
00004
|
||||
00005 <span class="preprocessor">#include <eo></span> <span class="comment">// eoBin, eoPop, eoLottery</span>
|
||||
00006
|
||||
00007 <span class="comment">//-----------------------------------------------------------------------------</span>
|
||||
00008
|
||||
00009 <span class="keyword">typedef</span> eoBin<float> Chrom;
|
||||
00010
|
||||
00011 <span class="keywordtype">void</span> binary_value(Chrom& chrom)
|
||||
00012 {
|
||||
00013 <span class="keywordtype">float</span> sum = 0;
|
||||
00014 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < chrom.size(); i++)
|
||||
00015 <span class="keywordflow">if</span> (chrom[i])
|
||||
00016 sum += pow(2, i);
|
||||
00017 chrom.fitness(sum);
|
||||
00018 }
|
||||
00019
|
||||
00020 <span class="comment">//-----------------------------------------------------------------------------</span>
|
||||
00021
|
||||
00022 main()
|
||||
00023 {
|
||||
00024 <span class="keyword">const</span> <span class="keywordtype">unsigned</span> POP_SIZE = 8, CHROM_SIZE = 4;
|
||||
00025
|
||||
00026 <a class="code" href="classeo_pop.html">eoPop<Chrom></a> pop, pop2;
|
||||
00027 eoBinRandom<Chrom> random;
|
||||
00028 <span class="keywordtype">unsigned</span> i;
|
||||
00029
|
||||
00030 <span class="keywordflow">for</span> (i = 0; i < POP_SIZE; i++)
|
||||
00031 {
|
||||
00032 Chrom chrom(CHROM_SIZE);
|
||||
00033 random(chrom);
|
||||
00034 binary_value(chrom);
|
||||
00035 pop.push_back(chrom);
|
||||
00036 }
|
||||
00037
|
||||
00038 std::cout << <span class="stringliteral">"original population:"</span> << std::endl;
|
||||
00039 sort(pop.begin(), pop.end());
|
||||
00040 <span class="keywordflow">for</span> (i = 0; i < pop.size(); i++)
|
||||
00041 std::cout << pop[i] << <span class="stringliteral">" "</span> << pop[i].fitness() << std::endl;
|
||||
00042
|
||||
00043 eoLottery<Chrom> lottery;
|
||||
00044 lottery(pop, pop2);
|
||||
00045
|
||||
00046 std::cout << <span class="stringliteral">"selected by lottery population:"</span> << std::endl;
|
||||
00047 sort(pop2.begin(), pop2.end());
|
||||
00048 <span class="keywordflow">for</span> (i = 0; i < pop2.size(); i++)
|
||||
00049 std::cout << pop2[i] << <span class="stringliteral">" "</span> << pop2[i].fitness() << std::endl;
|
||||
00050
|
||||
00051 <span class="keywordflow">return</span> 0;
|
||||
00052 }
|
||||
00053
|
||||
00054 <span class="comment">//-----------------------------------------------------------------------------</span>
|
||||
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:43 2006 for EO by
|
||||
<a href="http://www.doxygen.org/index.html">
|
||||
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.3.9.1 </small></address>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Add a link
Reference in a new issue