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
83
trunk/paradiseo-eo/doc/html/t-eo_roulette_8cpp-source.html
Normal file
83
trunk/paradiseo-eo/doc/html/t-eo_roulette_8cpp-source.html
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
<!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-eoRoulette.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-eoRoulette.cpp</h1><div class="fragment"><pre class="fragment">00001
|
||||
00002 <span class="preprocessor">#include <eoPop.h></span>
|
||||
00003 <span class="preprocessor">#include <EO.h></span>
|
||||
00004 <span class="preprocessor">#include <eoProportionalSelect.h></span>
|
||||
00005 <span class="preprocessor">#include <eoStochasticUniversalSelect.h></span>
|
||||
00006
|
||||
00007 <span class="keyword">class </span>TestEO : <span class="keyword">public</span> EO<double> { <span class="keyword">public</span>: <span class="keywordtype">unsigned</span> index; };
|
||||
00008
|
||||
00009 <span class="keyword">using</span> <span class="keyword">namespace </span>std;
|
||||
00010
|
||||
00011 <span class="keyword">template</span> <<span class="keyword">class</span> Select>
|
||||
00012 <span class="keywordtype">int</span> test_select()
|
||||
00013 {
|
||||
00014 vector<double> probs(4);
|
||||
00015 probs[0] = 0.1;
|
||||
00016 probs[1] = 0.4;
|
||||
00017 probs[2] = 0.2;
|
||||
00018 probs[3] = 0.3;
|
||||
00019
|
||||
00020 vector<double> counts(4,0.0);
|
||||
00021
|
||||
00022 <span class="comment">// setup population</span>
|
||||
00023 <a class="code" href="classeo_pop.html">eoPop<TestEO></a> pop;
|
||||
00024 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < probs.size(); ++i)
|
||||
00025 {
|
||||
00026 pop.push_back( TestEO());
|
||||
00027 pop.back().fitness( probs[i] * 2.1232 ); <span class="comment">// some number to check scaling</span>
|
||||
00028 pop.back().index = i;
|
||||
00029 }
|
||||
00030
|
||||
00031 Select select;
|
||||
00032
|
||||
00033 <span class="keywordtype">unsigned</span> ndraws = 10000;
|
||||
00034
|
||||
00035 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < ndraws; ++i)
|
||||
00036 {
|
||||
00037 <span class="keyword">const</span> TestEO& eo = select(pop);
|
||||
00038
|
||||
00039 counts[eo.index]++;
|
||||
00040 }
|
||||
00041
|
||||
00042 cout << <span class="stringliteral">"Threshold = "</span> << 1./sqrt(<span class="keywordtype">double</span>(ndraws)) << endl;
|
||||
00043
|
||||
00044 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < 4; ++i)
|
||||
00045 {
|
||||
00046 cout << counts[i]/ndraws << <span class="charliteral">' '</span>;
|
||||
00047
|
||||
00048 <span class="keywordtype">double</span> c = counts[i]/ndraws;
|
||||
00049
|
||||
00050 <span class="keywordflow">if</span> (fabs(c - probs[i]) > 1./sqrt((<span class="keywordtype">double</span>)ndraws)) {
|
||||
00051 cout << <span class="stringliteral">"ERROR"</span> << endl;
|
||||
00052 <span class="keywordflow">return</span> 1;
|
||||
00053 }
|
||||
00054 }
|
||||
00055
|
||||
00056 cout << endl;
|
||||
00057 <span class="keywordflow">return</span> 0;
|
||||
00058 }
|
||||
00059
|
||||
00060 <span class="keywordtype">int</span> main()
|
||||
00061 {
|
||||
00062 rng.<a class="code" href="classeo_rng.html#a2">reseed</a>(44);
|
||||
00063
|
||||
00064 <span class="keywordflow">if</span> (test_select<eoProportionalSelect<TestEO> >()) <span class="keywordflow">return</span> 1;
|
||||
00065
|
||||
00066 <span class="keywordflow">return</span> test_select<eoStochasticUniversalSelect<TestEO> >();
|
||||
00067 }
|
||||
00068
|
||||
</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