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
123
trunk/paradiseo-eo/doc/html/t-eoinsertion_8cpp-source.html
Normal file
123
trunk/paradiseo-eo/doc/html/t-eoinsertion_8cpp-source.html
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
<!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-eoinsertion.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-eoinsertion.cpp</h1><div class="fragment"><pre class="fragment">00001 <span class="comment">//-----------------------------------------------------------------------------</span>
|
||||
00002 <span class="comment">// t-eoinsertion.cpp</span>
|
||||
00003 <span class="comment">//-----------------------------------------------------------------------------</span>
|
||||
00004
|
||||
00005 <span class="preprocessor">#include <eo></span> <span class="comment">// eoBin, eoPop, eoInsertion</span>
|
||||
00006
|
||||
00007 <span class="comment">//-----------------------------------------------------------------------------</span>
|
||||
00008
|
||||
00009 <span class="keyword">typedef</span> eoBin<float> Chrom;
|
||||
00010
|
||||
00011 <span class="comment">//-----------------------------------------------------------------------------</span>
|
||||
00012
|
||||
00013 <span class="keywordtype">void</span> binary_value(Chrom& chrom)
|
||||
00014 {
|
||||
00015 <span class="keywordtype">float</span> sum = 0;
|
||||
00016 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < chrom.size(); i++)
|
||||
00017 <span class="keywordflow">if</span> (chrom[i])
|
||||
00018 sum += pow(2, chrom.size() - i - 1);
|
||||
00019 chrom.fitness(sum);
|
||||
00020 }
|
||||
00021
|
||||
00022 <span class="comment">//-----------------------------------------------------------------------------</span>
|
||||
00023
|
||||
00024 main()
|
||||
00025 {
|
||||
00026 <span class="keyword">const</span> <span class="keywordtype">unsigned</span> CHROM_SIZE = 4;
|
||||
00027 <span class="keywordtype">unsigned</span> i;
|
||||
00028
|
||||
00029 eoBinRandom<Chrom> random;
|
||||
00030
|
||||
00031 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> POP_SIZE = 4; POP_SIZE <=6; POP_SIZE++)
|
||||
00032 {
|
||||
00033 <a class="code" href="classeo_pop.html">eoPop<Chrom></a> pop;
|
||||
00034
|
||||
00035 <span class="keywordflow">for</span> (i = 0; i < POP_SIZE; i++)
|
||||
00036 {
|
||||
00037 Chrom chrom(CHROM_SIZE);
|
||||
00038 random(chrom);
|
||||
00039 binary_value(chrom);
|
||||
00040 pop.push_back(chrom);
|
||||
00041 }
|
||||
00042
|
||||
00043 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> POP2_SIZE = 4; POP2_SIZE <=6; POP2_SIZE++)
|
||||
00044 {
|
||||
00045 <a class="code" href="classeo_pop.html">eoPop<Chrom></a> pop2, pop3, pop4, pop5, popx;
|
||||
00046
|
||||
00047 <span class="keywordflow">for</span> (i = 0; i < POP2_SIZE; i++)
|
||||
00048 {
|
||||
00049 Chrom chrom(CHROM_SIZE);
|
||||
00050 random(chrom);
|
||||
00051 binary_value(chrom);
|
||||
00052 pop2.push_back(chrom);
|
||||
00053 }
|
||||
00054
|
||||
00055 std::cout << <span class="stringliteral">"--------------------------------------------------"</span> << std::endl
|
||||
00056 << <span class="stringliteral">"breeders \tpop"</span> << std::endl
|
||||
00057 << <span class="stringliteral">"--------------------------------------------------"</span> << std::endl;
|
||||
00058 <span class="keywordflow">for</span> (i = 0; i < max(pop.size(), pop2.size()); i++)
|
||||
00059 {
|
||||
00060 <span class="keywordflow">if</span> (pop.size() > i)
|
||||
00061 std::cout << pop[i] << <span class="stringliteral">" "</span> << pop[i].fitness() << <span class="stringliteral">" \t"</span>;
|
||||
00062 <span class="keywordflow">else</span>
|
||||
00063 std::cout << <span class="stringliteral">"\t\t"</span>;
|
||||
00064 <span class="keywordflow">if</span> (pop2.size() > i)
|
||||
00065 std::cout << pop2[i] << <span class="stringliteral">" "</span> << pop2[i].fitness();
|
||||
00066 std::cout << std::endl;
|
||||
00067 }
|
||||
00068
|
||||
00069 eoInsertion<Chrom> insertion(0.75);
|
||||
00070 popx = pop;
|
||||
00071 pop3 = pop2;
|
||||
00072 insertion(popx, pop3);
|
||||
00073
|
||||
00074 eoInsertion<Chrom> insertion2;
|
||||
00075 popx = pop;
|
||||
00076 pop4 = pop2;
|
||||
00077 insertion2(popx, pop4);
|
||||
00078
|
||||
00079 eoInsertion<Chrom> insertion3(1.5);
|
||||
00080 popx = pop;
|
||||
00081 pop5 = pop2;
|
||||
00082 insertion3(popx, pop5);
|
||||
00083
|
||||
00084 std::cout << std::endl
|
||||
00085 << <span class="stringliteral">"0.75 \t\t1.0 \t\t1.5"</span> << std::endl
|
||||
00086 << <span class="stringliteral">"---- \t\t--- \t\t---"</span> << std::endl;
|
||||
00087 <span class="keywordflow">for</span> (i = 0; i < pop5.size(); i++)
|
||||
00088 {
|
||||
00089 <span class="keywordflow">if</span> (pop3.size() > i)
|
||||
00090 std::cout << pop3[i] << <span class="stringliteral">" "</span> << pop3[i].fitness() << <span class="stringliteral">" \t"</span>;
|
||||
00091 <span class="keywordflow">else</span>
|
||||
00092 std::cout << <span class="stringliteral">" \t\t"</span>;
|
||||
00093 <span class="keywordflow">if</span> (pop4.size() > i)
|
||||
00094 std::cout << pop4[i] << <span class="stringliteral">" "</span> << pop4[i].fitness() << <span class="stringliteral">" \t"</span>;
|
||||
00095 <span class="keywordflow">else</span>
|
||||
00096 std::cout << <span class="stringliteral">" \t\t"</span>;
|
||||
00097 <span class="keywordflow">if</span> (pop5.size() > i)
|
||||
00098 std::cout << pop5[i] << <span class="stringliteral">" "</span> << pop5[i].fitness();
|
||||
00099 std::cout << std::endl;
|
||||
00100 }
|
||||
00101 }
|
||||
00102 }
|
||||
00103
|
||||
00104 <span class="keywordflow">return</span> 0;
|
||||
00105 }
|
||||
00106
|
||||
00107 <span class="comment">//-----------------------------------------------------------------------------</span>
|
||||
00108
|
||||
</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