git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@40 331e1502-861f-0410-8da2-ba01fb791d7f
133 lines
11 KiB
HTML
133 lines
11 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>EO: VirusOp.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_000007.html">contrib</a> / <a class="el" href="dir_000015.html">MGE</a></div>
|
|
<h1>VirusOp.h</h1><div class="fragment"><pre class="fragment">00001 <span class="comment">/*</span>
|
|
00002 <span class="comment"> ViruOp.h</span>
|
|
00003 <span class="comment"> (c) GeNeura Team 2001, Marc Schoenauer 2000</span>
|
|
00004 <span class="comment"></span>
|
|
00005 <span class="comment"> This library is free software; you can redistribute it and/or</span>
|
|
00006 <span class="comment"> modify it under the terms of the GNU Lesser General Public</span>
|
|
00007 <span class="comment"> License as published by the Free Software Foundation; either</span>
|
|
00008 <span class="comment"> version 2 of the License, or (at your option) any later version.</span>
|
|
00009 <span class="comment"></span>
|
|
00010 <span class="comment"> This library is distributed in the hope that it will be useful,</span>
|
|
00011 <span class="comment"> but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
|
|
00012 <span class="comment"> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</span>
|
|
00013 <span class="comment"> Lesser General Public License for more details.</span>
|
|
00014 <span class="comment"></span>
|
|
00015 <span class="comment"> You should have received a copy of the GNU Lesser General Public</span>
|
|
00016 <span class="comment"> License along with this library; if not, write to the Free Software</span>
|
|
00017 <span class="comment"> Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>
|
|
00018 <span class="comment"></span>
|
|
00019 <span class="comment"> Contact: todos@geneura.ugr.es, http://geneura.ugr.es</span>
|
|
00020 <span class="comment"> Marc.Schoenauer@polytechnique.fr</span>
|
|
00021 <span class="comment">CVS Info: $Date: 2003/02/27 19:26:43 $ $Header: /cvsroot/eodev/eo/contrib/MGE/VirusOp.h,v 1.3 2003/02/27 19:26:43 okoenig Exp $ $Author: okoenig $</span>
|
|
00022 <span class="comment">*/</span>
|
|
00023
|
|
00024 <span class="preprocessor">#ifndef VirusOp_h</span>
|
|
00025 <span class="preprocessor"></span><span class="preprocessor">#define VirusOp_h</span>
|
|
00026 <span class="preprocessor"></span>
|
|
00027 <span class="comment">//-----------------------------------------------------------------------------</span>
|
|
00028
|
|
00029 <span class="preprocessor">#include <iostream></span> <span class="comment">// ostream, istream</span>
|
|
00030 <span class="preprocessor">#include <functional></span> <span class="comment">// bind2nd</span>
|
|
00031 <span class="preprocessor">#include <string></span> <span class="comment">// std::string</span>
|
|
00032
|
|
00033 <span class="preprocessor">#include <utils/eoRNG.h></span>
|
|
00034 <span class="preprocessor">#include "../contrib/MGE/eoVirus.h"</span>
|
|
00035
|
|
00039 <span class="keyword">template</span><<span class="keyword">class</span> FitT>
|
|
<a name="l00040"></a><a class="code" href="class_virus_bit_flip.html">00040</a> <span class="keyword">class </span><a class="code" href="class_virus_bit_flip.html">VirusBitFlip</a>: <span class="keyword">public</span> <a class="code" href="classeo_mon_op.html">eoMonOp</a><eoVirus<FitT> > {
|
|
00041 <span class="keyword">public</span>:
|
|
<a name="l00043"></a><a class="code" href="class_virus_bit_flip.html#a0">00043</a> <span class="keyword">virtual</span> std::string <a class="code" href="class_virus_bit_flip.html#a0">className</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <span class="stringliteral">"VirusBitFlip"</span>; };
|
|
00044
|
|
<a name="l00049"></a><a class="code" href="class_virus_bit_flip.html#a1">00049</a> <span class="keywordtype">bool</span> <a class="code" href="class_virus_bit_flip.html#a1">operator()</a>(eoVirus<FitT>& _chrom) {
|
|
00050 <span class="keywordtype">unsigned</span> i = eo::rng.random(_chrom.size());
|
|
00051 _chrom.virusBitSet(i, _chrom.virusBit(i) ? <span class="keyword">false</span> : true );
|
|
00052 <span class="keywordflow">return</span> <span class="keyword">true</span>;
|
|
00053 }
|
|
00054 };
|
|
00055
|
|
00056 <span class="keyword">template</span><<span class="keyword">class</span> FitT>
|
|
00057 <span class="keyword">class </span>VirusMutation: <span class="keyword">public</span> <a class="code" href="classeo_mon_op.html">eoMonOp</a><eoVirus<FitT> > {
|
|
00058 <span class="keyword">public</span>:
|
|
00060 <span class="keyword">virtual</span> std::string className()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <span class="stringliteral">"VirusMutation"</span>; };
|
|
00061
|
|
00066 <span class="keywordtype">bool</span> <a class="code" href="classeo_u_f.html#a1">operator()</a>(eoVirus<FitT>& _chrom) {
|
|
00067 <span class="comment">// Search for virus bits</span>
|
|
00068 std::vector<unsigned> bitsSet;
|
|
00069 <span class="keywordflow">for</span> ( <span class="keywordtype">unsigned</span> i = 0; i < _chrom.size(); i ++ ) {
|
|
00070 <span class="keywordflow">if</span> ( _chrom.virusBit(i) ) {
|
|
00071 bitsSet.push_back( i );
|
|
00072 }
|
|
00073 }
|
|
00074 <span class="keywordflow">if</span> ( !bitsSet.size() ) {
|
|
00075 <span class="keywordflow">return</span> <span class="keyword">false</span>;
|
|
00076 }
|
|
00077 <span class="keywordtype">unsigned</span> flipSite = eo::rng.random(bitsSet.size());
|
|
00078 <span class="keywordtype">unsigned</span> flipValue = bitsSet[ flipSite ];
|
|
00079 _chrom[flipValue] = _chrom[flipValue] ? <span class="keyword">false</span> : <span class="keyword">true</span>;
|
|
00080 <span class="keywordflow">return</span> <span class="keyword">true</span>;
|
|
00081 }
|
|
00082 };
|
|
00083
|
|
00085 <span class="keyword">template</span><<span class="keyword">class</span> FitT>
|
|
<a name="l00086"></a><a class="code" href="class_virus_shift_mutation.html">00086</a> <span class="keyword">class </span><a class="code" href="class_virus_shift_mutation.html">VirusShiftMutation</a>: <span class="keyword">public</span> <a class="code" href="classeo_mon_op.html">eoMonOp</a><eoVirus<FitT> > {
|
|
00087 <span class="keyword">public</span>:
|
|
00088
|
|
<a name="l00090"></a><a class="code" href="class_virus_shift_mutation.html#a0">00090</a> <a class="code" href="class_virus_shift_mutation.html#a0">VirusShiftMutation</a>( ) {};
|
|
00091
|
|
<a name="l00093"></a><a class="code" href="class_virus_shift_mutation.html#a1">00093</a> <span class="keyword">virtual</span> std::string <a class="code" href="class_virus_shift_mutation.html#a1">className</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <span class="stringliteral">"VirusShiftMutation"</span>; };
|
|
00094
|
|
<a name="l00099"></a><a class="code" href="class_virus_shift_mutation.html#a2">00099</a> <span class="keywordtype">bool</span> <a class="code" href="class_virus_shift_mutation.html#a2">operator()</a>(eoVirus<FitT>& _chrom) {
|
|
00100 <span class="comment">// Search for virus bits</span>
|
|
00101 <a class="code" href="classeo_boolean_generator.html">eoBooleanGenerator</a> gen;
|
|
00102 <span class="keywordflow">for</span> ( <span class="keywordtype">unsigned</span> i = 0; i < _chrom.size(); i ++ ) {
|
|
00103 <span class="keywordflow">if</span> ( _chrom.virusBit(i) ) {
|
|
00104 <span class="keywordflow">if</span> ( gen() ) {
|
|
00105 <span class="keywordflow">if</span> ( i + 1 < _chrom.size() ) {
|
|
00106 _chrom.virusBitSet(i+1,<span class="keyword">true</span>);
|
|
00107 _chrom.virusBitSet(i, <span class="keyword">false</span>);
|
|
00108 }
|
|
00109 } <span class="keywordflow">else</span> {
|
|
00110 <span class="keywordflow">if</span> ( i - 1 > 0 ) {
|
|
00111 _chrom.virusBitSet(i-1,<span class="keyword">true</span>);
|
|
00112 _chrom.virusBitSet(i, <span class="keyword">false</span>);
|
|
00113 }
|
|
00114 }
|
|
00115 }
|
|
00116 }
|
|
00117 <span class="keywordflow">return</span> <span class="keyword">true</span>;
|
|
00118 }
|
|
00119
|
|
00120 <span class="keyword">private</span>:
|
|
00121 };
|
|
00122
|
|
00123
|
|
00124 <span class="keyword">template</span><<span class="keyword">class</span> FitT>
|
|
00125 <span class="keyword">class </span>VirusTransmission: <span class="keyword">public</span> <a class="code" href="classeo_bin_op.html">eoBinOp</a><eoVirus<FitT> > {
|
|
00126 <span class="keyword">public</span>:
|
|
00128 <span class="keyword">virtual</span> std::string className()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <span class="stringliteral">"VirusTransmission"</span>; };
|
|
00129
|
|
00135 <span class="keywordtype">bool</span> <a class="code" href="classeo_b_f.html#a1">operator()</a>(eoVirus<FitT>& _chrom,<span class="keyword">const</span> eoVirus<FitT>& _chrom2) {
|
|
00136 <span class="comment">// Search for virus bits</span>
|
|
00137 <span class="keywordflow">for</span> ( <span class="keywordtype">unsigned</span> i = 0; i < _chrom.size(); i ++ ) {
|
|
00138 _chrom.virusBitSet(i, _chrom2.virusBit(i) );
|
|
00139 }
|
|
00140 <span class="keywordflow">return</span> <span class="keyword">true</span>;
|
|
00141 }
|
|
00142 };
|
|
00143
|
|
00144 <span class="preprocessor">#endif //VirusOp_h</span>
|
|
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:44 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>
|