git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@40 331e1502-861f-0410-8da2-ba01fb791d7f
70 lines
4.5 KiB
HTML
70 lines
4.5 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: t-eoproblem.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-eoproblem.cpp</h1><div class="fragment"><pre class="fragment">00001 <span class="comment">//-----------------------------------------------------------------------------</span>
|
|
00002 <span class="comment">// t-eoproblem.cpp</span>
|
|
00003 <span class="comment">// (c) GeNeura Team 1998</span>
|
|
00004 <span class="comment">//-----------------------------------------------------------------------------</span>
|
|
00005
|
|
00006 <span class="preprocessor">#include <time.h></span> <span class="comment">// time</span>
|
|
00007 <span class="preprocessor">#include <math.h></span> <span class="comment">// fabs</span>
|
|
00008 <span class="preprocessor">#include <iostream></span> <span class="comment">// std::cout</span>
|
|
00009 <span class="preprocessor">#include <eo></span> <span class="comment">// eoVector, eoProblem</span>
|
|
00010
|
|
00011 <span class="comment">//-----------------------------------------------------------------------------</span>
|
|
00012
|
|
00013 <span class="keyword">typedef</span> <a class="code" href="classeo_vector.html">eoVector<float, float></a> Chrom;
|
|
00014
|
|
00015 <span class="comment">//-----------------------------------------------------------------------------</span>
|
|
00016
|
|
00017 std::ostream& operator<<(std::ostream& os, <span class="keyword">const</span> Chrom& chrom)
|
|
00018 {
|
|
00019 copy(chrom.begin(), chrom.end(), std::ostream_iterator<int>(os));
|
|
00020 <span class="keywordflow">return</span> os;
|
|
00021 }
|
|
00022
|
|
00023 <span class="comment">//-----------------------------------------------------------------------------</span>
|
|
00024
|
|
00025 <span class="keyword">class </span>Easy<span class="comment">//: public eoProblem<Chrom></span>
|
|
00026 {
|
|
00027 <span class="keyword">public</span>:
|
|
00028 <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">unsigned</span> size;
|
|
00029
|
|
00030 <span class="keywordtype">float</span> operator()(<span class="keyword">const</span> Chrom& chrom)
|
|
00031 {
|
|
00032 <span class="keywordflow">return</span> 1.0 / (fabs(chrom[0]) + 1.0);
|
|
00033 }
|
|
00034 };
|
|
00035 <span class="keyword">const</span> <span class="keywordtype">unsigned</span> Easy::size = 1;
|
|
00036
|
|
00037 <span class="comment">//-----------------------------------------------------------------------------</span>
|
|
00038
|
|
00039 <span class="keywordtype">int</span> main()
|
|
00040 {
|
|
00041 Easy easy;
|
|
00042 Chrom chrom(Easy::size);
|
|
00043
|
|
00044 srand(time(0));
|
|
00045
|
|
00046 chrom[0] = ((float)rand()) / ((float)RAND_MAX);
|
|
00047 chrom.<a class="code" href="class_e_o.html#a2">fitness</a>(easy(chrom));
|
|
00048
|
|
00049 std::cout << <span class="stringliteral">"chrom = "</span> << chrom << std::endl
|
|
00050 << <span class="stringliteral">"chrom.fitness() = "</span> << chrom.<a class="code" href="class_e_o.html#a2">fitness</a>() << std::endl;
|
|
00051
|
|
00052 <span class="keywordflow">return</span> 0;
|
|
00053 }
|
|
00054
|
|
00055 <span class="comment">//-----------------------------------------------------------------------------</span>
|
|
</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>
|