git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@497 331e1502-861f-0410-8da2-ba01fb791d7f
131 lines
13 KiB
HTML
131 lines
13 KiB
HTML
<!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>ParadisEO-MOEO: moeoSharingDiversityAssignment.h Source File</title>
|
|
<link href="doxygen.css" rel="stylesheet" type="text/css">
|
|
<link href="tabs.css" rel="stylesheet" type="text/css">
|
|
</head><body>
|
|
<!-- Generated by Doxygen 1.4.7 -->
|
|
<div class="tabs">
|
|
<ul>
|
|
<li><a href="main.html"><span>Main Page</span></a></li>
|
|
<li><a href="classes.html"><span>Classes</span></a></li>
|
|
<li id="current"><a href="files.html"><span>Files</span></a></li>
|
|
<li>
|
|
<form action="search.php" method="get">
|
|
<table cellspacing="0" cellpadding="0" border="0">
|
|
<tr>
|
|
<td><label> <u>S</u>earch for </label></td>
|
|
<td><input type="text" name="query" value="" size="20" accesskey="s"/></td>
|
|
</tr>
|
|
</table>
|
|
</form>
|
|
</li>
|
|
</ul></div>
|
|
<h1>moeoSharingDiversityAssignment.h</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-</span>
|
|
<a name="l00002"></a>00002
|
|
<a name="l00003"></a>00003 <span class="comment">//-----------------------------------------------------------------------------</span>
|
|
<a name="l00004"></a>00004 <span class="comment">// moeoSharingDiversityAssignment.h</span>
|
|
<a name="l00005"></a>00005 <span class="comment">// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007</span>
|
|
<a name="l00006"></a>00006 <span class="comment">/*</span>
|
|
<a name="l00007"></a>00007 <span class="comment"> This library...</span>
|
|
<a name="l00008"></a>00008 <span class="comment"></span>
|
|
<a name="l00009"></a>00009 <span class="comment"> Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr</span>
|
|
<a name="l00010"></a>00010 <span class="comment"> */</span>
|
|
<a name="l00011"></a>00011 <span class="comment">//-----------------------------------------------------------------------------</span>
|
|
<a name="l00012"></a>00012
|
|
<a name="l00013"></a>00013 <span class="preprocessor">#ifndef MOEOSHARINGDIVERSITYASSIGNMENT_H_</span>
|
|
<a name="l00014"></a>00014 <span class="preprocessor"></span><span class="preprocessor">#define MOEOSHARINGDIVERSITYASSIGNMENT_H_</span>
|
|
<a name="l00015"></a>00015 <span class="preprocessor"></span>
|
|
<a name="l00016"></a>00016 <span class="preprocessor">#include <eoPop.h></span>
|
|
<a name="l00017"></a>00017 <span class="preprocessor">#include <comparator/moeoDiversityThenFitnessComparator.h></span>
|
|
<a name="l00018"></a>00018 <span class="preprocessor">#include <distance/moeoDistance.h></span>
|
|
<a name="l00019"></a>00019 <span class="preprocessor">#include <distance/moeoDistanceMatrix.h></span>
|
|
<a name="l00020"></a>00020 <span class="preprocessor">#include <distance/moeoEuclideanDistance.h></span>
|
|
<a name="l00021"></a>00021 <span class="preprocessor">#include <diversity/moeoDiversityAssignment.h></span>
|
|
<a name="l00022"></a>00022
|
|
<a name="l00027"></a>00027 <span class="keyword">template</span> < <span class="keyword">class</span> MOEOT >
|
|
<a name="l00028"></a><a class="code" href="classmoeoSharingDiversityAssignment.html">00028</a> <span class="keyword">class </span><a class="code" href="classmoeoSharingDiversityAssignment.html">moeoSharingDiversityAssignment</a> : <span class="keyword">public</span> <a class="code" href="classmoeoDiversityAssignment.html">moeoDiversityAssignment</a> < MOEOT >
|
|
<a name="l00029"></a>00029 {
|
|
<a name="l00030"></a>00030 <span class="keyword">public</span>:
|
|
<a name="l00031"></a>00031
|
|
<a name="l00033"></a><a class="code" href="classmoeoSharingDiversityAssignment.html#5e92f136f41363dcb8a6df94dbf2f3b3">00033</a> <span class="keyword">typedef</span> <span class="keyword">typename</span> MOEOT::ObjectiveVector <a class="code" href="classmoeoSharingDiversityAssignment.html#5e92f136f41363dcb8a6df94dbf2f3b3">ObjectiveVector</a>;
|
|
<a name="l00034"></a>00034
|
|
<a name="l00035"></a>00035
|
|
<a name="l00042"></a><a class="code" href="classmoeoSharingDiversityAssignment.html#10ba0d2cdd57ce47244afdf4b1623409">00042</a> <a class="code" href="classmoeoSharingDiversityAssignment.html#10ba0d2cdd57ce47244afdf4b1623409">moeoSharingDiversityAssignment</a>(<a class="code" href="classmoeoDistance.html">moeoDistance<MOEOT,double></a> & _distance, <span class="keywordtype">double</span> _nicheSize = 0.5, <span class="keywordtype">double</span> _alpha = 1.0) : <a class="code" href="classmoeoSharingDiversityAssignment.html#b81d950d0469ebd4c769994bcea58f8b">distance</a>(_distance), <a class="code" href="classmoeoSharingDiversityAssignment.html#175d978d4b56603a3bcb45fec8395441">nicheSize</a>(_nicheSize), <a class="code" href="classmoeoSharingDiversityAssignment.html#95ed49448a35d5b99cdfd496a33fd45b">alpha</a>(_alpha)
|
|
<a name="l00043"></a>00043 {}
|
|
<a name="l00044"></a>00044
|
|
<a name="l00045"></a>00045
|
|
<a name="l00051"></a><a class="code" href="classmoeoSharingDiversityAssignment.html#ccc66529da0cacd3f11a019ebe646668">00051</a> <a class="code" href="classmoeoSharingDiversityAssignment.html#10ba0d2cdd57ce47244afdf4b1623409">moeoSharingDiversityAssignment</a>(<span class="keywordtype">double</span> _nicheSize = 0.5, <span class="keywordtype">double</span> _alpha = 1.0) : <a class="code" href="classmoeoSharingDiversityAssignment.html#b81d950d0469ebd4c769994bcea58f8b">distance</a>(<a class="code" href="classmoeoSharingDiversityAssignment.html#ecde6f1a0ba15d9ec563396a585188f0">defaultDistance</a>), <a class="code" href="classmoeoSharingDiversityAssignment.html#175d978d4b56603a3bcb45fec8395441">nicheSize</a>(_nicheSize), <a class="code" href="classmoeoSharingDiversityAssignment.html#95ed49448a35d5b99cdfd496a33fd45b">alpha</a>(_alpha)
|
|
<a name="l00052"></a>00052 {}
|
|
<a name="l00053"></a>00053
|
|
<a name="l00054"></a>00054
|
|
<a name="l00059"></a><a class="code" href="classmoeoSharingDiversityAssignment.html#6228be85e166172cf03def1a004505d5">00059</a> <span class="keywordtype">void</span> <a class="code" href="classmoeoSharingDiversityAssignment.html#6228be85e166172cf03def1a004505d5">operator()</a>(eoPop < MOEOT > & _pop)
|
|
<a name="l00060"></a>00060 {
|
|
<a name="l00061"></a>00061 <span class="comment">// 1 - set simuilarities</span>
|
|
<a name="l00062"></a>00062 <a class="code" href="classmoeoSharingDiversityAssignment.html#c01f6ac1abba3799f5c4b6c0608dac55">setSimilarities</a>(_pop);
|
|
<a name="l00063"></a>00063 <span class="comment">// 2 - a higher diversity is better, so the values need to be inverted</span>
|
|
<a name="l00064"></a>00064 moeoDiversityThenFitnessComparator < MOEOT > divComparator;
|
|
<a name="l00065"></a>00065 <span class="keywordtype">double</span> max = std::max_element(_pop.begin(), _pop.end(), divComparator)->diversity();
|
|
<a name="l00066"></a>00066 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i=0 ; i<_pop.size() ; i++)
|
|
<a name="l00067"></a>00067 {
|
|
<a name="l00068"></a>00068 _pop[i].diversity(max - _pop[i].diversity());
|
|
<a name="l00069"></a>00069 }
|
|
<a name="l00070"></a>00070 }
|
|
<a name="l00071"></a>00071
|
|
<a name="l00072"></a>00072
|
|
<a name="l00080"></a><a class="code" href="classmoeoSharingDiversityAssignment.html#21c8d6e020af23b2be219b7e02248300">00080</a> <span class="keywordtype">void</span> <a class="code" href="classmoeoSharingDiversityAssignment.html#21c8d6e020af23b2be219b7e02248300">updateByDeleting</a>(eoPop < MOEOT > & _pop, <a class="code" href="classmoeoSharingDiversityAssignment.html#5e92f136f41363dcb8a6df94dbf2f3b3">ObjectiveVector</a> & _objVec)
|
|
<a name="l00081"></a>00081 {
|
|
<a name="l00082"></a>00082 std::cout << <span class="stringliteral">"WARNING : updateByDeleting not implemented in moeoSharingDiversityAssignment"</span> << std::endl;
|
|
<a name="l00083"></a>00083 }
|
|
<a name="l00084"></a>00084
|
|
<a name="l00085"></a>00085
|
|
<a name="l00086"></a>00086 <span class="keyword">protected</span>:
|
|
<a name="l00087"></a>00087
|
|
<a name="l00089"></a><a class="code" href="classmoeoSharingDiversityAssignment.html#b81d950d0469ebd4c769994bcea58f8b">00089</a> moeoDistance < MOEOT , double > & <a class="code" href="classmoeoSharingDiversityAssignment.html#b81d950d0469ebd4c769994bcea58f8b">distance</a>;
|
|
<a name="l00091"></a><a class="code" href="classmoeoSharingDiversityAssignment.html#ecde6f1a0ba15d9ec563396a585188f0">00091</a> moeoEuclideanDistance < MOEOT > <a class="code" href="classmoeoSharingDiversityAssignment.html#ecde6f1a0ba15d9ec563396a585188f0">defaultDistance</a>;
|
|
<a name="l00093"></a><a class="code" href="classmoeoSharingDiversityAssignment.html#175d978d4b56603a3bcb45fec8395441">00093</a> <span class="keywordtype">double</span> <a class="code" href="classmoeoSharingDiversityAssignment.html#175d978d4b56603a3bcb45fec8395441">nicheSize</a>;
|
|
<a name="l00095"></a><a class="code" href="classmoeoSharingDiversityAssignment.html#95ed49448a35d5b99cdfd496a33fd45b">00095</a> <span class="keywordtype">double</span> <a class="code" href="classmoeoSharingDiversityAssignment.html#95ed49448a35d5b99cdfd496a33fd45b">alpha</a>;
|
|
<a name="l00096"></a>00096
|
|
<a name="l00097"></a>00097
|
|
<a name="l00102"></a><a class="code" href="classmoeoSharingDiversityAssignment.html#c01f6ac1abba3799f5c4b6c0608dac55">00102</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classmoeoSharingDiversityAssignment.html#c01f6ac1abba3799f5c4b6c0608dac55">setSimilarities</a>(eoPop < MOEOT > & _pop)
|
|
<a name="l00103"></a>00103 {
|
|
<a name="l00104"></a>00104 <span class="comment">// compute distances between every individuals</span>
|
|
<a name="l00105"></a>00105 moeoDistanceMatrix < MOEOT , double > <a class="codeRef" doxygen="eo.doxytag:../../../paradiseo-eo/doc/html/" href="../../../paradiseo-eo/doc/html/classd_matrix.html">dMatrix</a> (_pop.size(), <a class="code" href="classmoeoSharingDiversityAssignment.html#b81d950d0469ebd4c769994bcea58f8b">distance</a>);
|
|
<a name="l00106"></a>00106 <a class="codeRef" doxygen="eo.doxytag:../../../paradiseo-eo/doc/html/" href="../../../paradiseo-eo/doc/html/classd_matrix.html">dMatrix</a>(_pop);
|
|
<a name="l00107"></a>00107 <span class="comment">// compute similarities</span>
|
|
<a name="l00108"></a>00108 <span class="keywordtype">double</span> sum;
|
|
<a name="l00109"></a>00109 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i=0; i<_pop.size(); i++)
|
|
<a name="l00110"></a>00110 {
|
|
<a name="l00111"></a>00111 sum = 0.0;
|
|
<a name="l00112"></a>00112 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> j=0; j<_pop.size(); j++)
|
|
<a name="l00113"></a>00113 {
|
|
<a name="l00114"></a>00114 sum += <a class="code" href="classmoeoSharingDiversityAssignment.html#5b5daaa55e97c6fcd172d61c7837e26c">sh</a>(dMatrix[i][j]);
|
|
<a name="l00115"></a>00115 }
|
|
<a name="l00116"></a>00116 _pop[i].diversity(sum);
|
|
<a name="l00117"></a>00117 }
|
|
<a name="l00118"></a>00118 }
|
|
<a name="l00119"></a>00119
|
|
<a name="l00120"></a>00120
|
|
<a name="l00125"></a><a class="code" href="classmoeoSharingDiversityAssignment.html#5b5daaa55e97c6fcd172d61c7837e26c">00125</a> <span class="keywordtype">double</span> <a class="code" href="classmoeoSharingDiversityAssignment.html#5b5daaa55e97c6fcd172d61c7837e26c">sh</a>(<span class="keywordtype">double</span> _dist)
|
|
<a name="l00126"></a>00126 {
|
|
<a name="l00127"></a>00127 <span class="keywordtype">double</span> result;
|
|
<a name="l00128"></a>00128 <span class="keywordflow">if</span> (_dist < <a class="code" href="classmoeoSharingDiversityAssignment.html#175d978d4b56603a3bcb45fec8395441">nicheSize</a>)
|
|
<a name="l00129"></a>00129 {
|
|
<a name="l00130"></a>00130 result = 1.0 - pow(_dist / <a class="code" href="classmoeoSharingDiversityAssignment.html#175d978d4b56603a3bcb45fec8395441">nicheSize</a>, <a class="code" href="classmoeoSharingDiversityAssignment.html#95ed49448a35d5b99cdfd496a33fd45b">alpha</a>);
|
|
<a name="l00131"></a>00131 }
|
|
<a name="l00132"></a>00132 <span class="keywordflow">else</span>
|
|
<a name="l00133"></a>00133 {
|
|
<a name="l00134"></a>00134 result = 0.0;
|
|
<a name="l00135"></a>00135 }
|
|
<a name="l00136"></a>00136 <span class="keywordflow">return</span> result;
|
|
<a name="l00137"></a>00137 }
|
|
<a name="l00138"></a>00138
|
|
<a name="l00139"></a>00139 };
|
|
<a name="l00140"></a>00140
|
|
<a name="l00141"></a>00141
|
|
<a name="l00142"></a>00142 <span class="preprocessor">#endif </span><span class="comment">/*MOEOSHARINGDIVERSITYASSIGNMENT_H_*/</span>
|
|
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Mon Jul 2 16:05:01 2007 for ParadisEO-MOEO by
|
|
<a href="http://www.doxygen.org/index.html">
|
|
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.7 </small></address>
|
|
</body>
|
|
</html>
|