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
115
trunk/paradiseo-eo/doc/html/eo_sharing_8h-source.html
Normal file
115
trunk/paradiseo-eo/doc/html/eo_sharing_8h-source.html
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
<!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: eoSharing.h 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_000000.html">src</a></div>
|
||||
<h1>eoSharing.h</h1><div class="fragment"><pre class="fragment">00001
|
||||
00024 <span class="comment">//-----------------------------------------------------------------------------</span>
|
||||
00025
|
||||
00026 <span class="preprocessor">#ifndef eoSharing_h</span>
|
||||
00027 <span class="preprocessor"></span><span class="preprocessor">#define eoSharing_h</span>
|
||||
00028 <span class="preprocessor"></span>
|
||||
00029 <span class="preprocessor">#include <eoPerf2Worth.h></span>
|
||||
00030 <span class="preprocessor">#include <utils/eoDistance.h></span>
|
||||
00031
|
||||
<a name="l00037"></a><a class="code" href="classd_matrix.html">00037</a> <span class="keyword">class </span><a class="code" href="classd_matrix.html">dMatrix</a> : <span class="keyword">public</span> std::vector<double>
|
||||
00038 {
|
||||
00039 <span class="keyword">public</span>:
|
||||
00040 <span class="comment">// Ctor : sets size</span>
|
||||
00041 <a class="code" href="classd_matrix.html">dMatrix</a>(<span class="keywordtype">unsigned</span> _s) : std::vector<double>(_s*_s), rSize(_s) {}
|
||||
00042
|
||||
<a name="l00044"></a><a class="code" href="classd_matrix.html#a1">00044</a> <span class="keywordtype">double</span> <a class="code" href="classd_matrix.html#a1">operator()</a>(<span class="keywordtype">unsigned</span> _i, <span class="keywordtype">unsigned</span> _j)<span class="keyword"> const</span>
|
||||
00045 <span class="keyword"> </span>{
|
||||
00046 <span class="keywordflow">return</span> this->operator[](_i*rSize + _j);
|
||||
00047 }
|
||||
00048
|
||||
<a name="l00050"></a><a class="code" href="classd_matrix.html#a2">00050</a> <span class="keywordtype">double</span> & <a class="code" href="classd_matrix.html#a1">operator()</a>(<span class="keywordtype">unsigned</span> _i, <span class="keywordtype">unsigned</span> _j)
|
||||
00051 {
|
||||
00052 <span class="keywordflow">return</span> this->operator[](_i*rSize + _j);
|
||||
00053 }
|
||||
00054
|
||||
<a name="l00056"></a><a class="code" href="classd_matrix.html#a3">00056</a> <span class="keywordtype">void</span> <a class="code" href="classd_matrix.html#a3">printOn</a>(std::ostream & _os)
|
||||
00057 {
|
||||
00058 <span class="keywordtype">unsigned</span> index=0;
|
||||
00059 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i=0; i<rSize; i++)
|
||||
00060 {
|
||||
00061 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> j=0; j<rSize; j++)
|
||||
00062 _os << this->operator[](index++) << <span class="stringliteral">" "</span> ;
|
||||
00063 _os << std::endl;
|
||||
00064 }
|
||||
00065 _os << std::endl;
|
||||
00066 }
|
||||
00067
|
||||
00068 <span class="keyword">private</span>:
|
||||
00069 <span class="keywordtype">unsigned</span> rSize; <span class="comment">// row size (== number of columns!)</span>
|
||||
00070 };
|
||||
00071
|
||||
00072
|
||||
00078 <span class="keyword">template</span> <<span class="keyword">class</span> EOT>
|
||||
<a name="l00079"></a><a class="code" href="classeo_sharing.html">00079</a> <span class="keyword">class </span><a class="code" href="classeo_sharing.html">eoSharing</a> : <span class="keyword">public</span> <a class="code" href="classeo_perf2_worth.html">eoPerf2Worth</a><EOT>
|
||||
00080 {
|
||||
00081 <span class="keyword">public</span>:
|
||||
00082
|
||||
00083 <span class="keyword">using</span> <a class="code" href="classeo_perf2_worth.html">eoPerf2Worth<EOT></a>::value;
|
||||
00084
|
||||
00085
|
||||
00086 <span class="comment">/* Ctor requires a distance - cannot have a default distance! */</span>
|
||||
00087 <a class="code" href="classeo_sharing.html">eoSharing</a>(<span class="keywordtype">double</span> _nicheSize, <a class="code" href="classeo_distance.html">eoDistance<EOT></a> & _dist) : <a class="code" href="classeo_perf2_worth.html">eoPerf2Worth<EOT></a>(<span class="stringliteral">"Sharing"</span>),
|
||||
00088 nicheSize(_nicheSize),
|
||||
00089 dist(_dist)
|
||||
00090 {}
|
||||
00091
|
||||
<a name="l00094"></a><a class="code" href="classeo_sharing.html#a1">00094</a> <span class="keywordtype">void</span> <a class="code" href="classeo_sharing.html#a1">operator()</a>(<span class="keyword">const</span> <a class="code" href="classeo_pop.html">eoPop<EOT></a>& _pop)
|
||||
00095 {
|
||||
00096 <span class="keywordtype">unsigned</span> i, j,
|
||||
00097 pSize=_pop.size();
|
||||
00098 <span class="keywordflow">if</span> (pSize <= 1)
|
||||
00099 <span class="keywordflow">throw</span> std::runtime_error(<span class="stringliteral">"Apptempt to do sharing with population of size 1"</span>);
|
||||
00100 <a class="code" href="classeo_value_param.html#a2">value</a>().resize(pSize);
|
||||
00101 std::vector<double> sim(pSize); <span class="comment">// to hold the similarities</span>
|
||||
00102 <a class="code" href="classd_matrix.html">dMatrix</a> distMatrix(pSize*(pSize-1)/2); <span class="comment">// to hold the distances</span>
|
||||
00103
|
||||
00104 <span class="comment">// compute the similarities (wrong name for distMatrix, I know)</span>
|
||||
00105 distMatrix(0,0)=1;
|
||||
00106 <span class="keywordflow">for</span> (i=1; i<pSize; i++)
|
||||
00107 {
|
||||
00108 distMatrix(i,i)=1;
|
||||
00109 <span class="keywordflow">for</span> (j=0; j<i; j++)
|
||||
00110 {
|
||||
00111 <span class="keywordtype">double</span> d = dist(_pop[i], _pop[j]);
|
||||
00112 distMatrix(i,j) =
|
||||
00113 distMatrix(j,i) = ( d>nicheSize ? 0 : 1-(d/nicheSize) );
|
||||
00114 }
|
||||
00115 }
|
||||
00116
|
||||
00117 <span class="keywordflow">for</span> (i=0; i<pSize; i++)
|
||||
00118 {
|
||||
00119 <span class="keywordtype">double</span> sum=0.0;
|
||||
00120 <span class="keywordflow">for</span> (j=0; j<pSize; j++)
|
||||
00121 sum += distMatrix(i,j);
|
||||
00122 sim[i] = sum;
|
||||
00123 }
|
||||
00124
|
||||
00125 <span class="comment">// now set the worthes values</span>
|
||||
00126 <span class="keywordflow">for</span> (i = 0; i < _pop.size(); ++i)
|
||||
00127 <a class="code" href="classeo_value_param.html#a2">value</a>()[i]=_pop[i].fitness()/sim[i];
|
||||
00128 }
|
||||
00129 <span class="comment">// private data of class eoSharing</span>
|
||||
00130 <span class="keyword">private</span>:
|
||||
00131 <span class="keywordtype">double</span> nicheSize;
|
||||
00132 <a class="code" href="classeo_distance.html">eoDistance<EOT></a> & dist; <span class="comment">// specific distance</span>
|
||||
00133 };
|
||||
00134
|
||||
00135
|
||||
00136
|
||||
00137 <span class="preprocessor">#endif</span>
|
||||
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:38 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