Paradiseo-eo sources added
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@40 331e1502-861f-0410-8da2-ba01fb791d7f
6
trunk/paradiseo-eo/doc/.cvsignore
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
Makefile
|
||||
Makefile.in
|
||||
eo.doxytag
|
||||
html
|
||||
latex
|
||||
man
|
||||
10
trunk/paradiseo-eo/doc/CVS/Entries
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
/.cvsignore/5.3/Thu Dec 23 17:26:39 2004//
|
||||
/EO_EA2001.pdf/1.1/Mon Oct 3 10:06:26 2005/-kb/
|
||||
/LeCreusot.pdf/1.1/Sat Oct 1 11:59:13 2005/-kb/
|
||||
/Makefile.am/5.8/Fri Sep 24 15:00:42 2004//
|
||||
/eo.cfg/1.13/Mon Oct 3 09:56:02 2005//
|
||||
/index.h/1.8/Mon Oct 3 10:56:56 2005//
|
||||
/mainpage.html/1.20/Tue Jun 13 13:35:26 2006//
|
||||
/publications.html/1.1/Sat Mar 25 13:03:45 2006//
|
||||
/sflogo-hammer1.jpg/1.1/Mon Oct 3 10:10:09 2005/-kb/
|
||||
D
|
||||
1
trunk/paradiseo-eo/doc/CVS/Repository
Normal file
|
|
@ -0,0 +1 @@
|
|||
eo/doc
|
||||
1
trunk/paradiseo-eo/doc/CVS/Root
Normal file
|
|
@ -0,0 +1 @@
|
|||
:ext:evomarc@eodev.cvs.sourceforge.net:/cvsroot/eodev
|
||||
BIN
trunk/paradiseo-eo/doc/EO_EA2001.pdf
Normal file
BIN
trunk/paradiseo-eo/doc/LeCreusot.pdf
Normal file
10
trunk/paradiseo-eo/doc/Makefile.am
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
## Makefile.am for eo/doc
|
||||
|
||||
|
||||
EXTRA_DIST = eo.cfg foot.html
|
||||
|
||||
doc:
|
||||
cd $(srcdir) && $(DOXYGEN) eo.cfg
|
||||
|
||||
clean-local:
|
||||
cd $(srcdir) && rm -rf html latex man
|
||||
1119
trunk/paradiseo-eo/doc/eo.cfg
Normal file
14501
trunk/paradiseo-eo/doc/eo.doxytag
Normal file
102
trunk/paradiseo-eo/doc/html/_bit_e_a_8cpp-source.html
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
<!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: BitEA.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_000003.html">tutorial</a> / <a class="el" href="dir_000006.html">Lesson4</a></div>
|
||||
<h1>BitEA.cpp</h1><div class="fragment"><pre class="fragment">00001 <span class="preprocessor">#include <iostream></span>
|
||||
00002
|
||||
00003 <span class="preprocessor">#include <ga/make_ga.h></span>
|
||||
00004 <span class="preprocessor">#include <apply.h></span>
|
||||
00005
|
||||
00006 <span class="comment">// EVAL</span>
|
||||
00007 <span class="preprocessor">#include "binary_value.h"</span>
|
||||
00008
|
||||
00009 <span class="comment">// GENERAL</span>
|
||||
00010 <span class="keyword">using</span> <span class="keyword">namespace </span>std;
|
||||
00011
|
||||
00012 <span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span>* argv[])
|
||||
00013 {
|
||||
00014
|
||||
00015 <span class="keywordflow">try</span>
|
||||
00016 {
|
||||
00017 <span class="comment">// REPRESENTATION</span>
|
||||
00018 <span class="comment">//-----------------------------------------------------------------------------</span>
|
||||
00019 <span class="comment">// define your genotype and fitness types</span>
|
||||
00020 <span class="keyword">typedef</span> <a class="code" href="classeo_bit.html">eoBit<double></a> <a class="code" href="struct_dummy.html">EOT</a>;
|
||||
00021
|
||||
00022 <span class="comment">// PARAMETRES</span>
|
||||
00023 eoParser parser(argc, argv); <span class="comment">// for user-parameter reading</span>
|
||||
00024
|
||||
00025 <span class="comment">// GENERAL</span>
|
||||
00026 <a class="code" href="classeo_state.html">eoState</a> state; <span class="comment">// keeps all things allocated</span>
|
||||
00027
|
||||
00030
|
||||
00031 <span class="comment">// EVAL</span>
|
||||
00032 <span class="comment">// The evaluation fn - encapsulated into an eval counter for output </span>
|
||||
00033 <a class="code" href="structeo_eval_func_ptr.html">eoEvalFuncPtr<EOT, double></a> mainEval( binary_value<EOT> );
|
||||
00034 <a class="code" href="classeo_eval_func_counter.html">eoEvalFuncCounter<EOT></a> eval(mainEval);
|
||||
00035
|
||||
00036 <span class="comment">// REPRESENTATION</span>
|
||||
00037 <span class="comment">// the genotype - through a genotype initializer</span>
|
||||
00038 <a class="code" href="classeo_init.html">eoInit<EOT></a>& init = make_genotype(parser, state, EOT());
|
||||
00039
|
||||
00040 <span class="comment">// if you want to do sharing, you'll need a distance.</span>
|
||||
00041 <span class="comment">// here Hamming distance </span>
|
||||
00042 <a class="code" href="classeo_hamming_distance.html">eoHammingDistance<EOT></a> dist;
|
||||
00043
|
||||
00044 <span class="comment">// OPERATORS</span>
|
||||
00045 <span class="comment">// Build the variation operator (any seq/prop construct)</span>
|
||||
00046 <a class="code" href="classeo_gen_op.html">eoGenOp<EOT></a>& op = make_op(parser, state, init);
|
||||
00047
|
||||
00048 <span class="comment">// GENERAL</span>
|
||||
00051 <span class="comment"></span>
|
||||
00052 <span class="comment">// initialize the population - and evaluate</span>
|
||||
00053 <span class="comment">// yes, this is representation indepedent once you have an eoInit</span>
|
||||
00054 <a class="code" href="classeo_pop.html">eoPop<EOT></a>& pop = make_pop(parser, state, init);
|
||||
00055
|
||||
00056 <span class="comment">// STOP</span>
|
||||
00057 <span class="comment">// stopping criteria</span>
|
||||
00058 <a class="code" href="classeo_continue.html">eoContinue<EOT></a> & term = make_continue(parser, state, eval);
|
||||
00059 <span class="comment">// output</span>
|
||||
00060 <a class="code" href="classeo_check_point.html">eoCheckPoint<EOT></a> & checkpoint = make_checkpoint(parser, state, eval, term);
|
||||
00061 <span class="comment">// GENERATION</span>
|
||||
00062 <span class="comment">// algorithm (need the operator!)</span>
|
||||
00063 <a class="code" href="classeo_algo.html">eoAlgo<EOT></a>& ga = make_algo_scalar(parser, state, eval, checkpoint, op, &dist);
|
||||
00064
|
||||
00067 <span class="comment">// PARAMETRES</span>
|
||||
00068 <span class="comment">// to be called AFTER all parameters have been read!!!</span>
|
||||
00069 make_help(parser);
|
||||
00070
|
||||
00073 <span class="comment">// EVAL</span>
|
||||
00074 <span class="comment">// evaluate intial population AFTER help and status in case it takes time</span>
|
||||
00075 apply<EOT>(eval, pop);
|
||||
00076 <span class="comment">// STOP</span>
|
||||
00077 <span class="comment">// print it out (sort witout modifying) </span>
|
||||
00078 cout << <span class="stringliteral">"Initial Population\n"</span>;
|
||||
00079 pop.<a class="code" href="classeo_pop.html#a17">sortedPrintOn</a>(cout);
|
||||
00080 cout << endl;
|
||||
00081
|
||||
00082 <span class="comment">// GENERATION</span>
|
||||
00083 run_ea(ga, pop); <span class="comment">// run the ga</span>
|
||||
00084 <span class="comment">// STOP</span>
|
||||
00085 <span class="comment">// print it out (sort witout modifying) </span>
|
||||
00086 cout << <span class="stringliteral">"Final Population\n"</span>;
|
||||
00087 pop.<a class="code" href="classeo_pop.html#a17">sortedPrintOn</a>(cout);
|
||||
00088 cout << endl;
|
||||
00089 <span class="comment">// GENERAL</span>
|
||||
00090 }
|
||||
00091 <span class="keywordflow">catch</span>(exception& e)
|
||||
00092 {
|
||||
00093 cout << e.what() << endl;
|
||||
00094 }
|
||||
00095 }
|
||||
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:34 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>
|
||||
95
trunk/paradiseo-eo/doc/html/_bounds_check_8cpp-source.html
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
<!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: BoundsCheck.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_000007.html">contrib</a> / <a class="el" href="dir_000008.html">mathsym</a> / <a class="el" href="dir_000009.html">eval</a></div>
|
||||
<h1>BoundsCheck.cpp</h1><div class="fragment"><pre class="fragment">00001 <span class="comment">/* </span>
|
||||
00002 <span class="comment"> * Copyright (C) 2005 Maarten Keijzer</span>
|
||||
00003 <span class="comment"> *</span>
|
||||
00004 <span class="comment"> * This program is free software; you can redistribute it and/or modify</span>
|
||||
00005 <span class="comment"> * it under the terms of version 2 of the GNU General Public License as </span>
|
||||
00006 <span class="comment"> * published by the Free Software Foundation. </span>
|
||||
00007 <span class="comment"> *</span>
|
||||
00008 <span class="comment"> * This program is distributed in the hope that it will be useful,</span>
|
||||
00009 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
|
||||
00010 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
|
||||
00011 <span class="comment"> * GNU General Public License for more details.</span>
|
||||
00012 <span class="comment"> *</span>
|
||||
00013 <span class="comment"> * You should have received a copy of the GNU General Public License</span>
|
||||
00014 <span class="comment"> * along with this program; if not, write to the Free Software</span>
|
||||
00015 <span class="comment"> * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>
|
||||
00016 <span class="comment"> */</span>
|
||||
00017
|
||||
00018 <span class="preprocessor">#include <vector></span>
|
||||
00019
|
||||
00020 <span class="preprocessor">#include "BoundsCheck.h"</span>
|
||||
00021 <span class="preprocessor">#include <Sym.h></span>
|
||||
00022 <span class="preprocessor">#include <FunDef.h></span>
|
||||
00023 <span class="preprocessor">#include <sstream></span>
|
||||
00024
|
||||
00025 <span class="keyword">using</span> <span class="keyword">namespace </span>std;
|
||||
00026
|
||||
00027 <span class="keyword">class </span>IntervalBoundsCheckImpl {
|
||||
00028 <span class="keyword">public</span> :
|
||||
00029 vector<Interval> bounds;
|
||||
00030 };
|
||||
00031
|
||||
00032 IntervalBoundsCheck::IntervalBoundsCheck(<span class="keyword">const</span> vector<double>& mins, <span class="keyword">const</span> vector<double>& maxes) {
|
||||
00033 pimpl = <span class="keyword">new</span> IntervalBoundsCheckImpl;
|
||||
00034 vector<Interval>& b = pimpl->bounds;
|
||||
00035
|
||||
00036 b.resize( mins.size());
|
||||
00037
|
||||
00038 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < b.size(); ++i) {
|
||||
00039 b[i] = Interval(mins[i], maxes[i]);
|
||||
00040 }
|
||||
00041
|
||||
00042 }
|
||||
00043
|
||||
00044 IntervalBoundsCheck::~IntervalBoundsCheck() { <span class="keyword">delete</span> pimpl; }
|
||||
00045 IntervalBoundsCheck::IntervalBoundsCheck(<span class="keyword">const</span> IntervalBoundsCheck& that) { pimpl = <span class="keyword">new</span> IntervalBoundsCheckImpl(*that.pimpl); }
|
||||
00046 IntervalBoundsCheck& IntervalBoundsCheck::operator=(<span class="keyword">const</span> IntervalBoundsCheck& that) { *pimpl = *that.pimpl; <span class="keywordflow">return</span> *<span class="keyword">this</span>; }
|
||||
00047
|
||||
00048 <span class="keywordtype">bool</span> IntervalBoundsCheck::in_bounds(<span class="keyword">const</span> Sym& sym)<span class="keyword"> const </span>{
|
||||
00049 Interval bounds;
|
||||
00050
|
||||
00051 <span class="keywordflow">try</span> {
|
||||
00052 bounds = eval(sym, pimpl->bounds);
|
||||
00053 <span class="keywordflow">if</span> (!valid(bounds)) <span class="keywordflow">return</span> <span class="keyword">false</span>;
|
||||
00054 } <span class="keywordflow">catch</span> (interval_error) {
|
||||
00055 <span class="keywordflow">return</span> <span class="keyword">false</span>;
|
||||
00056 }
|
||||
00057 <span class="keywordflow">return</span> <span class="keyword">true</span>;
|
||||
00058 }
|
||||
00059
|
||||
00060 std::string IntervalBoundsCheck::get_bounds(<span class="keyword">const</span> Sym& sym)<span class="keyword"> const </span>{
|
||||
00061
|
||||
00062 <span class="keywordflow">try</span> {
|
||||
00063 Interval bounds = eval(sym, pimpl->bounds);
|
||||
00064 <span class="keywordflow">if</span> (!valid(bounds)) <span class="keywordflow">return</span> <span class="stringliteral">"err"</span>;
|
||||
00065 ostringstream os;
|
||||
00066 os << bounds;
|
||||
00067 <span class="keywordflow">return</span> os.str();
|
||||
00068 } <span class="keywordflow">catch</span> (interval_error) {
|
||||
00069 <span class="keywordflow">return</span> <span class="stringliteral">"err"</span>;
|
||||
00070 }
|
||||
00071 }
|
||||
00072
|
||||
00073
|
||||
00074 std::pair<double, double> IntervalBoundsCheck::calc_bounds(<span class="keyword">const</span> Sym& sym)<span class="keyword"> const </span>{
|
||||
00075
|
||||
00076 Interval bounds = eval(sym, pimpl->bounds);
|
||||
00077 <span class="keywordflow">return</span> make_pair(bounds.lower(), bounds.upper());
|
||||
00078 }
|
||||
00079
|
||||
00080
|
||||
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:34 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>
|
||||
73
trunk/paradiseo-eo/doc/html/_bounds_check_8h-source.html
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
<!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: BoundsCheck.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_000008.html">mathsym</a> / <a class="el" href="dir_000009.html">eval</a></div>
|
||||
<h1>BoundsCheck.h</h1><div class="fragment"><pre class="fragment">00001 <span class="comment">/* </span>
|
||||
00002 <span class="comment"> * Copyright (C) 2005 Maarten Keijzer</span>
|
||||
00003 <span class="comment"> *</span>
|
||||
00004 <span class="comment"> * This program is free software; you can redistribute it and/or modify</span>
|
||||
00005 <span class="comment"> * it under the terms of version 2 of the GNU General Public License as </span>
|
||||
00006 <span class="comment"> * published by the Free Software Foundation. </span>
|
||||
00007 <span class="comment"> *</span>
|
||||
00008 <span class="comment"> * This program is distributed in the hope that it will be useful,</span>
|
||||
00009 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
|
||||
00010 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
|
||||
00011 <span class="comment"> * GNU General Public License for more details.</span>
|
||||
00012 <span class="comment"> *</span>
|
||||
00013 <span class="comment"> * You should have received a copy of the GNU General Public License</span>
|
||||
00014 <span class="comment"> * along with this program; if not, write to the Free Software</span>
|
||||
00015 <span class="comment"> * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>
|
||||
00016 <span class="comment"> */</span>
|
||||
00017
|
||||
00018 <span class="preprocessor">#ifndef BOUNDS_CHECK_H_</span>
|
||||
00019 <span class="preprocessor"></span><span class="preprocessor">#define BOUNDS_CHECK_H_</span>
|
||||
00020 <span class="preprocessor"></span>
|
||||
00021 <span class="preprocessor">#include <string></span>
|
||||
00022
|
||||
00023 <span class="keyword">class </span>IntervalBoundsCheckImpl;
|
||||
00024 <span class="keyword">class </span>Sym;
|
||||
00025
|
||||
00026 <span class="keyword">class </span>BoundsCheck {
|
||||
00027 <span class="keyword">public</span> :
|
||||
00028 <span class="keyword">virtual</span> ~BoundsCheck() {};
|
||||
00029 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> in_bounds(<span class="keyword">const</span> Sym&) <span class="keyword">const </span>= 0;
|
||||
00030 <span class="keyword">virtual</span> std::string get_bounds(<span class="keyword">const</span> Sym&) <span class="keyword">const </span>= 0;
|
||||
00031 };
|
||||
00032
|
||||
00033 <span class="comment">// checks if a formula keeps within bounds using interval arithmetic</span>
|
||||
00034 <span class="keyword">class </span>IntervalBoundsCheck : <span class="keyword">public</span> BoundsCheck {
|
||||
00035
|
||||
00036 IntervalBoundsCheckImpl* pimpl;
|
||||
00037
|
||||
00038 <span class="keyword">public</span>:
|
||||
00039
|
||||
00040 IntervalBoundsCheck(<span class="keyword">const</span> std::vector<double>& minima, <span class="keyword">const</span> std::vector<double>& maxima);
|
||||
00041 ~IntervalBoundsCheck();
|
||||
00042 IntervalBoundsCheck(<span class="keyword">const</span> IntervalBoundsCheck&);
|
||||
00043 IntervalBoundsCheck& operator=(<span class="keyword">const</span> IntervalBoundsCheck&);
|
||||
00044
|
||||
00045 <span class="keywordtype">bool</span> in_bounds(<span class="keyword">const</span> Sym&) <span class="keyword">const</span>;
|
||||
00046 std::string get_bounds(<span class="keyword">const</span> Sym&) <span class="keyword">const</span>;
|
||||
00047
|
||||
00048 std::pair<double, double> calc_bounds(<span class="keyword">const</span> Sym&) <span class="keyword">const</span>;
|
||||
00049 };
|
||||
00050
|
||||
00051 <span class="keyword">class </span>NoBoundsCheck : <span class="keyword">public</span> BoundsCheck {
|
||||
00052 <span class="keywordtype">bool</span> in_bounds(<span class="keyword">const</span> Sym&)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <span class="keyword">false</span>; }
|
||||
00053 std::string get_bounds(<span class="keyword">const</span> Sym&)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <span class="stringliteral">""</span>; }
|
||||
00054 };
|
||||
00055
|
||||
00056 <span class="preprocessor">#endif</span>
|
||||
00057 <span class="preprocessor"></span>
|
||||
00058
|
||||
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:34 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>
|
||||
249
trunk/paradiseo-eo/doc/html/_c_m_a_params_8cpp-source.html
Normal file
|
|
@ -0,0 +1,249 @@
|
|||
<!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: CMAParams.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_000000.html">src</a> / <a class="el" href="dir_000010.html">es</a></div>
|
||||
<h1>CMAParams.cpp</h1><div class="fragment"><pre class="fragment">00001
|
||||
00002 <span class="comment">/*</span>
|
||||
00003 <span class="comment"> * C++ification of Nikolaus Hansen's original C-source code for the</span>
|
||||
00004 <span class="comment"> * CMA-ES</span>
|
||||
00005 <span class="comment"> *</span>
|
||||
00006 <span class="comment"> * C++-ificiation performed by Maarten Keijzer (C) 2005. Licensed under</span>
|
||||
00007 <span class="comment"> * the LGPL. Original copyright of Nikolaus Hansen can be found below</span>
|
||||
00008 <span class="comment"> *</span>
|
||||
00009 <span class="comment"> *</span>
|
||||
00010 <span class="comment"> * </span>
|
||||
00011 <span class="comment"> */</span>
|
||||
00012
|
||||
00013 <span class="comment">/* --------------------------------------------------------- */</span>
|
||||
00014 <span class="comment">/* --------------------------------------------------------- */</span>
|
||||
00015 <span class="comment">/* --- File: cmaes.c -------- Author: Nikolaus Hansen --- */</span>
|
||||
00016 <span class="comment">/* --------------------------------------------------------- */</span>
|
||||
00017 <span class="comment">/*</span>
|
||||
00018 <span class="comment"> * CMA-ES for non-linear function minimization.</span>
|
||||
00019 <span class="comment"> *</span>
|
||||
00020 <span class="comment"> * Copyright (C) 1996, 2003 Nikolaus Hansen.</span>
|
||||
00021 <span class="comment"> * e-mail: hansen@bionik.tu-berlin.de</span>
|
||||
00022 <span class="comment"> *</span>
|
||||
00023 <span class="comment"> * This library is free software; you can redistribute it and/or</span>
|
||||
00024 <span class="comment"> * modify it under the terms of the GNU Lesser General Public</span>
|
||||
00025 <span class="comment"> * License as published by the Free Software Foundation; either</span>
|
||||
00026 <span class="comment"> * version 2.1 of the License, or (at your option) any later</span>
|
||||
00027 <span class="comment"> * version (see http://www.gnu.org/copyleft/lesser.html).</span>
|
||||
00028 <span class="comment"> *</span>
|
||||
00029 <span class="comment"> * This library is distributed in the hope that it will be useful,</span>
|
||||
00030 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
|
||||
00031 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</span>
|
||||
00032 <span class="comment"> * Lesser General Public License for more details.</span>
|
||||
00033 <span class="comment"> * </span>
|
||||
00034 <span class="comment"> * */</span>
|
||||
00035 <span class="comment">/* --- Changes : ---</span>
|
||||
00036 <span class="comment"> * 03/03/21: argument const double *rgFunVal of</span>
|
||||
00037 <span class="comment"> * cmaes_ReestimateDistribution() was treated incorrectly.</span>
|
||||
00038 <span class="comment"> * 03/03/29: restart via cmaes_resume_distribution() implemented.</span>
|
||||
00039 <span class="comment"> * 03/03/30: Always max std dev / largest axis is printed first.</span>
|
||||
00040 <span class="comment"> * 03/08/30: Damping is adjusted for large mueff.</span>
|
||||
00041 <span class="comment"> * 03/10/30: Damping is adjusted for large mueff always.</span>
|
||||
00042 <span class="comment"> * 04/04/22: Cumulation time and damping for step size adjusted.</span>
|
||||
00043 <span class="comment"> * No iniphase but conditional update of pc.</span>
|
||||
00044 <span class="comment"> * Version 2.23.</span>
|
||||
00045 <span class="comment"> * */</span>
|
||||
00046
|
||||
00047 <span class="preprocessor">#include <es/CMAParams.h></span>
|
||||
00048 <span class="preprocessor">#include <utils/eoParser.h></span>
|
||||
00049
|
||||
00050 <span class="preprocessor">#include <string></span>
|
||||
00051
|
||||
00052 <span class="keyword">using</span> <span class="keyword">namespace </span>std;
|
||||
00053
|
||||
00054 <span class="keyword">namespace </span>eo {
|
||||
00055
|
||||
00056 CMAParams::CMAParams(eoParser& parser, <span class="keywordtype">unsigned</span> dimensionality) {
|
||||
00057
|
||||
00058 string section = <span class="stringliteral">"CMA parameters"</span>;
|
||||
00059
|
||||
00060 n = parser.createParam(dimensionality, <span class="stringliteral">"dimensionality"</span>, <span class="stringliteral">"Dimensionality (N) of the problem"</span>, <span class="charliteral">'N'</span>, section, dimensionality == 0).value();
|
||||
00061
|
||||
00062 maxgen = parser.createParam(
|
||||
00063 1000,
|
||||
00064 <span class="stringliteral">"max-gen"</span>,
|
||||
00065 <span class="stringliteral">"Maximum number of generations that the system will run (needed for damping)"</span>,
|
||||
00066 <span class="charliteral">'M'</span>,
|
||||
00067 section).value();
|
||||
00068
|
||||
00069
|
||||
00070 <span class="keywordflow">if</span> (n == 0) {
|
||||
00071 <span class="keywordflow">return</span>;
|
||||
00072 }
|
||||
00073
|
||||
00074 defaults(n, maxgen);
|
||||
00075
|
||||
00076 <span class="comment">/* handle lambda */</span>
|
||||
00077 lambda = parser.createParam(
|
||||
00078 lambda,
|
||||
00079 <span class="stringliteral">"lambda"</span>,
|
||||
00080 <span class="stringliteral">"Number of offspring"</span>,
|
||||
00081 <span class="charliteral">'l'</span>,
|
||||
00082 section).value();
|
||||
00083
|
||||
00084 <span class="keywordflow">if</span> (lambda < 2) {
|
||||
00085 lambda = 4+(int)(3*log((<span class="keywordtype">double</span>) n));
|
||||
00086 cerr << <span class="stringliteral">"Too small lambda specified, setting it to "</span> << lambda << endl;
|
||||
00087 }
|
||||
00088
|
||||
00089 <span class="comment">/* handle mu */</span>
|
||||
00090 mu = parser.createParam(
|
||||
00091 mu,
|
||||
00092 <span class="stringliteral">"mu"</span>,
|
||||
00093 <span class="stringliteral">"Population size"</span>,
|
||||
00094 <span class="charliteral">'m'</span>,
|
||||
00095 section).value();
|
||||
00096
|
||||
00097 <span class="keywordflow">if</span> (mu >= lambda) {
|
||||
00098 mu = lambda/2;
|
||||
00099 cerr << <span class="stringliteral">"Mu set larger/equal to lambda, setting it to "</span> << mu << endl;
|
||||
00100 }
|
||||
00101
|
||||
00102 <span class="comment">/* handle selection weights */</span>
|
||||
00103
|
||||
00104 <span class="keywordtype">int</span> weight_type = parser.createParam(
|
||||
00105 0,
|
||||
00106 <span class="stringliteral">"weighting"</span>,
|
||||
00107 <span class="stringliteral">"Weighting scheme (for 'selection'): 0 = logarithmic, 1 = equal, 2 = linear"</span>,
|
||||
00108 <span class="charliteral">'w'</span>,
|
||||
00109 section).value();
|
||||
00110
|
||||
00111 <span class="keywordflow">switch</span> (weight_type) {
|
||||
00112 <span class="keywordflow">case</span> 1:
|
||||
00113 {
|
||||
00114 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < weights.size(); ++i) {
|
||||
00115 weights[i] = mu - i;
|
||||
00116 }
|
||||
00117 }
|
||||
00118 <span class="keywordflow">case</span> 2:
|
||||
00119 {
|
||||
00120 weights = 1.;
|
||||
00121 }
|
||||
00122 <span class="keywordflow">default</span> :
|
||||
00123 {
|
||||
00124 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < weights.size(); ++i) {
|
||||
00125 weights[i] = log(mu+1.)-log(i+1.);
|
||||
00126 }
|
||||
00127 }
|
||||
00128
|
||||
00129 }
|
||||
00130
|
||||
00131 <span class="comment">/* Normalize weights and set mu_eff */</span>
|
||||
00132 <span class="keywordtype">double</span> sumw = weights.sum();
|
||||
00133 mueff = sumw * sumw / (weights * weights).sum();
|
||||
00134 weights /= sumw;
|
||||
00135
|
||||
00136
|
||||
00137 <span class="comment">/* most of the rest depends on mu_eff, so needs to be set again */</span>
|
||||
00138
|
||||
00139 <span class="comment">/* set the others using Nikolaus logic. If you want to tweak, you can parameterize over these defaults */</span>
|
||||
00140 mucov = mueff;
|
||||
00141 ccumsig = (mueff + 2.) / (n + mueff + 3.);
|
||||
00142 ccumcov = 4. / (n + 4);
|
||||
00143
|
||||
00144 <span class="keywordtype">double</span> t1 = 2. / ((n+1.4142)*(n+1.4142));
|
||||
00145 <span class="keywordtype">double</span> t2 = (2.*mucov-1.) / ((n+2.)*(n+2.)+mucov);
|
||||
00146 t2 = (t2 > 1) ? 1 : t2;
|
||||
00147 t2 = (1./mucov) * t1 + (1.-1./mucov) * t2;
|
||||
00148
|
||||
00149 ccov = t2;
|
||||
00150
|
||||
00151 damp = 1 + std::max(0.3,(1.-(<span class="keywordtype">double</span>)n/(<span class="keywordtype">double</span>)maxgen))
|
||||
00152 * (1+2*std::max(0.,sqrt((mueff-1.)/(n+1.))-1)) <span class="comment">/* limit sigma increase */</span>
|
||||
00153 / ccumsig;
|
||||
00154
|
||||
00155 vector<double> mins(1,0.0);
|
||||
00156 mins = parser.createParam(
|
||||
00157 mins,
|
||||
00158 <span class="stringliteral">"min-stdev"</span>,
|
||||
00159 <span class="stringliteral">"Array of minimum stdevs, last one will apply for all remaining axes"</span>,
|
||||
00160 0,
|
||||
00161 section).value();
|
||||
00162
|
||||
00163 <span class="keywordflow">if</span> (mins.size() > n) mins.resize(n);
|
||||
00164
|
||||
00165 <span class="keywordflow">if</span> (mins.size()) {
|
||||
00166 minStdevs = mins.back();
|
||||
00167 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < mins.size(); ++i) {
|
||||
00168 minStdevs[i] = mins[i];
|
||||
00169 }
|
||||
00170 }
|
||||
00171
|
||||
00172 vector<double> inits(1,0.3);
|
||||
00173 inits = parser.createParam(
|
||||
00174 inits,
|
||||
00175 <span class="stringliteral">"init-stdev"</span>,
|
||||
00176 <span class="stringliteral">"Array of initial stdevs, last one will apply for all remaining axes"</span>,
|
||||
00177 0,
|
||||
00178 section).value();
|
||||
00179
|
||||
00180 <span class="keywordflow">if</span> (inits.size() > n) inits.resize(n);
|
||||
00181
|
||||
00182 <span class="keywordflow">if</span> (inits.size()) {
|
||||
00183 initialStdevs = inits.back();
|
||||
00184 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < inits.size(); ++i) {
|
||||
00185 initialStdevs[i] = inits[i];
|
||||
00186 }
|
||||
00187 }
|
||||
00188
|
||||
00189 }
|
||||
00190
|
||||
00191 <span class="keywordtype">void</span> CMAParams::defaults(<span class="keywordtype">unsigned</span> n_, <span class="keywordtype">unsigned</span> maxgen_) {
|
||||
00192 n = n_;
|
||||
00193 maxgen = maxgen_;
|
||||
00194
|
||||
00195 lambda = 4+(int)(3*log((<span class="keywordtype">double</span>) n));
|
||||
00196 mu = lambda / 2;
|
||||
00197
|
||||
00198 weights.resize(mu);
|
||||
00199
|
||||
00200 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < weights.size(); ++i) {
|
||||
00201 weights[i] = log(mu+1.)-log(i+1.);
|
||||
00202 }
|
||||
00203
|
||||
00204 <span class="comment">/* Normalize weights and set mu_eff */</span>
|
||||
00205 <span class="keywordtype">double</span> sumw = weights.sum();
|
||||
00206 mueff = sumw * sumw / (weights * weights).sum();
|
||||
00207 weights /= sumw;
|
||||
00208
|
||||
00209 mucov = mueff;
|
||||
00210 ccumsig *= (mueff + 2.) / (n + mueff + 3.);
|
||||
00211 ccumcov = 4. / (n + 4);
|
||||
00212
|
||||
00213 <span class="keywordtype">double</span> t1 = 2. / ((n+1.4142)*(n+1.4142));
|
||||
00214 <span class="keywordtype">double</span> t2 = (2.*mucov-1.) / ((n+2.)*(n+2.)+mucov);
|
||||
00215 t2 = (t2 > 1) ? 1 : t2;
|
||||
00216 t2 = (1./mucov) * t1 + (1.-1./mucov) * t2;
|
||||
00217
|
||||
00218 ccov = t2;
|
||||
00219
|
||||
00220 damp = 1 + std::max(0.3,(1.-(<span class="keywordtype">double</span>)n/maxgen))
|
||||
00221 * (1+2*std::max(0.,sqrt((mueff-1.)/(n+1.))-1)) <span class="comment">/* limit sigma increase */</span>
|
||||
00222 / ccumsig;
|
||||
00223
|
||||
00224 minStdevs.resize(n);
|
||||
00225 minStdevs = 0.0;
|
||||
00226
|
||||
00227 initialStdevs.resize(n);
|
||||
00228 initialStdevs = 0.3;
|
||||
00229
|
||||
00230
|
||||
00231 }
|
||||
00232
|
||||
00233
|
||||
00234 }<span class="comment">// namespace eo</span>
|
||||
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:34 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>
|
||||
67
trunk/paradiseo-eo/doc/html/_c_m_a_params_8h-source.html
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
<!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: CMAParams.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> / <a class="el" href="dir_000010.html">es</a></div>
|
||||
<h1>CMAParams.h</h1><div class="fragment"><pre class="fragment">00001 <span class="comment">/*</span>
|
||||
00002 <span class="comment"> * C++ification of Nikolaus Hansen's original C-source code for the</span>
|
||||
00003 <span class="comment"> * CMA-ES. </span>
|
||||
00004 <span class="comment"> *</span>
|
||||
00005 <span class="comment"> * Copyright (C) 1996, 2003, Nikolaus Hansen</span>
|
||||
00006 <span class="comment"> * (C) 2005, Maarten Keijzer</span>
|
||||
00007 <span class="comment"> *</span>
|
||||
00008 <span class="comment"> * License: LGPL </span>
|
||||
00009 <span class="comment"> * </span>
|
||||
00010 <span class="comment"> */</span>
|
||||
00011
|
||||
00012 <span class="preprocessor">#ifndef CMAPARAMS_H__</span>
|
||||
00013 <span class="preprocessor"></span><span class="preprocessor">#define CMAPARAMS_H__</span>
|
||||
00014 <span class="preprocessor"></span>
|
||||
00015 <span class="preprocessor">#include <valarray></span>
|
||||
00016
|
||||
00017 <span class="keyword">class </span><a class="code" href="classeo_parser.html">eoParser</a>;
|
||||
00018 <span class="keyword">namespace </span>eo {
|
||||
00019
|
||||
00020 <span class="keyword">class </span>CMAParams {
|
||||
00021
|
||||
00022 <span class="keyword">public</span>:
|
||||
00023
|
||||
00024 CMAParams() { <span class="comment">/* Call this and all values need to be set by hand */</span> }
|
||||
00025 CMAParams(<a class="code" href="classeo_parser.html">eoParser</a>& parser, <span class="keywordtype">unsigned</span> dimensionality = 0); <span class="comment">// 0 dimensionality -> user needs to set it</span>
|
||||
00026
|
||||
00027 <span class="keywordtype">void</span> defaults(<span class="keywordtype">unsigned</span> n_, <span class="keywordtype">unsigned</span> maxgen_); <span class="comment">/* apply all defaults using n and maxgen */</span>
|
||||
00028
|
||||
00029 <span class="keywordtype">unsigned</span> n;
|
||||
00030 <span class="keywordtype">unsigned</span> maxgen;
|
||||
00031
|
||||
00032 <span class="keywordtype">unsigned</span> lambda; <span class="comment">/* -> mu */</span>
|
||||
00033 <span class="keywordtype">unsigned</span> mu; <span class="comment">/* -> weights, lambda */</span>
|
||||
00034
|
||||
00035 std::valarray<double> weights; <span class="comment">/* <- mu, -> mueff -> mucov -> ccov */</span>
|
||||
00036 <span class="keywordtype">double</span> mueff; <span class="comment">/* <- weights */</span>
|
||||
00037
|
||||
00038 <span class="keywordtype">double</span> mucov;
|
||||
00039
|
||||
00040 <span class="keywordtype">double</span> damp; <span class="comment">/* <- ccumsig, maxeval, lambda */</span>
|
||||
00041 <span class="keywordtype">double</span> ccumsig; <span class="comment">/* -> damp, <- N */</span>
|
||||
00042 <span class="keywordtype">double</span> ccumcov;
|
||||
00043 <span class="keywordtype">double</span> ccov; <span class="comment">/* <- mucov, N */</span>
|
||||
00044
|
||||
00045 std::valarray<double> minStdevs; <span class="comment">/* Minimum standard deviations per coordinate (default = 0.0) */</span>
|
||||
00046 std::valarray<double> initialStdevs; <span class="comment">/* Initial standard deviations per coordinate (default = 0.3) */</span>
|
||||
00047 };
|
||||
00048
|
||||
00049 } <span class="comment">// namespace eo</span>
|
||||
00050
|
||||
00051 <span class="preprocessor">#endif</span>
|
||||
00052 <span class="preprocessor"></span>
|
||||
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:34 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>
|
||||
380
trunk/paradiseo-eo/doc/html/_c_m_a_state_8cpp-source.html
Normal file
|
|
@ -0,0 +1,380 @@
|
|||
<!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: CMAState.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_000000.html">src</a> / <a class="el" href="dir_000010.html">es</a></div>
|
||||
<h1>CMAState.cpp</h1><div class="fragment"><pre class="fragment">00001 <span class="comment">/*</span>
|
||||
00002 <span class="comment"> * C++ification of Nikolaus Hansen's original C-source code for the</span>
|
||||
00003 <span class="comment"> * CMA-ES</span>
|
||||
00004 <span class="comment"> *</span>
|
||||
00005 <span class="comment"> * C++-ificiation performed by Maarten Keijzer (C) 2005. Licensed under</span>
|
||||
00006 <span class="comment"> * the LGPL. Original copyright of Nikolaus Hansen can be found below</span>
|
||||
00007 <span class="comment"> *</span>
|
||||
00008 <span class="comment"> *</span>
|
||||
00009 <span class="comment"> * Some changes have been made to the original flow and logic of the</span>
|
||||
00010 <span class="comment"> * algorithm:</span>
|
||||
00011 <span class="comment"> *</span>
|
||||
00012 <span class="comment"> * - Numerical issues are now treated 'before' going into the eigenvector decomposition</span>
|
||||
00013 <span class="comment"> * (this was done out of convenience)</span>
|
||||
00014 <span class="comment"> * - dMaxSignifiKond (smallest x such that x == x + 1.0) replaced by</span>
|
||||
00015 <span class="comment"> * numeric_limits<double>::epsilon() (smallest x such that 1.0 != 1.0 + x)</span>
|
||||
00016 <span class="comment"> * </span>
|
||||
00017 <span class="comment"> * </span>
|
||||
00018 <span class="comment"> */</span>
|
||||
00019
|
||||
00020 <span class="comment">/* --------------------------------------------------------- */</span>
|
||||
00021 <span class="comment">/* --------------------------------------------------------- */</span>
|
||||
00022 <span class="comment">/* --- File: cmaes.c -------- Author: Nikolaus Hansen --- */</span>
|
||||
00023 <span class="comment">/* --------------------------------------------------------- */</span>
|
||||
00024 <span class="comment">/*</span>
|
||||
00025 <span class="comment"> * CMA-ES for non-linear function minimization.</span>
|
||||
00026 <span class="comment"> *</span>
|
||||
00027 <span class="comment"> * Copyright (C) 1996, 2003 Nikolaus Hansen.</span>
|
||||
00028 <span class="comment"> * e-mail: hansen@bionik.tu-berlin.de</span>
|
||||
00029 <span class="comment"> *</span>
|
||||
00030 <span class="comment"> * This library is free software; you can redistribute it and/or</span>
|
||||
00031 <span class="comment"> * modify it under the terms of the GNU Lesser General Public</span>
|
||||
00032 <span class="comment"> * License as published by the Free Software Foundation; either</span>
|
||||
00033 <span class="comment"> * version 2.1 of the License, or (at your option) any later</span>
|
||||
00034 <span class="comment"> * version (see http://www.gnu.org/copyleft/lesser.html).</span>
|
||||
00035 <span class="comment"> *</span>
|
||||
00036 <span class="comment"> * This library is distributed in the hope that it will be useful,</span>
|
||||
00037 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
|
||||
00038 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</span>
|
||||
00039 <span class="comment"> * Lesser General Public License for more details.</span>
|
||||
00040 <span class="comment"> * </span>
|
||||
00041 <span class="comment"> * */</span>
|
||||
00042 <span class="comment">/* --- Changes : ---</span>
|
||||
00043 <span class="comment"> * 03/03/21: argument const double *rgFunVal of</span>
|
||||
00044 <span class="comment"> * cmaes_ReestimateDistribution() was treated incorrectly.</span>
|
||||
00045 <span class="comment"> * 03/03/29: restart via cmaes_resume_distribution() implemented.</span>
|
||||
00046 <span class="comment"> * 03/03/30: Always max std dev / largest axis is printed first.</span>
|
||||
00047 <span class="comment"> * 03/08/30: Damping is adjusted for large mueff.</span>
|
||||
00048 <span class="comment"> * 03/10/30: Damping is adjusted for large mueff always.</span>
|
||||
00049 <span class="comment"> * 04/04/22: Cumulation time and damping for step size adjusted.</span>
|
||||
00050 <span class="comment"> * No iniphase but conditional update of pc.</span>
|
||||
00051 <span class="comment"> * Version 2.23.</span>
|
||||
00052 <span class="comment"> * */</span>
|
||||
00053
|
||||
00054 <span class="preprocessor">#include <valarray></span>
|
||||
00055 <span class="preprocessor">#include <limits></span>
|
||||
00056 <span class="preprocessor">#include <iostream></span>
|
||||
00057 <span class="preprocessor">#include <cassert></span>
|
||||
00058
|
||||
00059 <span class="preprocessor">#include <utils/eoRNG.h></span>
|
||||
00060
|
||||
00061 <span class="preprocessor">#include <es/CMAState.h></span>
|
||||
00062 <span class="preprocessor">#include <es/CMAParams.h></span>
|
||||
00063 <span class="preprocessor">#include <es/matrices.h></span>
|
||||
00064 <span class="preprocessor">#include <es/eig.h></span>
|
||||
00065
|
||||
00066 <span class="keyword">using</span> <span class="keyword">namespace </span>std;
|
||||
00067
|
||||
00068 <span class="keyword">namespace </span>eo {
|
||||
00069
|
||||
00070 <span class="keyword">struct </span>CMAStateImpl {
|
||||
00071
|
||||
00072 CMAParams p;
|
||||
00073
|
||||
00074 lower_triangular_matrix C; <span class="comment">// Covariance matrix</span>
|
||||
00075 square_matrix B; <span class="comment">// Eigen vectors (in columns)</span>
|
||||
00076 valarray<double> d; <span class="comment">// eigen values (diagonal matrix)</span>
|
||||
00077 valarray<double> pc; <span class="comment">// Evolution path</span>
|
||||
00078 valarray<double> ps; <span class="comment">// Evolution path for stepsize;</span>
|
||||
00079
|
||||
00080 vector<double> mean; <span class="comment">// current mean to sample around</span>
|
||||
00081 <span class="keywordtype">double</span> sigma; <span class="comment">// global step size</span>
|
||||
00082
|
||||
00083 <span class="keywordtype">unsigned</span> gen;
|
||||
00084 vector<double> fitnessHistory;
|
||||
00085
|
||||
00086
|
||||
00087 CMAStateImpl(<span class="keyword">const</span> CMAParams& params_, <span class="keyword">const</span> vector<double>& m, <span class="keywordtype">double</span> sigma_) :
|
||||
00088 p(params_),
|
||||
00089 C(p.n), B(p.n), d(p.n), pc(p.n), ps(p.n), mean(m), sigma(sigma_),
|
||||
00090 gen(0), fitnessHistory(3)
|
||||
00091 {
|
||||
00092 <span class="keywordtype">double</span> trace = (p.initialStdevs * p.initialStdevs).sum();
|
||||
00093 <span class="comment">/* Initialize covariance structure */</span>
|
||||
00094 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < p.n; ++i)
|
||||
00095 {
|
||||
00096 B[i][i] = 1.;
|
||||
00097 d[i] = p.initialStdevs[i] * sqrt(p.n / trace);
|
||||
00098 C[i][i] = d[i] * d[i];
|
||||
00099 pc[i] = 0.;
|
||||
00100 ps[i] = 0.;
|
||||
00101 }
|
||||
00102
|
||||
00103 }
|
||||
00104
|
||||
00105 <span class="keywordtype">void</span> sample(vector<double>& v) {
|
||||
00106 <span class="keywordtype">unsigned</span> n = p.n;
|
||||
00107 v.resize(n);
|
||||
00108
|
||||
00109 vector<double> tmp(n);
|
||||
00110 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < n; ++i)
|
||||
00111 tmp[i] = d[i] * rng.<a class="code" href="classeo_rng.html#a7">normal</a>();
|
||||
00112
|
||||
00113 <span class="comment">/* add mutation (sigma * B * (D*z)) */</span>
|
||||
00114 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < n; ++i) {
|
||||
00115 <span class="keywordtype">double</span> sum = 0;
|
||||
00116 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> j = 0; j < n; ++j) {
|
||||
00117 sum += B[i][j] * tmp[j];
|
||||
00118 }
|
||||
00119 v[i] = mean[i] + sigma * sum;
|
||||
00120 }
|
||||
00121 }
|
||||
00122
|
||||
00123 <span class="keywordtype">void</span> reestimate(<span class="keyword">const</span> vector<<span class="keyword">const</span> vector<double>* >& pop, <span class="keywordtype">double</span> muBest, <span class="keywordtype">double</span> muWorst) {
|
||||
00124
|
||||
00125 assert(pop.size() == p.mu);
|
||||
00126
|
||||
00127 <span class="keywordtype">unsigned</span> n = p.n;
|
||||
00128
|
||||
00129 fitnessHistory[gen % fitnessHistory.size()] = muBest; <span class="comment">// needed for divergence check</span>
|
||||
00130
|
||||
00131 vector<double> oldmean = mean;
|
||||
00132 valarray<double> BDz(n);
|
||||
00133
|
||||
00134 <span class="comment">/* calculate xmean and rgBDz~N(0,C) */</span>
|
||||
00135 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < n; ++i) {
|
||||
00136 mean[i] = 0.;
|
||||
00137 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> j = 0; j < pop.size(); ++j) {
|
||||
00138 mean[i] += p.weights[j] * (*pop[j])[i];
|
||||
00139 }
|
||||
00140 BDz[i] = sqrt(p.mueff)*(mean[i] - oldmean[i])/sigma;
|
||||
00141 }
|
||||
00142
|
||||
00143 vector<double> tmp(n);
|
||||
00144 <span class="comment">/* calculate z := D^(-1) * B^(-1) * rgBDz into rgdTmp */</span>
|
||||
00145 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < n; ++i) {
|
||||
00146 <span class="keywordtype">double</span> sum = 0.0;
|
||||
00147 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> j = 0; j < n; ++j) {
|
||||
00148 sum += B[j][i] * BDz[j];
|
||||
00149 }
|
||||
00150 tmp[i] = sum / d[i];
|
||||
00151 }
|
||||
00152
|
||||
00153 <span class="comment">/* cumulation for sigma (ps) using B*z */</span>
|
||||
00154 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < n; ++i) {
|
||||
00155 <span class="keywordtype">double</span> sum = 0.0;
|
||||
00156 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> j = 0; j < n; ++j)
|
||||
00157 sum += B[i][j] * tmp[j];
|
||||
00158
|
||||
00159 ps[i] = (1. - p.ccumsig) * ps[i] + sqrt(p.ccumsig * (2. - p.ccumsig)) * sum;
|
||||
00160 }
|
||||
00161
|
||||
00162 <span class="comment">/* calculate norm(ps)^2 */</span>
|
||||
00163 <span class="keywordtype">double</span> psxps = (ps * ps).sum();
|
||||
00164
|
||||
00165
|
||||
00166 <span class="keywordtype">double</span> chiN = sqrt((<span class="keywordtype">double</span>) p.n) * (1. - 1./(4.*p.n) + 1./(21.*p.n*p.n));
|
||||
00167 <span class="comment">/* cumulation for covariance matrix (pc) using B*D*z~N(0,C) */</span>
|
||||
00168 <span class="keywordtype">double</span> hsig = sqrt(psxps) / sqrt(1. - pow(1.-p.ccumsig, 2.*gen)) / chiN < 1.5 + 1./(p.n-0.5);
|
||||
00169
|
||||
00170 pc = (1. - p.ccumcov) * pc + hsig * sqrt(p.ccumcov * (2. - p.ccumcov)) * BDz;
|
||||
00171
|
||||
00172 <span class="comment">/* stop initial phase (MK, this was not reachable in the org code, deleted) */</span>
|
||||
00173
|
||||
00174 <span class="comment">/* remove momentum in ps, if ps is large and fitness is getting worse */</span>
|
||||
00175
|
||||
00176 <span class="keywordflow">if</span> (gen >= fitnessHistory.size()) {
|
||||
00177
|
||||
00178 <span class="comment">// find direction from muBest and muWorst (muBest == muWorst handled seperately</span>
|
||||
00179 <span class="keywordtype">double</span> direction = muBest < muWorst? -1.0 : 1.0;
|
||||
00180
|
||||
00181 <span class="keywordtype">unsigned</span> now = gen % fitnessHistory.size();
|
||||
00182 <span class="keywordtype">unsigned</span> prev = (gen-1) % fitnessHistory.size();
|
||||
00183 <span class="keywordtype">unsigned</span> prevprev = (gen-2) % fitnessHistory.size();
|
||||
00184
|
||||
00185 <span class="keywordtype">bool</span> fitnessWorsens = (muBest == muWorst) || <span class="comment">// <- increase norm also when population has converged (this deviates from Hansen's scheme)</span>
|
||||
00186 ( (direction * fitnessHistory[now] < direction * fitnessHistory[prev])
|
||||
00187 &&
|
||||
00188 (direction * fitnessHistory[now] < direction * fitnessHistory[prevprev]));
|
||||
00189
|
||||
00190 <span class="keywordflow">if</span>(psxps/p.n > 1.5 + 10.*sqrt(2./p.n) && fitnessWorsens) {
|
||||
00191 <span class="keywordtype">double</span> tfac = sqrt((1 + std::max(0., log(psxps/p.n))) * p.n / psxps);
|
||||
00192 ps *= tfac;
|
||||
00193 psxps *= tfac*tfac;
|
||||
00194 }
|
||||
00195 }
|
||||
00196
|
||||
00197 <span class="comment">/* update of C */</span>
|
||||
00198 <span class="comment">/* Adapt_C(t); not used anymore */</span>
|
||||
00199 <span class="keywordflow">if</span> (p.ccov != 0.) {
|
||||
00200 <span class="comment">//flgEigensysIsUptodate = 0;</span>
|
||||
00201
|
||||
00202 <span class="comment">/* update covariance matrix */</span>
|
||||
00203 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < n; ++i) {
|
||||
00204 vector<double>::iterator c_row = C[i];
|
||||
00205 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> j = 0; j <= i; ++j) {
|
||||
00206 c_row[j] =
|
||||
00207 (1 - p.ccov) * c_row[j]
|
||||
00208 +
|
||||
00209 p.ccov * (1./p.mucov) * pc[i] * pc[j]
|
||||
00210 +
|
||||
00211 (1-hsig) * p.ccumcov * (2. - p.ccumcov) * c_row[j];
|
||||
00212
|
||||
00213 <span class="comment">/*C[i][j] = (1 - p.ccov) * C[i][j] </span>
|
||||
00214 <span class="comment"> + sp.ccov * (1./sp.mucov) </span>
|
||||
00215 <span class="comment"> * (rgpc[i] * rgpc[j] </span>
|
||||
00216 <span class="comment"> + (1-hsig)*sp.ccumcov*(2.-sp.ccumcov) * C[i][j]); */</span>
|
||||
00217 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> k = 0; k < p.mu; ++k) { <span class="comment">/* additional rank mu update */</span>
|
||||
00218 c_row[j] += p.ccov * (1-1./p.mucov) * p.weights[k]
|
||||
00219 * ( (*pop[k])[i] - oldmean[i])
|
||||
00220 * ( (*pop[k])[j] - oldmean[j])
|
||||
00221 / sigma / sigma;
|
||||
00222
|
||||
00223 <span class="comment">// * (rgrgx[index[k]][i] - rgxold[i]) </span>
|
||||
00224 <span class="comment">// * (rgrgx[index[k]][j] - rgxold[j])</span>
|
||||
00225 <span class="comment">// / sigma / sigma; </span>
|
||||
00226 }
|
||||
00227 }
|
||||
00228 }
|
||||
00229 }
|
||||
00230
|
||||
00231 <span class="comment">/* update of sigma */</span>
|
||||
00232 sigma *= exp(((sqrt(psxps)/chiN)-1.)/p.damp);
|
||||
00233 <span class="comment">/* calculate eigensystem, must be done by caller */</span>
|
||||
00234 <span class="comment">//cmaes_UpdateEigensystem(0);</span>
|
||||
00235
|
||||
00236
|
||||
00237 <span class="comment">/* treat minimal standard deviations and numeric problems </span>
|
||||
00238 <span class="comment"> * Note that in contrast with the original code, some numerical issues are treated *before* we </span>
|
||||
00239 <span class="comment"> * go into the eigenvalue calculation */</span>
|
||||
00240
|
||||
00241 treatNumericalIssues(muBest, muWorst);
|
||||
00242
|
||||
00243 gen++; <span class="comment">// increase generation</span>
|
||||
00244 }
|
||||
00245
|
||||
00246 <span class="keywordtype">void</span> treatNumericalIssues(<span class="keywordtype">double</span> best, <span class="keywordtype">double</span> worst) {
|
||||
00247
|
||||
00248 <span class="comment">/* treat stdevs */</span>
|
||||
00249 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < p.n; ++i) {
|
||||
00250 <span class="keywordflow">if</span> (sigma * sqrt(C[i][i]) < p.minStdevs[i]) {
|
||||
00251 <span class="comment">// increase stdev</span>
|
||||
00252 sigma *= exp(0.05+1./p.damp);
|
||||
00253 <span class="keywordflow">break</span>;
|
||||
00254 }
|
||||
00255 }
|
||||
00256
|
||||
00257 <span class="comment">/* treat convergence */</span>
|
||||
00258 <span class="keywordflow">if</span> (best == worst) {
|
||||
00259 sigma *= exp(0.2 + 1./p.damp);
|
||||
00260 }
|
||||
00261
|
||||
00262 <span class="comment">/* Jede Hauptachse i testen, ob x == x + 0.1 * sigma * rgD[i] * B[i] */</span>
|
||||
00263 <span class="comment">/* Test if all the means are not numerically out of whack with our coordinate system*/</span>
|
||||
00264 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> axis = 0; axis < p.n; ++axis) {
|
||||
00265 <span class="keywordtype">double</span> fac = 0.1 * sigma * d[axis];
|
||||
00266 <span class="keywordtype">unsigned</span> coord;
|
||||
00267 <span class="keywordflow">for</span> (coord = 0; coord < p.n; ++coord) {
|
||||
00268 <span class="keywordflow">if</span> (mean[coord] != mean[coord] + fac * B[coord][axis]) {
|
||||
00269 <span class="keywordflow">break</span>;
|
||||
00270 }
|
||||
00271 }
|
||||
00272
|
||||
00273 <span class="keywordflow">if</span> (coord == p.n) { <span class="comment">// means are way too big (little) for numerical accuraccy. Start rocking the craddle a bit more</span>
|
||||
00274 sigma *= exp(0.2+1./p.damp);
|
||||
00275 }
|
||||
00276
|
||||
00277 }
|
||||
00278
|
||||
00279 <span class="comment">/* Testen ob eine Komponente des Objektparameters festhaengt */</span>
|
||||
00280 <span class="comment">/* Correct issues with scale between objective values and covariances */</span>
|
||||
00281 <span class="keywordtype">bool</span> theresAnIssue = <span class="keyword">false</span>;
|
||||
00282
|
||||
00283 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < p.n; ++i) {
|
||||
00284 <span class="keywordflow">if</span> (mean[i] == mean[i] + 0.2 * sigma * sqrt(C[i][i])) {
|
||||
00285 C[i][i] *= (1. + p.ccov);
|
||||
00286 theresAnIssue = <span class="keyword">true</span>;
|
||||
00287 }
|
||||
00288 }
|
||||
00289
|
||||
00290 <span class="keywordflow">if</span> (theresAnIssue) {
|
||||
00291 sigma *= exp(0.05 + 1./p.damp);
|
||||
00292 }
|
||||
00293 }
|
||||
00294
|
||||
00295
|
||||
00296 <span class="keywordtype">bool</span> updateEigenSystem(<span class="keywordtype">unsigned</span> max_tries, <span class="keywordtype">unsigned</span> max_iters) {
|
||||
00297
|
||||
00298 <span class="keywordflow">if</span> (max_iters==0) max_iters = 30 * p.n;
|
||||
00299
|
||||
00300 <span class="keyword">static</span> <span class="keywordtype">double</span> lastGoodMinimumEigenValue = 1.0;
|
||||
00301
|
||||
00302 <span class="comment">/* Try to get a valid calculation */</span>
|
||||
00303 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> tries = 0; tries < max_tries; ++tries) {
|
||||
00304
|
||||
00305 <span class="keywordtype">unsigned</span> iters = eig( p.n, C, d, B, max_iters);
|
||||
00306 <span class="keywordflow">if</span> (iters < max_iters)
|
||||
00307 { <span class="comment">// all is well</span>
|
||||
00308
|
||||
00309 <span class="comment">/* find largest/smallest eigenvalues */</span>
|
||||
00310 <span class="keywordtype">double</span> minEV = d.min();
|
||||
00311 <span class="keywordtype">double</span> maxEV = d.max();
|
||||
00312
|
||||
00313 <span class="comment">/* (MK Original comment was) :Limit Condition of C to dMaxSignifKond+1 </span>
|
||||
00314 <span class="comment"> * replaced dMaxSignifKond with 1./numeric_limits<double>::epsilon()</span>
|
||||
00315 <span class="comment"> * */</span>
|
||||
00316 <span class="keywordflow">if</span> (maxEV * numeric_limits<double>::epsilon() > minEV) {
|
||||
00317 <span class="keywordtype">double</span> tmp = maxEV * numeric_limits<double>::epsilon() - minEV;
|
||||
00318 minEV += tmp;
|
||||
00319 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i=0;i<p.n;++i) {
|
||||
00320 C[i][i] += tmp;
|
||||
00321 d[i] += tmp;
|
||||
00322 }
|
||||
00323 } <span class="comment">/* if */</span>
|
||||
00324 lastGoodMinimumEigenValue = minEV;
|
||||
00325
|
||||
00326 d = sqrt(d);
|
||||
00327
|
||||
00328 <span class="comment">//flgEigensysIsUptodate = 1;</span>
|
||||
00329 <span class="comment">//genOfEigensysUpdate = gen; </span>
|
||||
00330 <span class="comment">//clockeigensum += clock() - clockeigenbegin;</span>
|
||||
00331 <span class="keywordflow">return</span> <span class="keyword">true</span>;
|
||||
00332 } <span class="comment">/* if cIterEig < ... */</span>
|
||||
00333
|
||||
00334 <span class="comment">// numerical problems, ignore them and try again</span>
|
||||
00335
|
||||
00336 <span class="comment">/* Addition des letzten minEW auf die Diagonale von C */</span>
|
||||
00337 <span class="comment">/* Add the last known good eigen value to the diagonal of C */</span>
|
||||
00338 <span class="keywordtype">double</span> summand = lastGoodMinimumEigenValue * exp((<span class="keywordtype">double</span>) tries);
|
||||
00339 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < p.n; ++i)
|
||||
00340 C[i][i] += summand;
|
||||
00341
|
||||
00342 } <span class="comment">/* for iEigenCalcVers */</span>
|
||||
00343
|
||||
00344 <span class="keywordflow">return</span> <span class="keyword">false</span>;
|
||||
00345
|
||||
00346 }
|
||||
00347
|
||||
00348
|
||||
00349 };
|
||||
00350
|
||||
00351 CMAState::CMAState(<span class="keyword">const</span> CMAParams& params, <span class="keyword">const</span> std::vector<double>& initial_point, <span class="keyword">const</span> <span class="keywordtype">double</span> initial_sigma)
|
||||
00352 : pimpl(new CMAStateImpl(params, initial_point, initial_sigma)) {}
|
||||
00353
|
||||
00354 CMAState::~CMAState() { <span class="keyword">delete</span> pimpl; }
|
||||
00355 CMAState::CMAState(<span class="keyword">const</span> CMAState& that) : pimpl(new CMAStateImpl(*that.pimpl )) {}
|
||||
00356 CMAState& CMAState::operator=(<span class="keyword">const</span> CMAState& that) { *pimpl = *that.pimpl; <span class="keywordflow">return</span> *<span class="keyword">this</span>; }
|
||||
00357
|
||||
00358 <span class="keywordtype">void</span> CMAState::sample(vector<double>& v)<span class="keyword"> const </span>{ pimpl->sample(v); }
|
||||
00359
|
||||
00360 <span class="keywordtype">void</span> CMAState::reestimate(<span class="keyword">const</span> vector<<span class="keyword">const</span> vector<double>* >& population, <span class="keywordtype">double</span> muBest, <span class="keywordtype">double</span> muWorst) { pimpl->reestimate(population, muBest, muWorst); }
|
||||
00361 <span class="keywordtype">bool</span> CMAState::updateEigenSystem(<span class="keywordtype">unsigned</span> max_tries, <span class="keywordtype">unsigned</span> max_iters) { <span class="keywordflow">return</span> pimpl->updateEigenSystem(max_tries, max_iters); }
|
||||
00362
|
||||
00363
|
||||
00364 } <span class="comment">// namespace eo</span>
|
||||
00365
|
||||
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:34 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>
|
||||
59
trunk/paradiseo-eo/doc/html/_c_m_a_state_8h-source.html
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
<!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: CMAState.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> / <a class="el" href="dir_000010.html">es</a></div>
|
||||
<h1>CMAState.h</h1><div class="fragment"><pre class="fragment">00001
|
||||
00002 <span class="comment">/*</span>
|
||||
00003 <span class="comment"> * C++ification of Nikolaus Hansen's original C-source code for the</span>
|
||||
00004 <span class="comment"> * CMA-ES. </span>
|
||||
00005 <span class="comment"> *</span>
|
||||
00006 <span class="comment"> * Copyright (C) 1996, 2003, Nikolaus Hansen</span>
|
||||
00007 <span class="comment"> * (C) 2005, Maarten Keijzer</span>
|
||||
00008 <span class="comment"> *</span>
|
||||
00009 <span class="comment"> * License: LGPL (see source file)</span>
|
||||
00010 <span class="comment"> * </span>
|
||||
00011 <span class="comment"> */</span>
|
||||
00012
|
||||
00013 <span class="preprocessor">#ifndef CMASTATE_H_</span>
|
||||
00014 <span class="preprocessor"></span><span class="preprocessor">#define CMASTATE_H_</span>
|
||||
00015 <span class="preprocessor"></span>
|
||||
00016 <span class="preprocessor">#include <vector></span>
|
||||
00017 <span class="preprocessor">#include <valarray></span>
|
||||
00018
|
||||
00019 <span class="keyword">namespace </span>eo {
|
||||
00020
|
||||
00021
|
||||
00022 <span class="keyword">class </span>CMAStateImpl;
|
||||
00023 <span class="keyword">class </span>CMAParams;
|
||||
00024 <span class="keyword">class </span>CMAState {
|
||||
00025
|
||||
00026 CMAStateImpl* pimpl; <span class="comment">/* pointer to implementation, hidden in source file */</span>
|
||||
00027
|
||||
00028 <span class="keyword">public</span>:
|
||||
00029
|
||||
00030 CMAState(<span class="keyword">const</span> CMAParams&, <span class="keyword">const</span> std::vector<double>& initial_point, <span class="keyword">const</span> <span class="keywordtype">double</span> initial_sigma = 1.0);
|
||||
00031 ~CMAState();
|
||||
00032 CMAState(<span class="keyword">const</span> CMAState&);
|
||||
00033 CMAState& operator=(<span class="keyword">const</span> CMAState&);
|
||||
00034
|
||||
00051 <span class="keywordtype">void</span> sample(std::vector<double>& v) <span class="keyword">const</span>;
|
||||
00052
|
||||
00063 <span class="keywordtype">void</span> reestimate(<span class="keyword">const</span> std::vector<<span class="keyword">const</span> std::vector<double>* >& sorted_population, <span class="keywordtype">double</span> muBest, <span class="keywordtype">double</span> muWorst);
|
||||
00064
|
||||
00074 <span class="keywordtype">bool</span> updateEigenSystem(<span class="keywordtype">unsigned</span> max_tries = 1, <span class="keywordtype">unsigned</span> max_iters = 0);
|
||||
00075 };
|
||||
00076
|
||||
00077 } <span class="comment">// namespace eo</span>
|
||||
00078
|
||||
00079 <span class="preprocessor">#endif</span>
|
||||
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:34 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>
|
||||
148
trunk/paradiseo-eo/doc/html/_dataset_8cpp-source.html
Normal file
|
|
@ -0,0 +1,148 @@
|
|||
<!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: Dataset.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_000007.html">contrib</a> / <a class="el" href="dir_000008.html">mathsym</a> / <a class="el" href="dir_000012.html">regression</a></div>
|
||||
<h1>Dataset.cpp</h1><div class="fragment"><pre class="fragment">00001 <span class="comment">/* </span>
|
||||
00002 <span class="comment"> * Copyright (C) 2005 Maarten Keijzer</span>
|
||||
00003 <span class="comment"> *</span>
|
||||
00004 <span class="comment"> * This program is free software; you can redistribute it and/or modify</span>
|
||||
00005 <span class="comment"> * it under the terms of version 2 of the GNU General Public License as </span>
|
||||
00006 <span class="comment"> * published by the Free Software Foundation. </span>
|
||||
00007 <span class="comment"> *</span>
|
||||
00008 <span class="comment"> * This program is distributed in the hope that it will be useful,</span>
|
||||
00009 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
|
||||
00010 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
|
||||
00011 <span class="comment"> * GNU General Public License for more details.</span>
|
||||
00012 <span class="comment"> *</span>
|
||||
00013 <span class="comment"> * You should have received a copy of the GNU General Public License</span>
|
||||
00014 <span class="comment"> * along with this program; if not, write to the Free Software</span>
|
||||
00015 <span class="comment"> * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>
|
||||
00016 <span class="comment"> */</span>
|
||||
00017
|
||||
00018 <span class="preprocessor">#include "Dataset.h"</span>
|
||||
00019 <span class="preprocessor">#include <fstream></span>
|
||||
00020 <span class="preprocessor">#include <sstream></span>
|
||||
00021
|
||||
00022 <span class="preprocessor">#include <iostream></span>
|
||||
00023
|
||||
00024 <span class="keyword">using</span> <span class="keyword">namespace </span>std;
|
||||
00025
|
||||
00026 <span class="keyword">class </span>DataSetImpl {
|
||||
00027 <span class="keyword">public</span>:
|
||||
00028 vector< vector<double> > inputs;
|
||||
00029 vector<double> targets;
|
||||
00030
|
||||
00031 <span class="keywordtype">void</span> read_data(vector<string> strings) {
|
||||
00032 <span class="comment">// find the number of inputs</span>
|
||||
00033
|
||||
00034 istringstream cnt(strings[0]);
|
||||
00035 <span class="keywordtype">unsigned</span> n = 0;
|
||||
00036 <span class="keywordflow">for</span> (;;) {
|
||||
00037 string s;
|
||||
00038 cnt >> s;
|
||||
00039 <span class="keywordflow">if</span> (!cnt) <span class="keywordflow">break</span>;
|
||||
00040 ++n;
|
||||
00041 }
|
||||
00042
|
||||
00043 inputs.resize(strings.size(), vector<double>(n-1));
|
||||
00044 targets.resize(strings.size());
|
||||
00045
|
||||
00046 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < strings.size(); ++i) {
|
||||
00047 istringstream is(strings[i]);
|
||||
00048 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> j = 0; j < n; ++j) {
|
||||
00049
|
||||
00050 <span class="keywordflow">if</span> (!is) {
|
||||
00051 cerr << <span class="stringliteral">"Too few targets in record "</span> << i << endl;
|
||||
00052 exit(1);
|
||||
00053 }
|
||||
00054
|
||||
00055 <span class="keywordflow">if</span> (j < n-1) {
|
||||
00056 is >> inputs[i][j];
|
||||
00057 } <span class="keywordflow">else</span> {
|
||||
00058 is >> targets[i];
|
||||
00059 }
|
||||
00060
|
||||
00061 }
|
||||
00062 }
|
||||
00063
|
||||
00064 }
|
||||
00065
|
||||
00066 };
|
||||
00067
|
||||
00068 Dataset::Dataset() { pimpl = <span class="keyword">new</span> DataSetImpl; }
|
||||
00069 Dataset::~Dataset() { <span class="keyword">delete</span> pimpl; }
|
||||
00070 Dataset::Dataset(<span class="keyword">const</span> Dataset& that) { pimpl = <span class="keyword">new</span> DataSetImpl(*that.pimpl); }
|
||||
00071 Dataset& Dataset::operator=(<span class="keyword">const</span> Dataset& that) { *pimpl = *that.pimpl; <span class="keywordflow">return</span> *<span class="keyword">this</span>; }
|
||||
00072
|
||||
00073 <span class="keywordtype">unsigned</span> Dataset::n_records()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> pimpl->targets.size(); }
|
||||
00074 <span class="keywordtype">unsigned</span> Dataset::n_fields()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> pimpl->inputs[0].size(); }
|
||||
00075 <span class="keyword">const</span> std::vector<double>& Dataset::get_inputs(<span class="keywordtype">unsigned</span> record)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> pimpl->inputs[record]; }
|
||||
00076 <span class="keywordtype">double</span> Dataset::get_target(<span class="keywordtype">unsigned</span> record)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> pimpl->targets[record]; }
|
||||
00077
|
||||
00078 <span class="keywordtype">double</span> error(string errstr);
|
||||
00079
|
||||
00080 <span class="keywordtype">void</span> Dataset::load_data(std::string filename) {
|
||||
00081 vector<string> strings; <span class="comment">// first load it in strings</span>
|
||||
00082
|
||||
00083 ifstream is(filename.c_str());
|
||||
00084
|
||||
00085 <span class="keywordflow">for</span>(;;) {
|
||||
00086 string s;
|
||||
00087 getline(is, s);
|
||||
00088 <span class="keywordflow">if</span> (!is) <span class="keywordflow">break</span>;
|
||||
00089
|
||||
00090 <span class="keywordflow">if</span> (s[0] == <span class="charliteral">'#'</span>) <span class="keywordflow">continue</span>; <span class="comment">// comment, skip</span>
|
||||
00091
|
||||
00092 strings.push_back(s);
|
||||
00093 }
|
||||
00094
|
||||
00095 is.close();
|
||||
00096
|
||||
00097 <span class="keywordflow">if</span> (strings.size() == 0) {
|
||||
00098 error(<span class="stringliteral">"No data could be loaded"</span>);
|
||||
00099 }
|
||||
00100
|
||||
00101 pimpl->read_data(strings);
|
||||
00102
|
||||
00103 }
|
||||
00104
|
||||
00105 std::vector<double> Dataset::input_minima()<span class="keyword"> const </span>{
|
||||
00106 vector<vector<double> >& in = pimpl->inputs;
|
||||
00107
|
||||
00108 vector<double> mn(in[0].size(), 1e+50);
|
||||
00109 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < in.size(); ++i) {
|
||||
00110 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> j = 0; j < in[i].size(); ++j) {
|
||||
00111 mn[j] = std::min(mn[j], in[i][j]);
|
||||
00112 }
|
||||
00113 }
|
||||
00114
|
||||
00115 <span class="keywordflow">return</span> mn;
|
||||
00116 }
|
||||
00117
|
||||
00118 vector<double> Dataset::input_maxima()<span class="keyword"> const </span>{
|
||||
00119 vector<vector<double> >& in = pimpl->inputs;
|
||||
00120
|
||||
00121 vector<double> mx(in[0].size(), -1e+50);
|
||||
00122 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < in.size(); ++i) {
|
||||
00123 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> j = 0; j < in[i].size(); ++j) {
|
||||
00124 mx[j] = std::max(mx[j], in[i][j]);
|
||||
00125 }
|
||||
00126 }
|
||||
00127
|
||||
00128 <span class="keywordflow">return</span> mx;
|
||||
00129 }
|
||||
00130
|
||||
00131
|
||||
00132
|
||||
00133
|
||||
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:34 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>
|
||||
66
trunk/paradiseo-eo/doc/html/_dataset_8h-source.html
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
<!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: Dataset.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_000008.html">mathsym</a> / <a class="el" href="dir_000012.html">regression</a></div>
|
||||
<h1>Dataset.h</h1><div class="fragment"><pre class="fragment">00001 <span class="comment">/* </span>
|
||||
00002 <span class="comment"> * Copyright (C) 2005 Maarten Keijzer</span>
|
||||
00003 <span class="comment"> *</span>
|
||||
00004 <span class="comment"> * This program is free software; you can redistribute it and/or modify</span>
|
||||
00005 <span class="comment"> * it under the terms of version 2 of the GNU General Public License as </span>
|
||||
00006 <span class="comment"> * published by the Free Software Foundation. </span>
|
||||
00007 <span class="comment"> *</span>
|
||||
00008 <span class="comment"> * This program is distributed in the hope that it will be useful,</span>
|
||||
00009 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
|
||||
00010 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
|
||||
00011 <span class="comment"> * GNU General Public License for more details.</span>
|
||||
00012 <span class="comment"> *</span>
|
||||
00013 <span class="comment"> * You should have received a copy of the GNU General Public License</span>
|
||||
00014 <span class="comment"> * along with this program; if not, write to the Free Software</span>
|
||||
00015 <span class="comment"> * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>
|
||||
00016 <span class="comment"> */</span>
|
||||
00017
|
||||
00018 <span class="preprocessor">#ifndef DATASET_H_</span>
|
||||
00019 <span class="preprocessor"></span><span class="preprocessor">#define DATASET_H_</span>
|
||||
00020 <span class="preprocessor"></span>
|
||||
00021 <span class="preprocessor">#include <string></span>
|
||||
00022 <span class="preprocessor">#include <vector></span>
|
||||
00023
|
||||
00024 <span class="keyword">class </span>DataSetImpl;
|
||||
00025
|
||||
00026 <span class="keyword">class </span>Dataset {
|
||||
00027
|
||||
00028 DataSetImpl* pimpl;
|
||||
00029
|
||||
00030 Dataset& operator=(<span class="keyword">const</span> Dataset&); <span class="comment">// cannot assign</span>
|
||||
00031 <span class="keyword">public</span>:
|
||||
00032
|
||||
00033 Dataset();
|
||||
00034 ~Dataset();
|
||||
00035 Dataset(<span class="keyword">const</span> Dataset&);
|
||||
00036
|
||||
00037 <span class="keywordtype">void</span> load_data(std::string filename);
|
||||
00038
|
||||
00039 <span class="keywordtype">unsigned</span> n_records() <span class="keyword">const</span>;
|
||||
00040 <span class="keywordtype">unsigned</span> n_fields() <span class="keyword">const</span>;
|
||||
00041
|
||||
00042 <span class="keyword">const</span> std::vector<double>& get_inputs(<span class="keywordtype">unsigned</span> record) <span class="keyword">const</span>;
|
||||
00043 <span class="keywordtype">double</span> get_target(<span class="keywordtype">unsigned</span> record) <span class="keyword">const</span>;
|
||||
00044
|
||||
00045 std::vector<double> input_minima() <span class="keyword">const</span>;
|
||||
00046 std::vector<double> input_maxima() <span class="keyword">const</span>;
|
||||
00047
|
||||
00048 };
|
||||
00049
|
||||
00050 <span class="preprocessor">#endif</span>
|
||||
00051 <span class="preprocessor"></span>
|
||||
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:34 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>
|
||||
125
trunk/paradiseo-eo/doc/html/_e_o_8h-source.html
Normal file
|
|
@ -0,0 +1,125 @@
|
|||
<!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: EO.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>EO.h</h1><div class="fragment"><pre class="fragment">00001 <span class="comment">// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-</span>
|
||||
00002
|
||||
00003 <span class="comment">//-----------------------------------------------------------------------------</span>
|
||||
00004 <span class="comment">// EO.h</span>
|
||||
00005 <span class="comment">// (c) GeNeura Team 1998</span>
|
||||
00006 <span class="comment">/*</span>
|
||||
00007 <span class="comment"> This library is free software; you can redistribute it and/or</span>
|
||||
00008 <span class="comment"> modify it under the terms of the GNU Lesser General Public</span>
|
||||
00009 <span class="comment"> License as published by the Free Software Foundation; either</span>
|
||||
00010 <span class="comment"> version 2 of the License, or (at your option) any later version.</span>
|
||||
00011 <span class="comment"></span>
|
||||
00012 <span class="comment"> This library is distributed in the hope that it will be useful,</span>
|
||||
00013 <span class="comment"> but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
|
||||
00014 <span class="comment"> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</span>
|
||||
00015 <span class="comment"> Lesser General Public License for more details.</span>
|
||||
00016 <span class="comment"></span>
|
||||
00017 <span class="comment"> You should have received a copy of the GNU Lesser General Public</span>
|
||||
00018 <span class="comment"> License along with this library; if not, write to the Free Software</span>
|
||||
00019 <span class="comment"> Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>
|
||||
00020 <span class="comment"></span>
|
||||
00021 <span class="comment"> Contact: todos@geneura.ugr.es, http://geneura.ugr.es</span>
|
||||
00022 <span class="comment"> */</span>
|
||||
00023 <span class="comment">//-----------------------------------------------------------------------------</span>
|
||||
00024
|
||||
00025 <span class="preprocessor">#ifndef EO_H</span>
|
||||
00026 <span class="preprocessor"></span><span class="preprocessor">#define EO_H</span>
|
||||
00027 <span class="preprocessor"></span>
|
||||
00028 <span class="comment">//-----------------------------------------------------------------------------</span>
|
||||
00029
|
||||
00030 <span class="preprocessor">#include <stdexcept></span> <span class="comment">// std::runtime_error</span>
|
||||
00031 <span class="preprocessor">#include <eoObject.h></span> <span class="comment">// eoObject</span>
|
||||
00032 <span class="preprocessor">#include <eoPersistent.h></span> <span class="comment">// eoPersistent</span>
|
||||
00033
|
||||
00034 <span class="comment">//-----------------------------------------------------------------------------</span>
|
||||
<a name="l00044"></a><a class="code" href="class_e_o.html">00044</a> <span class="comment"></span><span class="keyword">template</span><<span class="keyword">class</span> F> <span class="keyword">class </span><a class="code" href="class_e_o.html">EO</a>: <span class="keyword">public</span> <a class="code" href="classeo_object.html">eoObject</a>, <span class="keyword">public</span> <a class="code" href="classeo_persistent.html">eoPersistent</a>
|
||||
00045 {
|
||||
00046 <span class="keyword">public</span>:
|
||||
00047 <span class="keyword">typedef</span> F Fitness;
|
||||
00048
|
||||
<a name="l00054"></a><a class="code" href="class_e_o.html#a0">00054</a> <a class="code" href="class_e_o.html#a0">EO</a>(): repFitness(Fitness()), invalidFitness(true) {}
|
||||
00055
|
||||
<a name="l00057"></a><a class="code" href="class_e_o.html#a1">00057</a> <span class="keyword">virtual</span> <a class="code" href="class_e_o.html#a1">~EO</a>() {};
|
||||
00058
|
||||
<a name="l00060"></a><a class="code" href="class_e_o.html#a2">00060</a> Fitness <a class="code" href="class_e_o.html#a2">fitness</a>()<span class="keyword"> const </span>{
|
||||
00061 <span class="keywordflow">if</span> (<a class="code" href="class_e_o.html#a5">invalid</a>())
|
||||
00062 <span class="keywordflow">throw</span> std::runtime_error(<span class="stringliteral">"invalid fitness"</span>);
|
||||
00063 <span class="keywordflow">return</span> repFitness;
|
||||
00064 }
|
||||
00065
|
||||
00066 <span class="comment">// Set fitness as invalid.</span>
|
||||
00067 <span class="keywordtype">void</span> invalidate() { invalidFitness = <span class="keyword">true</span>; }
|
||||
00068
|
||||
<a name="l00072"></a><a class="code" href="class_e_o.html#a4">00072</a> <span class="keywordtype">void</span> <a class="code" href="class_e_o.html#a2">fitness</a>(<span class="keyword">const</span> Fitness& _fitness)
|
||||
00073 {
|
||||
00074 repFitness = _fitness;
|
||||
00075 invalidFitness = <span class="keyword">false</span>;
|
||||
00076 }
|
||||
00077
|
||||
<a name="l00081"></a><a class="code" href="class_e_o.html#a5">00081</a> <span class="keywordtype">bool</span> <a class="code" href="class_e_o.html#a5">invalid</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> invalidFitness; }
|
||||
00082
|
||||
<a name="l00086"></a><a class="code" href="class_e_o.html#a6">00086</a> <span class="keywordtype">bool</span> <a class="code" href="class_e_o.html#a6">operator<</a>(<span class="keyword">const</span> <a class="code" href="class_e_o.html">EO</a>& _eo2)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="class_e_o.html#a2">fitness</a>() < _eo2.<a class="code" href="class_e_o.html#a2">fitness</a>(); }
|
||||
00087 <span class="keywordtype">bool</span> operator>(<span class="keyword">const</span> <a class="code" href="class_e_o.html">EO</a>& _eo2)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> !(<a class="code" href="class_e_o.html#a2">fitness</a>() <= _eo2.<a class="code" href="class_e_o.html#a2">fitness</a>()); }
|
||||
00088
|
||||
00090
|
||||
00091
|
||||
<a name="l00095"></a><a class="code" href="class_e_o.html#z10_0">00095</a> <span class="keyword">virtual</span> std::string <a class="code" href="class_e_o.html#z10_0">className</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <span class="stringliteral">"EO"</span>; }
|
||||
00096
|
||||
<a name="l00105"></a><a class="code" href="class_e_o.html#z10_1">00105</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="class_e_o.html#z10_1">readFrom</a>(std::istream& _is) {
|
||||
00106
|
||||
00107 <span class="comment">// the new version of the reafFrom function.</span>
|
||||
00108 <span class="comment">// It can distinguish between valid and invalid fitness values. </span>
|
||||
00109 std::string fitness_str;
|
||||
00110 <span class="keywordtype">int</span> pos = _is.tellg();
|
||||
00111 _is >> fitness_str;
|
||||
00112
|
||||
00113 <span class="keywordflow">if</span> (fitness_str == <span class="stringliteral">"INVALID"</span>)
|
||||
00114 {
|
||||
00115 invalidFitness = <span class="keyword">true</span>;
|
||||
00116 }
|
||||
00117 <span class="keywordflow">else</span>
|
||||
00118 {
|
||||
00119 invalidFitness = <span class="keyword">false</span>;
|
||||
00120 _is.seekg(pos); <span class="comment">// rewind</span>
|
||||
00121 _is >> repFitness;
|
||||
00122 }
|
||||
00123 }
|
||||
00124
|
||||
<a name="l00129"></a><a class="code" href="class_e_o.html#z10_2">00129</a> <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="class_e_o.html#z10_2">printOn</a>(std::ostream& _os)<span class="keyword"> const </span>{
|
||||
00130
|
||||
00131
|
||||
00132 <span class="comment">// the latest version of the code. Very similar to the old code</span>
|
||||
00133 <span class="keywordflow">if</span> (<a class="code" href="class_e_o.html#a5">invalid</a>()) {
|
||||
00134 _os << <span class="stringliteral">"INVALID "</span>;
|
||||
00135 }
|
||||
00136 <span class="keywordflow">else</span>
|
||||
00137 {
|
||||
00138 _os << repFitness << <span class="charliteral">' '</span>;
|
||||
00139 }
|
||||
00140
|
||||
00141 }
|
||||
00142
|
||||
00144
|
||||
00145 <span class="keyword">private</span>:
|
||||
00146 Fitness repFitness; <span class="comment">// value of fitness for this chromosome</span>
|
||||
00147 <span class="keywordtype">bool</span> invalidFitness; <span class="comment">// true if the value of fitness is invalid</span>
|
||||
00148 };
|
||||
00149
|
||||
00150 <span class="comment">//-----------------------------------------------------------------------------</span>
|
||||
00151
|
||||
00152 <span class="preprocessor">#endif</span>
|
||||
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:34 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>
|
||||
139
trunk/paradiseo-eo/doc/html/_e_s_e_a_8cpp-source.html
Normal file
|
|
@ -0,0 +1,139 @@
|
|||
<!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: ESEA.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_000003.html">tutorial</a> / <a class="el" href="dir_000006.html">Lesson4</a></div>
|
||||
<h1>ESEA.cpp</h1><div class="fragment"><pre class="fragment">00001 <span class="comment">// Program to test several EO-ES features</span>
|
||||
00002
|
||||
00003 <span class="preprocessor">#ifdef _MSC_VER</span>
|
||||
00004 <span class="preprocessor"></span><span class="preprocessor">#pragma warning(disable:4786)</span>
|
||||
00005 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
|
||||
00006 <span class="preprocessor"></span>
|
||||
00007 <span class="preprocessor">#include <algorithm></span>
|
||||
00008 <span class="preprocessor">#include <string></span>
|
||||
00009 <span class="preprocessor">#include <iostream></span>
|
||||
00010 <span class="preprocessor">#include <iterator></span>
|
||||
00011 <span class="preprocessor">#include <stdexcept></span>
|
||||
00012 <span class="preprocessor">#include <time.h></span>
|
||||
00013
|
||||
00014 <span class="keyword">using</span> <span class="keyword">namespace </span>std;
|
||||
00015
|
||||
00016 <span class="preprocessor">#include <eo></span>
|
||||
00017
|
||||
00018 <span class="comment">// representation specific</span>
|
||||
00019 <span class="preprocessor">#include <es/make_es.h></span>
|
||||
00020
|
||||
00021 <span class="preprocessor">#include "real_value.h"</span> <span class="comment">// the sphere fitness</span>
|
||||
00022
|
||||
00023 <span class="comment">// Now the main </span>
|
||||
00025 <span class="comment"></span><span class="keyword">typedef</span> <a class="code" href="classeo_scalar_fitness.html">eoMinimizingFitness</a> FitT;
|
||||
00026
|
||||
00027 <span class="keyword">template</span> <<span class="keyword">class</span> EOT>
|
||||
00028 <span class="keywordtype">void</span> runAlgorithm(<a class="code" href="struct_dummy.html">EOT</a>, eoParser& _parser, <a class="code" href="classeo_state.html">eoState</a>& _state);
|
||||
00029
|
||||
00030 <span class="keywordtype">int</span> main_function(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> *argv[])
|
||||
00031 {
|
||||
00032 <span class="comment">// Create the command-line parser</span>
|
||||
00033 eoParser parser(argc, argv); <span class="comment">// for user-parameter reading</span>
|
||||
00034
|
||||
00035 <a class="code" href="classeo_state.html">eoState</a> state; <span class="comment">// keeps all things allocated</span>
|
||||
00036
|
||||
00037
|
||||
00038 <a class="code" href="classeo_value_param.html">eoValueParam<bool></a>& simpleParam = parser.createParam(<span class="keyword">true</span>, <span class="stringliteral">"Isotropic"</span>, <span class="stringliteral">"Isotropic self-adaptive mutation"</span>, <span class="charliteral">'i'</span>, <span class="stringliteral">"ES mutation"</span>);
|
||||
00039 <a class="code" href="classeo_value_param.html">eoValueParam<bool></a>& stdevsParam = parser.createParam(<span class="keyword">false</span>, <span class="stringliteral">"Stdev"</span>, <span class="stringliteral">"One self-adaptive stDev per variable"</span>, <span class="charliteral">'s'</span>, <span class="stringliteral">"ES mutation"</span>);
|
||||
00040 <a class="code" href="classeo_value_param.html">eoValueParam<bool></a>& corrParam = parser.createParam(<span class="keyword">false</span>, <span class="stringliteral">"Correl"</span>, <span class="stringliteral">"Use correlated mutations"</span>, <span class="charliteral">'c'</span>, <span class="stringliteral">"ES mutation"</span>);
|
||||
00041
|
||||
00042 <span class="comment">// Run the appropriate algorithm</span>
|
||||
00043 <span class="keywordflow">if</span> (simpleParam.<a class="code" href="classeo_value_param.html#a2">value</a>() == <span class="keyword">false</span>)
|
||||
00044 {
|
||||
00045 cout << <span class="stringliteral">"Using eoReal"</span> << endl;
|
||||
00046 runAlgorithm(<a class="code" href="classeo_real.html">eoReal<FitT></a>(), parser, state);
|
||||
00047 }
|
||||
00048 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (stdevsParam.<a class="code" href="classeo_value_param.html#a2">value</a>() == <span class="keyword">false</span>)
|
||||
00049 {
|
||||
00050 cout << <span class="stringliteral">"Using eoEsSimple"</span> << endl;
|
||||
00051 runAlgorithm(<a class="code" href="classeo_es_simple.html">eoEsSimple<FitT></a>(), parser, state);
|
||||
00052 }
|
||||
00053 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (corrParam.<a class="code" href="classeo_value_param.html#a2">value</a>() == <span class="keyword">false</span>)
|
||||
00054 {
|
||||
00055 cout << <span class="stringliteral">"Using eoEsStdev"</span> << endl;
|
||||
00056 runAlgorithm(<a class="code" href="classeo_es_stdev.html">eoEsStdev<FitT></a>(), parser, state);
|
||||
00057 }
|
||||
00058 <span class="keywordflow">else</span>
|
||||
00059 {
|
||||
00060 cout << <span class="stringliteral">"Using eoEsFull"</span> << endl;
|
||||
00061 runAlgorithm(<a class="code" href="classeo_es_full.html">eoEsFull<FitT></a>(), parser, state);
|
||||
00062 }
|
||||
00063
|
||||
00064 <span class="keywordflow">return</span> 0;
|
||||
00065 }
|
||||
00066
|
||||
00067 <span class="comment">// A main that catches the exceptions</span>
|
||||
00068
|
||||
00069 <span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> **argv)
|
||||
00070 {
|
||||
00071 <span class="keywordflow">try</span>
|
||||
00072 {
|
||||
00073 main_function(argc, argv);
|
||||
00074 }
|
||||
00075 <span class="keywordflow">catch</span>(exception& e)
|
||||
00076 {
|
||||
00077 cout << <span class="stringliteral">"Exception: "</span> << e.what() << <span class="charliteral">'\n'</span>;
|
||||
00078 }
|
||||
00079
|
||||
00080 <span class="keywordflow">return</span> 1;
|
||||
00081 }
|
||||
00082
|
||||
00087 <span class="keyword">template</span> <<span class="keyword">class</span> EOT>
|
||||
00088 <span class="keywordtype">void</span> runAlgorithm(<a class="code" href="struct_dummy.html">EOT</a>, eoParser& _parser, <a class="code" href="classeo_state.html">eoState</a>& _state)
|
||||
00089 {
|
||||
00090 <span class="keyword">typedef</span> <span class="keyword">typename</span> EOT::Fitness FitT;
|
||||
00091
|
||||
00094
|
||||
00095 <span class="comment">// The evaluation fn - encapsulated into an eval counter for output </span>
|
||||
00096 <a class="code" href="structeo_eval_func_ptr.html">eoEvalFuncPtr<EOT, double, const std::vector<double></a>&>
|
||||
00097 mainEval( real_value );
|
||||
00098 <a class="code" href="classeo_eval_func_counter.html">eoEvalFuncCounter<EOT></a> eval(mainEval);
|
||||
00099
|
||||
00100 <span class="comment">// the genotype - through a genotype initializer</span>
|
||||
00101 <a class="code" href="classeo_real_init_bounded.html">eoRealInitBounded<EOT></a>& init = make_genotype(_parser, _state, <a class="code" href="struct_dummy.html">EOT</a>());
|
||||
00102
|
||||
00103 <span class="comment">// Build the variation operator (any seq/prop construct)</span>
|
||||
00104 <a class="code" href="classeo_gen_op.html">eoGenOp<EOT></a>& op = make_op(_parser, _state, init);
|
||||
00105
|
||||
00108
|
||||
00109 <span class="comment">// initialize the population - and evaluate</span>
|
||||
00110 <span class="comment">// yes, this is representation indepedent once you have an eoInit</span>
|
||||
00111 <a class="code" href="classeo_pop.html">eoPop<EOT></a>& pop = make_pop(_parser, _state, init);
|
||||
00112 apply<EOT>(eval, pop);
|
||||
00113
|
||||
00114 <span class="comment">// stopping criteria</span>
|
||||
00115 <a class="code" href="classeo_continue.html">eoContinue<EOT></a> & term = make_continue(_parser, _state, eval);
|
||||
00116 <span class="comment">// output</span>
|
||||
00117 <a class="code" href="classeo_check_point.html">eoCheckPoint<EOT></a> & checkpoint = make_checkpoint(_parser, _state, eval, term);
|
||||
00118 <span class="comment">// algorithm (need the operator!)</span>
|
||||
00119 <a class="code" href="classeo_algo.html">eoAlgo<EOT></a>& ga = make_algo_scalar(_parser, _state, eval, checkpoint, op);
|
||||
00120
|
||||
00123 <span class="comment">// to be called AFTER all parameters have been read!!!</span>
|
||||
00124 make_help(_parser);
|
||||
00125
|
||||
00128 cout << <span class="stringliteral">"Initial Population\n"</span>;
|
||||
00129 pop.<a class="code" href="classeo_pop.html#a17">sortedPrintOn</a>(cout);
|
||||
00130 cout << endl;
|
||||
00131
|
||||
00132 run_ea(ga, pop); <span class="comment">// run the ga</span>
|
||||
00133
|
||||
00134 cout << <span class="stringliteral">"Final Population\n"</span>;
|
||||
00135 pop.<a class="code" href="classeo_pop.html#a17">sortedPrintOn</a>(cout);
|
||||
00136 cout << endl;
|
||||
00137 }
|
||||
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:39 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>
|
||||
355
trunk/paradiseo-eo/doc/html/_error_measure_8cpp-source.html
Normal file
|
|
@ -0,0 +1,355 @@
|
|||
<!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: ErrorMeasure.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_000007.html">contrib</a> / <a class="el" href="dir_000008.html">mathsym</a> / <a class="el" href="dir_000012.html">regression</a></div>
|
||||
<h1>ErrorMeasure.cpp</h1><div class="fragment"><pre class="fragment">00001 <span class="comment">/* </span>
|
||||
00002 <span class="comment"> * Copyright (C) 2005 Maarten Keijzer</span>
|
||||
00003 <span class="comment"> *</span>
|
||||
00004 <span class="comment"> * This program is free software; you can redistribute it and/or modify</span>
|
||||
00005 <span class="comment"> * it under the terms of version 2 of the GNU General Public License as </span>
|
||||
00006 <span class="comment"> * published by the Free Software Foundation. </span>
|
||||
00007 <span class="comment"> *</span>
|
||||
00008 <span class="comment"> * This program is distributed in the hope that it will be useful,</span>
|
||||
00009 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
|
||||
00010 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
|
||||
00011 <span class="comment"> * GNU General Public License for more details.</span>
|
||||
00012 <span class="comment"> *</span>
|
||||
00013 <span class="comment"> * You should have received a copy of the GNU General Public License</span>
|
||||
00014 <span class="comment"> * along with this program; if not, write to the Free Software</span>
|
||||
00015 <span class="comment"> * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>
|
||||
00016 <span class="comment"> */</span>
|
||||
00017
|
||||
00018
|
||||
00019 <span class="preprocessor">#include <vector></span>
|
||||
00020 <span class="preprocessor">#include <valarray></span>
|
||||
00021
|
||||
00022 <span class="preprocessor">#include "MultiFunction.h"</span>
|
||||
00023
|
||||
00024 <span class="preprocessor">#include "ErrorMeasure.h"</span>
|
||||
00025 <span class="preprocessor">#include "Dataset.h"</span>
|
||||
00026 <span class="preprocessor">#include "Sym.h"</span>
|
||||
00027 <span class="preprocessor">#include "FunDef.h"</span>
|
||||
00028 <span class="preprocessor">#include "sym_compile.h"</span>
|
||||
00029 <span class="preprocessor">#include "TargetInfo.h"</span>
|
||||
00030 <span class="preprocessor">#include "stats.h"</span>
|
||||
00031
|
||||
00032 <span class="keyword">using</span> <span class="keyword">namespace </span>std;
|
||||
00033
|
||||
00034 <span class="preprocessor">#ifdef INTERVAL_DEBUG</span>
|
||||
00035 <span class="preprocessor"></span>
|
||||
00036 <span class="preprocessor">#include <BoundsCheck.h></span>
|
||||
00037 <span class="preprocessor">#include <FunDef.h></span>
|
||||
00038
|
||||
00039 vector<double> none;
|
||||
00040 IntervalBoundsCheck bounds(none, none);
|
||||
00041
|
||||
00042 <span class="preprocessor">#endif</span>
|
||||
00043 <span class="preprocessor"></span>
|
||||
00044
|
||||
00045
|
||||
00046 <span class="keyword">static</span> <span class="keywordtype">double</span> not_a_number = atof(<span class="stringliteral">"nan"</span>);
|
||||
00047
|
||||
00048 <span class="keyword">class </span>ErrorMeasureImpl {
|
||||
00049 <span class="keyword">public</span>:
|
||||
00050 <span class="keyword">const</span> Dataset& data;
|
||||
00051 TargetInfo train_info;
|
||||
00052
|
||||
00053 ErrorMeasure::measure measure;
|
||||
00054
|
||||
00055 Scaling no_scaling;
|
||||
00056
|
||||
00057 ErrorMeasureImpl(<span class="keyword">const</span> Dataset& d, <span class="keywordtype">double</span> t_p, ErrorMeasure::measure m) : data(d), measure(m) {
|
||||
00058
|
||||
00059 <span class="preprocessor">#ifdef INTERVAL_DEBUG</span>
|
||||
00060 <span class="preprocessor"></span> bounds = IntervalBoundsCheck(d.input_minima(), d.input_maxima());
|
||||
00061 <span class="preprocessor">#endif</span>
|
||||
00062 <span class="preprocessor"></span>
|
||||
00063 <span class="keywordtype">unsigned</span> nrecords = d.n_records();
|
||||
00064 <span class="keywordtype">unsigned</span> cases = unsigned(t_p * nrecords);
|
||||
00065
|
||||
00066 valarray<double> t(cases);
|
||||
00067
|
||||
00068 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < cases; ++i) {
|
||||
00069 t[i] = data.get_target(i);
|
||||
00070 }
|
||||
00071
|
||||
00072 train_info = TargetInfo(t);
|
||||
00073 no_scaling = Scaling(<span class="keyword">new</span> NoScaling);
|
||||
00074 }
|
||||
00075
|
||||
00076 ErrorMeasure::result eval(<span class="keyword">const</span> valarray<double>& y) {
|
||||
00077
|
||||
00078 ErrorMeasure::result result;
|
||||
00079 result.scaling = no_scaling;
|
||||
00080
|
||||
00081
|
||||
00082 <span class="keywordflow">switch</span>(measure) {
|
||||
00083 <span class="keywordflow">case</span> ErrorMeasure::mean_squared:
|
||||
00084 result.error = pow(train_info.targets() - y, 2.0).sum() / y.size();
|
||||
00085 <span class="keywordflow">return</span> result;
|
||||
00086 <span class="keywordflow">case</span> ErrorMeasure::absolute:
|
||||
00087 result.error = abs(train_info.targets() - y).sum() / y.size();
|
||||
00088 <span class="keywordflow">return</span> result;
|
||||
00089 <span class="keywordflow">case</span> ErrorMeasure::mean_squared_scaled:
|
||||
00090 result.scaling = ols(y, train_info);
|
||||
00091 result.error = pow(train_info.targets() - result.scaling->transform(y), 2.0).sum() / y.size();
|
||||
00092 <span class="keywordflow">return</span> result;
|
||||
00093 <span class="keywordflow">default</span>:
|
||||
00094 cerr << <span class="stringliteral">"Unknown measure encountered: "</span> << measure << <span class="stringliteral">" "</span> << __FILE__ << <span class="stringliteral">" "</span> << __LINE__ << endl;
|
||||
00095 }
|
||||
00096
|
||||
00097 <span class="keywordflow">return</span> result;
|
||||
00098 }
|
||||
00099
|
||||
00100 <span class="keywordtype">unsigned</span> train_cases()<span class="keyword"> const </span>{
|
||||
00101 <span class="keywordflow">return</span> train_info.targets().size();
|
||||
00102 }
|
||||
00103
|
||||
00104 vector<ErrorMeasure::result> multi_function_eval(<span class="keyword">const</span> vector<Sym>& pop) {
|
||||
00105
|
||||
00106 <span class="keywordflow">if</span> (pop.size() == 0) <span class="keywordflow">return</span> vector<ErrorMeasure::result>();
|
||||
00107
|
||||
00108 multi_function all = compile(pop);
|
||||
00109 <span class="comment">//MultiFunction all(pop);</span>
|
||||
00110 std::vector<double> y(pop.size());
|
||||
00111
|
||||
00112 Scaling noScaling = Scaling(<span class="keyword">new</span> NoScaling);
|
||||
00113
|
||||
00114 <span class="keyword">const</span> std::valarray<double>& t = train_info.targets();
|
||||
00115
|
||||
00116 cout << <span class="stringliteral">"Population size "</span> << pop.size() << endl;
|
||||
00117
|
||||
00118 <span class="keywordflow">if</span> (measure == ErrorMeasure::mean_squared_scaled) {
|
||||
00119 std::vector<Var> var(pop.size());
|
||||
00120 std::vector<Cov> cov(pop.size());
|
||||
00121
|
||||
00122 Var vart;
|
||||
00123
|
||||
00124 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < t.size(); ++i) {
|
||||
00125 vart.update(t[i]);
|
||||
00126
|
||||
00127 all(&data.get_inputs(i)[0], &y[0]); <span class="comment">// evalutate</span>
|
||||
00128 <span class="comment">//all(data.get_inputs(i), y); // evalutate</span>
|
||||
00129
|
||||
00130 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> j = 0; j < pop.size(); ++j) {
|
||||
00131 var[j].update(y[j]);
|
||||
00132 cov[j].update(y[j], t[i]);
|
||||
00133 }
|
||||
00134 }
|
||||
00135
|
||||
00136 std::vector<ErrorMeasure::result> result(pop.size());
|
||||
00137
|
||||
00138 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < pop.size(); ++i) {
|
||||
00139
|
||||
00140 <span class="comment">// calculate scaling</span>
|
||||
00141 <span class="keywordtype">double</span> b = cov[i].get_cov() / var[i].get_var();
|
||||
00142
|
||||
00143 <span class="keywordflow">if</span> (!finite(b)) {
|
||||
00144 result[i].scaling = noScaling;
|
||||
00145 result[i].error = vart.get_var(); <span class="comment">// largest error</span>
|
||||
00146 <span class="keywordflow">continue</span>;
|
||||
00147 }
|
||||
00148
|
||||
00149 <span class="keywordtype">double</span> a = vart.get_mean() - b * var[i].get_mean();
|
||||
00150
|
||||
00151 result[i].scaling = Scaling( <span class="keyword">new</span> LinearScaling(a,b));
|
||||
00152
|
||||
00153 <span class="comment">// calculate error</span>
|
||||
00154 <span class="keywordtype">double</span> c = cov[i].get_cov();
|
||||
00155 c *= c;
|
||||
00156
|
||||
00157 <span class="keywordtype">double</span> err = vart.get_var() - c / var[i].get_var();
|
||||
00158 result[i].error = err;
|
||||
00159 <span class="keywordflow">if</span> (!finite(err)) {
|
||||
00160 <span class="comment">//cout << pop[i] << endl;</span>
|
||||
00161 cout << <span class="stringliteral">"b "</span> << b << endl;
|
||||
00162 cout << <span class="stringliteral">"var t "</span> << vart.get_var() << endl;
|
||||
00163 cout << <span class="stringliteral">"var i "</span> << var[i].get_var() << endl;
|
||||
00164 cout << <span class="stringliteral">"cov "</span> << cov[i].get_cov() << endl;
|
||||
00165
|
||||
00166 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> j = 0; j < t.size(); ++j) {
|
||||
00167 all(&data.get_inputs(i)[0], &y[0]); <span class="comment">// evalutate</span>
|
||||
00168 <span class="comment">//all(data.get_inputs(j), y); // evalutate</span>
|
||||
00169
|
||||
00170 cout << y[i] << <span class="charliteral">' '</span> << ::eval(pop[i], data.get_inputs(j)) << endl;
|
||||
00171 }
|
||||
00172
|
||||
00173 exit(1);
|
||||
00174 }
|
||||
00175 }
|
||||
00176
|
||||
00177 <span class="keywordflow">return</span> result;
|
||||
00178 }
|
||||
00179
|
||||
00180
|
||||
00181 std::vector<double> err(pop.size());
|
||||
00182
|
||||
00183 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < train_cases(); ++i) {
|
||||
00184 <span class="comment">// evaluate</span>
|
||||
00185 all(&data.get_inputs(i)[0], &y[0]);
|
||||
00186 <span class="comment">//all(data.get_inputs(i), y);</span>
|
||||
00187
|
||||
00188 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> j = 0; j < pop.size(); ++j) {
|
||||
00189 <span class="keywordtype">double</span> diff = y[j] - t[i];
|
||||
00190 <span class="keywordflow">if</span> (measure == ErrorMeasure::mean_squared) { <span class="comment">// branch prediction will probably solve this inefficiency</span>
|
||||
00191 err[j] += diff * diff;
|
||||
00192 } <span class="keywordflow">else</span> {
|
||||
00193 err[j] += fabs(diff);
|
||||
00194 }
|
||||
00195
|
||||
00196 }
|
||||
00197
|
||||
00198 }
|
||||
00199
|
||||
00200 std::vector<ErrorMeasure::result> result(pop.size());
|
||||
00201
|
||||
00202 <span class="keywordtype">double</span> n = train_cases();
|
||||
00203 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < pop.size(); ++i) {
|
||||
00204 result[i].error = err[i] / n;
|
||||
00205 result[i].scaling = noScaling;
|
||||
00206 }
|
||||
00207
|
||||
00208 <span class="keywordflow">return</span> result;
|
||||
00209
|
||||
00210 }
|
||||
00211
|
||||
00212 vector<ErrorMeasure::result> single_function_eval(<span class="keyword">const</span> vector<Sym> & pop) {
|
||||
00213
|
||||
00214 vector<single_function> funcs(pop.size());
|
||||
00215 compile(pop, funcs); <span class="comment">// get one function pointer for each individual</span>
|
||||
00216
|
||||
00217 valarray<double> y(train_cases());
|
||||
00218 vector<ErrorMeasure::result> result(pop.size());
|
||||
00219 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < funcs.size(); ++i) {
|
||||
00220 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> j = 0; j < train_cases(); ++j) {
|
||||
00221 y[j] = funcs[i](&data.get_inputs(j)[0]);
|
||||
00222 }
|
||||
00223
|
||||
00224 <span class="preprocessor">#ifdef INTERVAL_DEBUG</span>
|
||||
00225 <span class="preprocessor"></span> <span class="comment">//cout << "eval func " << i << " " << pop[i] << endl;</span>
|
||||
00226 pair<double, double> b = bounds.calc_bounds(pop[i]);
|
||||
00227
|
||||
00228 <span class="comment">// check if y is in bounds</span>
|
||||
00229 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> j = 0; j < y.size(); ++j) {
|
||||
00230 <span class="keywordflow">if</span> (y[j] < b.first -1e-4 || y[j] > b.second + 1e-4 || !finite(y[j])) {
|
||||
00231 cout << <span class="stringliteral">"Error "</span> << y[j] << <span class="stringliteral">" not in "</span> << b.first << <span class="charliteral">' '</span> << b.second << endl;
|
||||
00232 cout << <span class="stringliteral">"Function "</span> << pop[i] << endl;
|
||||
00233 exit(1);
|
||||
00234 }
|
||||
00235 }
|
||||
00236 <span class="preprocessor">#endif</span>
|
||||
00237 <span class="preprocessor"></span>
|
||||
00238 result[i] = eval(y);
|
||||
00239 }
|
||||
00240
|
||||
00241 <span class="keywordflow">return</span> result;
|
||||
00242 }
|
||||
00243
|
||||
00244 vector<ErrorMeasure::result> calc_error(<span class="keyword">const</span> vector<Sym>& pop) {
|
||||
00245
|
||||
00246 <span class="comment">// first declone</span>
|
||||
00247 <span class="preprocessor">#if USE_TR1</span>
|
||||
00248 <span class="preprocessor"></span> <span class="keyword">typedef</span> std::tr1::unordered_map<Sym, unsigned, HashSym> HashMap;
|
||||
00249 <span class="preprocessor">#else</span>
|
||||
00250 <span class="preprocessor"></span> <span class="keyword">typedef</span> hash_map<Sym, unsigned, HashSym> HashMap;
|
||||
00251 <span class="preprocessor">#endif </span>
|
||||
00252 <span class="preprocessor"></span> HashMap clone_map;
|
||||
00253 vector<Sym> decloned;
|
||||
00254 decloned.reserve(pop.size());
|
||||
00255
|
||||
00256 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < pop.size(); ++i) {
|
||||
00257 HashMap::iterator it = clone_map.find(pop[i]);
|
||||
00258
|
||||
00259 <span class="keywordflow">if</span> (it == clone_map.end()) { <span class="comment">// new</span>
|
||||
00260 clone_map[ pop[i] ] = decloned.size();
|
||||
00261 decloned.push_back(pop[i]);
|
||||
00262 }
|
||||
00263
|
||||
00264 }
|
||||
00265
|
||||
00266 <span class="comment">// evaluate </span>
|
||||
00267 vector<ErrorMeasure::result> dresult;
|
||||
00268 <span class="comment">// currently we can only accumulate simple measures such as absolute and mean_squared</span>
|
||||
00269 <span class="keywordflow">switch</span>(measure) {
|
||||
00270 <span class="keywordflow">case</span> ErrorMeasure::mean_squared:
|
||||
00271 <span class="keywordflow">case</span> ErrorMeasure::absolute:
|
||||
00272 dresult = multi_function_eval(decloned);
|
||||
00273 <span class="keywordflow">break</span>;
|
||||
00274 <span class="keywordflow">case</span> ErrorMeasure::mean_squared_scaled:
|
||||
00275 dresult = multi_function_eval(decloned);
|
||||
00276 <span class="keywordflow">break</span>;
|
||||
00277 }
|
||||
00278
|
||||
00279 vector<ErrorMeasure::result> result(pop.size());
|
||||
00280 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < result.size(); ++i) {
|
||||
00281 result[i] = dresult[ clone_map[pop[i]] ];
|
||||
00282 }
|
||||
00283
|
||||
00284 <span class="keywordflow">return</span> result;
|
||||
00285 }
|
||||
00286
|
||||
00287 };
|
||||
00288
|
||||
00289 ErrorMeasure::result::result() {
|
||||
00290 error = 0.0;
|
||||
00291 scaling = Scaling(0);
|
||||
00292 }
|
||||
00293
|
||||
00294 <span class="keywordtype">bool</span> ErrorMeasure::result::valid()<span class="keyword"> const </span>{
|
||||
00295 <span class="keywordflow">return</span> isfinite(error);
|
||||
00296 }
|
||||
00297
|
||||
00298 ErrorMeasure::ErrorMeasure(<span class="keyword">const</span> Dataset& data, <span class="keywordtype">double</span> train_perc, measure meas) {
|
||||
00299 pimpl = <span class="keyword">new</span> ErrorMeasureImpl(data, train_perc, meas);
|
||||
00300 }
|
||||
00301
|
||||
00302 ErrorMeasure::~ErrorMeasure() { <span class="keyword">delete</span> pimpl; }
|
||||
00303 ErrorMeasure::ErrorMeasure(<span class="keyword">const</span> ErrorMeasure& that) { pimpl = <span class="keyword">new</span> ErrorMeasureImpl(*that.pimpl); }
|
||||
00304
|
||||
00305
|
||||
00306 ErrorMeasure::result ErrorMeasure::calc_error(Sym sym) {
|
||||
00307
|
||||
00308 single_function f = compile(sym);
|
||||
00309
|
||||
00310 valarray<double> y(pimpl->train_cases());
|
||||
00311
|
||||
00312 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < y.size(); ++i) {
|
||||
00313
|
||||
00314 y[i] = f(&pimpl->data.get_inputs(i)[0]);
|
||||
00315
|
||||
00316 <span class="keywordflow">if</span> (!finite(y[i])) {
|
||||
00317 result res;
|
||||
00318 res.scaling = Scaling(<span class="keyword">new</span> NoScaling);
|
||||
00319 res.error = not_a_number;
|
||||
00320 <span class="keywordflow">return</span> res;
|
||||
00321 }
|
||||
00322 }
|
||||
00323
|
||||
00324 <span class="keywordflow">return</span> pimpl->eval(y);
|
||||
00325 }
|
||||
00326
|
||||
00327 vector<ErrorMeasure::result> ErrorMeasure::calc_error(<span class="keyword">const</span> vector<Sym>& syms) {
|
||||
00328 <span class="keywordflow">return</span> pimpl->calc_error(syms);
|
||||
00329
|
||||
00330 }
|
||||
00331
|
||||
00332 <span class="keywordtype">double</span> ErrorMeasure::worst_performance()<span class="keyword"> const </span>{
|
||||
00333
|
||||
00334 <span class="keywordflow">if</span> (pimpl->measure == mean_squared_scaled) {
|
||||
00335 <span class="keywordflow">return</span> pimpl->train_info.tvar();
|
||||
00336 }
|
||||
00337
|
||||
00338 <span class="keywordflow">return</span> 1e+20;
|
||||
00339 }
|
||||
00340
|
||||
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:39 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>
|
||||
76
trunk/paradiseo-eo/doc/html/_error_measure_8h-source.html
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
<!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: ErrorMeasure.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_000008.html">mathsym</a> / <a class="el" href="dir_000012.html">regression</a></div>
|
||||
<h1>ErrorMeasure.h</h1><div class="fragment"><pre class="fragment">00001 <span class="comment">/* </span>
|
||||
00002 <span class="comment"> * Copyright (C) 2005 Maarten Keijzer</span>
|
||||
00003 <span class="comment"> *</span>
|
||||
00004 <span class="comment"> * This program is free software; you can redistribute it and/or modify</span>
|
||||
00005 <span class="comment"> * it under the terms of version 2 of the GNU General Public License as </span>
|
||||
00006 <span class="comment"> * published by the Free Software Foundation. </span>
|
||||
00007 <span class="comment"> *</span>
|
||||
00008 <span class="comment"> * This program is distributed in the hope that it will be useful,</span>
|
||||
00009 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
|
||||
00010 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
|
||||
00011 <span class="comment"> * GNU General Public License for more details.</span>
|
||||
00012 <span class="comment"> *</span>
|
||||
00013 <span class="comment"> * You should have received a copy of the GNU General Public License</span>
|
||||
00014 <span class="comment"> * along with this program; if not, write to the Free Software</span>
|
||||
00015 <span class="comment"> * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>
|
||||
00016 <span class="comment"> */</span>
|
||||
00017
|
||||
00018 <span class="preprocessor">#ifndef ERROR_MEASURE_H</span>
|
||||
00019 <span class="preprocessor"></span><span class="preprocessor">#define ERROR_MEASURE_H</span>
|
||||
00020 <span class="preprocessor"></span>
|
||||
00021 <span class="preprocessor">#include "Scaling.h"</span>
|
||||
00022
|
||||
00023 <span class="keyword">class </span>ErrorMeasureImpl;
|
||||
00024 <span class="keyword">class </span>Sym;
|
||||
00025 <span class="keyword">class </span>Dataset;
|
||||
00026
|
||||
00027 <span class="keyword">class </span>ErrorMeasure {
|
||||
00028
|
||||
00029 ErrorMeasureImpl* pimpl;
|
||||
00030
|
||||
00031 <span class="keyword">public</span> :
|
||||
00032
|
||||
00033 <span class="keyword">enum</span> measure {
|
||||
00034 absolute,
|
||||
00035 mean_squared,
|
||||
00036 mean_squared_scaled,
|
||||
00037 };
|
||||
00038
|
||||
00039 <span class="keyword">struct </span>result {
|
||||
00040 <span class="keywordtype">double</span> error;
|
||||
00041 Scaling scaling;
|
||||
00042
|
||||
00043 result();
|
||||
00044 <span class="keywordtype">bool</span> valid() <span class="keyword">const</span>;
|
||||
00045 };
|
||||
00046
|
||||
00047 ErrorMeasure(<span class="keyword">const</span> Dataset& data, <span class="keywordtype">double</span> train_perc, measure meas = mean_squared);
|
||||
00048
|
||||
00049 ~ErrorMeasure();
|
||||
00050 ErrorMeasure(<span class="keyword">const</span> ErrorMeasure& that);
|
||||
00051 ErrorMeasure& operator=(<span class="keyword">const</span> ErrorMeasure& that);
|
||||
00052
|
||||
00053 result calc_error(Sym sym);
|
||||
00054
|
||||
00055 std::vector<result> calc_error(<span class="keyword">const</span> std::vector<Sym>& sym);
|
||||
00056
|
||||
00057 <span class="keywordtype">double</span> worst_performance() <span class="keyword">const</span>;
|
||||
00058 };
|
||||
00059
|
||||
00060 <span class="preprocessor">#endif</span>
|
||||
00061 <span class="preprocessor"></span>
|
||||
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:39 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>
|
||||
194
trunk/paradiseo-eo/doc/html/_first_bit_e_a_8cpp-source.html
Normal file
|
|
@ -0,0 +1,194 @@
|
|||
<!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: FirstBitEA.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_000003.html">tutorial</a> / <a class="el" href="dir_000004.html">Lesson2</a></div>
|
||||
<h1>FirstBitEA.cpp</h1><div class="fragment"><pre class="fragment">00001 <span class="comment">//-----------------------------------------------------------------------------</span>
|
||||
00002 <span class="comment">// FirstBitEA.cpp</span>
|
||||
00003 <span class="comment">//-----------------------------------------------------------------------------</span>
|
||||
00004 <span class="comment">//*</span>
|
||||
00005 <span class="comment">// Still an instance of a VERY simple Bitstring Genetic Algorithm</span>
|
||||
00006 <span class="comment">// (see FirstBitGA.cpp) but now with Breeder - and Combined Ops</span>
|
||||
00007 <span class="comment">//</span>
|
||||
00008 <span class="comment">//-----------------------------------------------------------------------------</span>
|
||||
00009 <span class="preprocessor">#ifdef HAVE_CONFIG_H</span>
|
||||
00010 <span class="preprocessor"></span><span class="preprocessor">#include <config.h></span>
|
||||
00011 <span class="preprocessor">#endif</span>
|
||||
00012 <span class="preprocessor"></span>
|
||||
00013 <span class="comment">// standard includes</span>
|
||||
00014 <span class="preprocessor">#include <stdexcept></span> <span class="comment">// runtime_error</span>
|
||||
00015 <span class="preprocessor">#include <iostream></span> <span class="comment">// cout</span>
|
||||
00016
|
||||
00017 <span class="comment">// the general include for eo</span>
|
||||
00018 <span class="preprocessor">#include <eo></span>
|
||||
00019 <span class="preprocessor">#include <ga.h></span>
|
||||
00020
|
||||
00021 <span class="comment">// Use functions from namespace std</span>
|
||||
00022 <span class="keyword">using</span> <span class="keyword">namespace </span>std;
|
||||
00023
|
||||
00024 <span class="comment">// REPRESENTATION</span>
|
||||
00025 <span class="comment">//-----------------------------------------------------------------------------</span>
|
||||
00026 <span class="comment">// define your individuals</span>
|
||||
00027 <span class="keyword">typedef</span> <a class="code" href="classeo_bit.html">eoBit<double></a> <a class="code" href="classeo_real.html">Indi</a>; <span class="comment">// A bitstring with fitness double</span>
|
||||
00028
|
||||
00029 <span class="comment">// EVALFUNC</span>
|
||||
00030 <span class="comment">//-----------------------------------------------------------------------------</span>
|
||||
00031 <span class="comment">// a simple fitness function that computes the number of ones of a bitstring</span>
|
||||
00032 <span class="comment">// Now in a separate file, and declared as binary_value(const vector<bool> &)</span>
|
||||
00033
|
||||
00034 <span class="preprocessor">#include "binary_value.h"</span>
|
||||
00035
|
||||
00036 <span class="comment">// GENERAL</span>
|
||||
00037 <span class="comment">//-----------------------------------------------------------------------------</span>
|
||||
00038
|
||||
00039 <span class="keywordtype">void</span> main_function(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> **argv)
|
||||
00040 {
|
||||
00041 <span class="comment">// PARAMETRES</span>
|
||||
00042 <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> SEED = 42; <span class="comment">// seed for random number generator</span>
|
||||
00043 <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> T_SIZE = 3; <span class="comment">// size for tournament selection</span>
|
||||
00044 <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> VEC_SIZE = 8; <span class="comment">// Number of bits in genotypes</span>
|
||||
00045 <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> POP_SIZE = 20; <span class="comment">// Size of population</span>
|
||||
00046
|
||||
00047 <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> MAX_GEN = 500; <span class="comment">// Maximum number of generation before STOP</span>
|
||||
00048 <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> MIN_GEN = 10; <span class="comment">// Minimum number of generation before ...</span>
|
||||
00049 <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> STEADY_GEN = 50; <span class="comment">// stop after STEADY_GEN gen. without improvelent</span>
|
||||
00050
|
||||
00051 <span class="keyword">const</span> <span class="keywordtype">double</span> P_CROSS = 0.8; <span class="comment">// Crossover probability</span>
|
||||
00052 <span class="keyword">const</span> <span class="keywordtype">double</span> P_MUT = 1.0; <span class="comment">// mutation probability</span>
|
||||
00053
|
||||
00054 <span class="keyword">const</span> <span class="keywordtype">double</span> P_MUT_PER_BIT = 0.01; <span class="comment">// internal probability for bit-flip mutation</span>
|
||||
00055 <span class="comment">// some parameters for chosing among different operators</span>
|
||||
00056 <span class="keyword">const</span> <span class="keywordtype">double</span> onePointRate = 0.5; <span class="comment">// rate for 1-pt Xover</span>
|
||||
00057 <span class="keyword">const</span> <span class="keywordtype">double</span> twoPointsRate = 0.5; <span class="comment">// rate for 2-pt Xover</span>
|
||||
00058 <span class="keyword">const</span> <span class="keywordtype">double</span> URate = 0.5; <span class="comment">// rate for Uniform Xover</span>
|
||||
00059 <span class="keyword">const</span> <span class="keywordtype">double</span> bitFlipRate = 0.5; <span class="comment">// rate for bit-flip mutation</span>
|
||||
00060 <span class="keyword">const</span> <span class="keywordtype">double</span> oneBitRate = 0.5; <span class="comment">// rate for one-bit mutation</span>
|
||||
00061
|
||||
00062 <span class="comment">// GENERAL</span>
|
||||
00064 <span class="comment"></span> <span class="comment">// Random seed</span>
|
||||
00066 <span class="comment"></span> <span class="comment">//reproducible random seed: if you don't change SEED above,</span>
|
||||
00067 <span class="comment">// you'll aways get the same result, NOT a random run</span>
|
||||
00068 rng.<a class="code" href="classeo_rng.html#a2">reseed</a>(SEED);
|
||||
00069
|
||||
00070 <span class="comment">// EVAL</span>
|
||||
00072 <span class="comment"></span> <span class="comment">// Fitness function</span>
|
||||
00074 <span class="comment"></span> <span class="comment">// Evaluation: from a plain C++ fn to an EvalFunc Object</span>
|
||||
00075 <span class="comment">// you need to give the full description of the function</span>
|
||||
00076 <a class="code" href="structeo_eval_func_ptr.html">eoEvalFuncPtr<Indi, double, const vector<bool></a>& > eval( binary_value );
|
||||
00077
|
||||
00078 <span class="comment">// INIT</span>
|
||||
00080 <span class="comment"></span> <span class="comment">// Initilisation of population</span>
|
||||
00082 <span class="comment"></span>
|
||||
00083 <span class="comment">// based on boolean_generator class (see utils/eoRndGenerators.h)</span>
|
||||
00084 <a class="code" href="classeo_uniform_generator.html">eoUniformGenerator<bool></a> uGen;
|
||||
00085 <a class="code" href="classeo_init_fixed_length.html">eoInitFixedLength<Indi></a> random(VEC_SIZE, uGen);
|
||||
00086 <span class="comment">// Initialization of the population</span>
|
||||
00087 <a class="code" href="classeo_pop.html">eoPop<Indi></a> pop(POP_SIZE, random);
|
||||
00088
|
||||
00089 <span class="comment">// and evaluate it in one loop</span>
|
||||
00090 apply<Indi>(eval, pop); <span class="comment">// STL syntax</span>
|
||||
00091
|
||||
00092 <span class="comment">// OUTPUT</span>
|
||||
00093 <span class="comment">// sort pop before printing it!</span>
|
||||
00094 pop.sort();
|
||||
00095 <span class="comment">// Print (sorted) intial population (raw printout)</span>
|
||||
00096 cout << <span class="stringliteral">"Initial Population"</span> << endl;
|
||||
00097 cout << pop;
|
||||
00098
|
||||
00099 <span class="comment">// ENGINE</span>
|
||||
00101 <span class="comment"></span> <span class="comment">// selection and replacement</span>
|
||||
00103 <span class="comment"></span><span class="comment">// SELECT</span>
|
||||
00104 <span class="comment">// The robust tournament selection</span>
|
||||
00105 <a class="code" href="classeo_det_tournament_select.html">eoDetTournamentSelect<Indi></a> selectOne(T_SIZE); <span class="comment">// T_SIZE in [2,POP_SIZE]</span>
|
||||
00106 <span class="comment">// is now encapsulated in a eoSelectPerc (entage)</span>
|
||||
00107 <a class="code" href="classeo_select_perc.html">eoSelectPerc<Indi></a> select(selectOne);<span class="comment">// by default rate==1</span>
|
||||
00108
|
||||
00109 <span class="comment">// REPLACE</span>
|
||||
00110 <span class="comment">// And we now have the full slection/replacement - though with</span>
|
||||
00111 <span class="comment">// no replacement (== generational replacement) at the moment :-)</span>
|
||||
00112 <a class="code" href="classeo_generational_replacement.html">eoGenerationalReplacement<Indi></a> replace;
|
||||
00113
|
||||
00114 <span class="comment">// OPERATORS</span>
|
||||
00116 <span class="comment"></span> <span class="comment">// The variation operators</span>
|
||||
00118 <span class="comment"></span><span class="comment">// CROSSOVER</span>
|
||||
00119 <span class="comment">// 1-point crossover for bitstring</span>
|
||||
00120 eo1PtBitXover<Indi> xover1;
|
||||
00121 <span class="comment">// uniform crossover for bitstring</span>
|
||||
00122 <a class="code" href="classeo_u_bit_xover.html">eoUBitXover<Indi></a> xoverU;
|
||||
00123 <span class="comment">// 2-pots xover</span>
|
||||
00124 <a class="code" href="classeo_n_pts_bit_xover.html">eoNPtsBitXover<Indi></a> xover2(2);
|
||||
00125 <span class="comment">// Combine them with relative rates</span>
|
||||
00126 <a class="code" href="classeo_prop_combined_quad_op.html">eoPropCombinedQuadOp<Indi></a> xover(xover1, onePointRate);
|
||||
00127 xover.add(xoverU, URate);
|
||||
00128 xover.add(xover2, twoPointsRate, <span class="keyword">true</span>);
|
||||
00129
|
||||
00130 <span class="comment">// MUTATION</span>
|
||||
00131 <span class="comment">// standard bit-flip mutation for bitstring</span>
|
||||
00132 <a class="code" href="classeo_bit_mutation.html">eoBitMutation<Indi></a> mutationBitFlip(P_MUT_PER_BIT);
|
||||
00133 <span class="comment">// mutate exactly 1 bit per individual</span>
|
||||
00134 <a class="code" href="classeo_det_bit_flip.html">eoDetBitFlip<Indi></a> mutationOneBit;
|
||||
00135 <span class="comment">// Combine them with relative rates</span>
|
||||
00136 <a class="code" href="classeo_prop_combined_mon_op.html">eoPropCombinedMonOp<Indi></a> mutation(mutationBitFlip, bitFlipRate);
|
||||
00137 mutation.add(mutationOneBit, oneBitRate, <span class="keyword">true</span>);
|
||||
00138
|
||||
00139 <span class="comment">// The operators are encapsulated into an eoTRansform object</span>
|
||||
00140 <a class="code" href="classeo_s_g_a_transform.html">eoSGATransform<Indi></a> transform(xover, P_CROSS, mutation, P_MUT);
|
||||
00141
|
||||
00142 <span class="comment">// STOP</span>
|
||||
00143 <span class="comment">// CHECKPOINT</span>
|
||||
00145 <span class="comment"></span> <span class="comment">// termination conditions: use more than one</span>
|
||||
00147 <span class="comment"></span> <span class="comment">// stop after MAX_GEN generations</span>
|
||||
00148 <a class="code" href="classeo_gen_continue.html">eoGenContinue<Indi></a> genCont(MAX_GEN);
|
||||
00149 <span class="comment">// do MIN_GEN gen., then stop after STEADY_GEN gen. without improvement</span>
|
||||
00150 <a class="code" href="classeo_steady_fit_continue.html">eoSteadyFitContinue<Indi></a> steadyCont(MIN_GEN, STEADY_GEN);
|
||||
00151 <span class="comment">// stop when fitness reaches a target (here VEC_SIZE)</span>
|
||||
00152 <a class="code" href="classeo_fit_continue.html">eoFitContinue<Indi></a> fitCont(VEC_SIZE);
|
||||
00153 <span class="comment">// do stop when one of the above says so</span>
|
||||
00154 <a class="code" href="classeo_combined_continue.html">eoCombinedContinue<Indi></a> continuator(genCont);
|
||||
00155 continuator.add(steadyCont);
|
||||
00156 continuator.add(fitCont);
|
||||
00157
|
||||
00158 <span class="comment">// GENERATION</span>
|
||||
00160 <span class="comment"></span> <span class="comment">// the algorithm</span>
|
||||
00162 <span class="comment"></span>
|
||||
00163 <span class="comment">// Easy EA requires</span>
|
||||
00164 <span class="comment">// selection, transformation, eval, replacement, and stopping criterion</span>
|
||||
00165 <a class="code" href="classeo_easy_e_a.html">eoEasyEA<Indi></a> gga(continuator, eval, select, transform, replace);
|
||||
00166
|
||||
00167 <span class="comment">// Apply algo to pop - that's it!</span>
|
||||
00168 cout << <span class="stringliteral">"\n Here we go\n\n"</span>;
|
||||
00169 gga(pop);
|
||||
00170
|
||||
00171 <span class="comment">// OUTPUT</span>
|
||||
00172 <span class="comment">// Print (sorted) intial population</span>
|
||||
00173 pop.sort();
|
||||
00174 cout << <span class="stringliteral">"FINAL Population\n"</span> << pop << endl;
|
||||
00175 <span class="comment">// GENERAL</span>
|
||||
00176 }
|
||||
00177
|
||||
00178 <span class="comment">// A main that catches the exceptions</span>
|
||||
00179
|
||||
00180 <span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> **argv)
|
||||
00181 {
|
||||
00182
|
||||
00183 <span class="keywordflow">try</span>
|
||||
00184 {
|
||||
00185 main_function(argc, argv);
|
||||
00186 }
|
||||
00187 <span class="keywordflow">catch</span>(exception& e)
|
||||
00188 {
|
||||
00189 cout << <span class="stringliteral">"Exception: "</span> << e.what() << <span class="charliteral">'\n'</span>;
|
||||
00190 }
|
||||
00191
|
||||
00192 <span class="keywordflow">return</span> 1;
|
||||
00193 }
|
||||
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:39 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>
|
||||
168
trunk/paradiseo-eo/doc/html/_first_bit_g_a_8cpp-source.html
Normal file
|
|
@ -0,0 +1,168 @@
|
|||
<!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: FirstBitGA.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_000003.html">tutorial</a> / <a class="el" href="dir_000019.html">Lesson1</a></div>
|
||||
<h1>FirstBitGA.cpp</h1><div class="fragment"><pre class="fragment">00001 <span class="comment">//-----------------------------------------------------------------------------</span>
|
||||
00002 <span class="comment">// FirstBitGA.cpp</span>
|
||||
00003 <span class="comment">//-----------------------------------------------------------------------------</span>
|
||||
00004 <span class="comment">//*</span>
|
||||
00005 <span class="comment">// An instance of a VERY simple Bitstring Genetic Algorithm</span>
|
||||
00006 <span class="comment">//</span>
|
||||
00007 <span class="comment">//-----------------------------------------------------------------------------</span>
|
||||
00008
|
||||
00009 <span class="preprocessor">#ifdef HAVE_CONFIG_H</span>
|
||||
00010 <span class="preprocessor"></span><span class="preprocessor">#include <config.h></span>
|
||||
00011 <span class="preprocessor">#endif</span>
|
||||
00012 <span class="preprocessor"></span>
|
||||
00013 <span class="preprocessor">#include <stdexcept></span>
|
||||
00014 <span class="preprocessor">#include <iostream></span>
|
||||
00015
|
||||
00016 <span class="preprocessor">#include <eo></span>
|
||||
00017 <span class="preprocessor">#include <ga.h></span>
|
||||
00018
|
||||
00019 <span class="comment">// Use functions from namespace std</span>
|
||||
00020 <span class="keyword">using</span> <span class="keyword">namespace </span>std;
|
||||
00021
|
||||
00022 <span class="comment">// REPRESENTATION</span>
|
||||
00023 <span class="comment">//-----------------------------------------------------------------------------</span>
|
||||
00024 <span class="comment">// define your individuals</span>
|
||||
00025 <span class="keyword">typedef</span> <a class="code" href="classeo_bit.html">eoBit<double></a> <a class="code" href="classeo_real.html">Indi</a>; <span class="comment">// A bitstring with fitness double</span>
|
||||
00026
|
||||
00027 <span class="comment">// EVAL</span>
|
||||
00028 <span class="comment">//-----------------------------------------------------------------------------</span>
|
||||
00029 <span class="comment">// a simple fitness function that computes the number of ones of a bitstring</span>
|
||||
00030 <span class="comment">// @param _indi A biststring individual</span>
|
||||
00031
|
||||
00032 <span class="keywordtype">double</span> binary_value(<span class="keyword">const</span> Indi & _indi)
|
||||
00033 {
|
||||
00034 <span class="keywordtype">double</span> sum = 0;
|
||||
00035 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < _indi.size(); i++)
|
||||
00036 sum += _indi[i];
|
||||
00037 <span class="keywordflow">return</span> sum;
|
||||
00038 }
|
||||
00039 <span class="comment">// GENERAL</span>
|
||||
00040 <span class="comment">//-----------------------------------------------------------------------------</span>
|
||||
00041 <span class="keywordtype">void</span> main_function(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> **argv)
|
||||
00042 {
|
||||
00043 <span class="comment">// PARAMETRES</span>
|
||||
00044 <span class="comment">// all parameters are hard-coded!</span>
|
||||
00045 <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> SEED = 42; <span class="comment">// seed for random number generator</span>
|
||||
00046 <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> T_SIZE = 3; <span class="comment">// size for tournament selection</span>
|
||||
00047 <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> VEC_SIZE = 16; <span class="comment">// Number of bits in genotypes</span>
|
||||
00048 <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> POP_SIZE = 100; <span class="comment">// Size of population</span>
|
||||
00049 <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> MAX_GEN = 400; <span class="comment">// Maximum number of generation before STOP</span>
|
||||
00050 <span class="keyword">const</span> <span class="keywordtype">float</span> CROSS_RATE = 0.8; <span class="comment">// Crossover rate</span>
|
||||
00051 <span class="keyword">const</span> <span class="keywordtype">double</span> P_MUT_PER_BIT = 0.01; <span class="comment">// probability of bit-flip mutation</span>
|
||||
00052 <span class="keyword">const</span> <span class="keywordtype">float</span> MUT_RATE = 1.0; <span class="comment">// mutation rate</span>
|
||||
00053
|
||||
00054 <span class="comment">// GENERAL</span>
|
||||
00056 <span class="comment"></span> <span class="comment">// Random seed</span>
|
||||
00058 <span class="comment"></span> <span class="comment">//reproducible random seed: if you don't change SEED above,</span>
|
||||
00059 <span class="comment">// you'll aways get the same result, NOT a random run</span>
|
||||
00060 rng.<a class="code" href="classeo_rng.html#a2">reseed</a>(SEED);
|
||||
00061
|
||||
00062 <span class="comment">// EVAL</span>
|
||||
00064 <span class="comment"></span> <span class="comment">// Fitness function</span>
|
||||
00066 <span class="comment"></span> <span class="comment">// Evaluation: from a plain C++ fn to an EvalFunc Object</span>
|
||||
00067 <a class="code" href="structeo_eval_func_ptr.html">eoEvalFuncPtr<Indi></a> eval( binary_value );
|
||||
00068
|
||||
00069 <span class="comment">// INIT</span>
|
||||
00071 <span class="comment"></span> <span class="comment">// Initilisation of population</span>
|
||||
00073 <span class="comment"></span>
|
||||
00074 <span class="comment">// declare the population</span>
|
||||
00075 <a class="code" href="classeo_pop.html">eoPop<Indi></a> pop;
|
||||
00076 <span class="comment">// fill it!</span>
|
||||
00077 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> igeno=0; igeno<POP_SIZE; igeno++)
|
||||
00078 {
|
||||
00079 Indi v; <span class="comment">// void individual, to be filled</span>
|
||||
00080 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> ivar=0; ivar<VEC_SIZE; ivar++)
|
||||
00081 {
|
||||
00082 <span class="keywordtype">bool</span> r = rng.<a class="code" href="classeo_rng.html#a6">flip</a>(); <span class="comment">// new value, random in {0,1}</span>
|
||||
00083 v.push_back(r); <span class="comment">// append that random value to v</span>
|
||||
00084 }
|
||||
00085 eval(v); <span class="comment">// evaluate it</span>
|
||||
00086 pop.push_back(v); <span class="comment">// and put it in the population</span>
|
||||
00087 }
|
||||
00088
|
||||
00089 <span class="comment">// OUTPUT</span>
|
||||
00090 <span class="comment">// sort pop before printing it!</span>
|
||||
00091 pop.<a class="code" href="classeo_pop.html#a5">sort</a>();
|
||||
00092 <span class="comment">// Print (sorted) intial population (raw printout)</span>
|
||||
00093 cout << <span class="stringliteral">"Initial Population"</span> << endl;
|
||||
00094 cout << pop;
|
||||
00095 <span class="comment">// shuffle - this is a test</span>
|
||||
00096 pop.<a class="code" href="classeo_pop.html#a7">shuffle</a>();
|
||||
00097 <span class="comment">// Print (sorted) intial population (raw printout)</span>
|
||||
00098 cout << <span class="stringliteral">"Shuffled Population"</span> << endl;
|
||||
00099 cout << pop;
|
||||
00100
|
||||
00101 <span class="comment">// ENGINE</span>
|
||||
00103 <span class="comment"></span> <span class="comment">// selection and replacement</span>
|
||||
00105 <span class="comment"></span><span class="comment">// SELECT</span>
|
||||
00106 <span class="comment">// The robust tournament selection</span>
|
||||
00107 <a class="code" href="classeo_det_tournament_select.html">eoDetTournamentSelect<Indi></a> select(T_SIZE); <span class="comment">// T_SIZE in [2,POP_SIZE]</span>
|
||||
00108
|
||||
00109 <span class="comment">// REPLACE</span>
|
||||
00110 <span class="comment">// The simple GA evolution engine uses generational replacement</span>
|
||||
00111 <span class="comment">// so no replacement procedure is needed</span>
|
||||
00112
|
||||
00113 <span class="comment">// OPERATORS</span>
|
||||
00115 <span class="comment"></span> <span class="comment">// The variation operators</span>
|
||||
00117 <span class="comment"></span><span class="comment">// CROSSOVER</span>
|
||||
00118 <span class="comment">// 1-point crossover for bitstring</span>
|
||||
00119 eo1PtBitXover<Indi> xover;
|
||||
00120 <span class="comment">// MUTATION</span>
|
||||
00121 <span class="comment">// standard bit-flip mutation for bitstring</span>
|
||||
00122 <a class="code" href="classeo_bit_mutation.html">eoBitMutation<Indi></a> mutation(P_MUT_PER_BIT);
|
||||
00123
|
||||
00124 <span class="comment">// STOP</span>
|
||||
00125 <span class="comment">// CHECKPOINT</span>
|
||||
00127 <span class="comment"></span> <span class="comment">// termination condition</span>
|
||||
00129 <span class="comment"></span> <span class="comment">// stop after MAX_GEN generations</span>
|
||||
00130 <a class="code" href="classeo_gen_continue.html">eoGenContinue<Indi></a> continuator(MAX_GEN);
|
||||
00131
|
||||
00132 <span class="comment">// GENERATION</span>
|
||||
00134 <span class="comment"></span> <span class="comment">// the algorithm</span>
|
||||
00136 <span class="comment"></span> <span class="comment">// standard Generational GA requires as parameters</span>
|
||||
00137 <span class="comment">// selection, evaluation, crossover and mutation, stopping criterion</span>
|
||||
00138
|
||||
00139
|
||||
00140 <a class="code" href="classeo_s_g_a.html">eoSGA<Indi></a> gga(select, xover, CROSS_RATE, mutation, MUT_RATE,
|
||||
00141 eval, continuator);
|
||||
00142
|
||||
00143 <span class="comment">// Apply algo to pop - that's it!</span>
|
||||
00144 gga(pop);
|
||||
00145
|
||||
00146 <span class="comment">// OUTPUT</span>
|
||||
00147 <span class="comment">// Print (sorted) intial population</span>
|
||||
00148 pop.<a class="code" href="classeo_pop.html#a5">sort</a>();
|
||||
00149 cout << <span class="stringliteral">"FINAL Population\n"</span> << pop << endl;
|
||||
00150 <span class="comment">// GENERAL</span>
|
||||
00151 }
|
||||
00152 <span class="comment">// A main that catches the exceptions</span>
|
||||
00153
|
||||
00154 <span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> **argv)
|
||||
00155 {
|
||||
00156
|
||||
00157 <span class="keywordflow">try</span>
|
||||
00158 {
|
||||
00159 main_function(argc, argv);
|
||||
00160 }
|
||||
00161 <span class="keywordflow">catch</span>(exception& e)
|
||||
00162 {
|
||||
00163 cout << <span class="stringliteral">"Exception: "</span> << e.what() << <span class="charliteral">'\n'</span>;
|
||||
00164 }
|
||||
00165
|
||||
00166 <span class="keywordflow">return</span> 1;
|
||||
00167 }
|
||||
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:39 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>
|
||||
193
trunk/paradiseo-eo/doc/html/_first_real_e_a_8cpp-source.html
Normal file
|
|
@ -0,0 +1,193 @@
|
|||
<!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: FirstRealEA.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_000003.html">tutorial</a> / <a class="el" href="dir_000004.html">Lesson2</a></div>
|
||||
<h1>FirstRealEA.cpp</h1><div class="fragment"><pre class="fragment">00001 <span class="comment">//-----------------------------------------------------------------------------</span>
|
||||
00002 <span class="comment">// FirstRealEA.cpp</span>
|
||||
00003 <span class="comment">//-----------------------------------------------------------------------------</span>
|
||||
00004 <span class="comment">//*</span>
|
||||
00005 <span class="comment">// Still an instance of a VERY simple Real-coded Genetic Algorithm</span>
|
||||
00006 <span class="comment">// (see FirstBitGA.cpp) but now with Breeder - and Combined Ops</span>
|
||||
00007 <span class="comment">//</span>
|
||||
00008 <span class="comment">//-----------------------------------------------------------------------------</span>
|
||||
00009 <span class="preprocessor">#ifdef HAVE_CONFIG_H</span>
|
||||
00010 <span class="preprocessor"></span><span class="preprocessor">#include <config.h></span>
|
||||
00011 <span class="preprocessor">#endif</span>
|
||||
00012 <span class="preprocessor"></span>
|
||||
00013 <span class="comment">// standard includes</span>
|
||||
00014 <span class="preprocessor">#include <stdexcept></span> <span class="comment">// runtime_error</span>
|
||||
00015 <span class="preprocessor">#include <iostream></span> <span class="comment">// cout</span>
|
||||
00016
|
||||
00017 <span class="comment">// the general include for eo</span>
|
||||
00018 <span class="preprocessor">#include <eo></span>
|
||||
00019 <span class="preprocessor">#include <es.h></span>
|
||||
00020
|
||||
00021 <span class="comment">// REPRESENTATION</span>
|
||||
00022 <span class="comment">//-----------------------------------------------------------------------------</span>
|
||||
00023 <span class="comment">// define your individuals</span>
|
||||
00024 <span class="keyword">typedef</span> <a class="code" href="classeo_real.html">eoReal<double></a> <a class="code" href="classeo_real.html">Indi</a>;
|
||||
00025
|
||||
00026 <span class="comment">// Use functions from namespace std</span>
|
||||
00027 <span class="keyword">using</span> <span class="keyword">namespace </span>std;
|
||||
00028
|
||||
00029 <span class="comment">// EVALFUNC</span>
|
||||
00030 <span class="comment">//-----------------------------------------------------------------------------</span>
|
||||
00031 <span class="comment">// a simple fitness function that computes the euclidian norm of a real vector</span>
|
||||
00032 <span class="comment">// Now in a separate file, and declared as binary_value(const vector<bool> &)</span>
|
||||
00033
|
||||
00034 <span class="preprocessor">#include "real_value.h"</span>
|
||||
00035
|
||||
00036 <span class="comment">// GENERAL</span>
|
||||
00037 <span class="comment">//-----------------------------------------------------------------------------</span>
|
||||
00038
|
||||
00039 <span class="keywordtype">void</span> main_function(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> **argv)
|
||||
00040 {
|
||||
00041 <span class="comment">// PARAMETRES</span>
|
||||
00042 <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> SEED = 42; <span class="comment">// seed for random number generator</span>
|
||||
00043 <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> T_SIZE = 3; <span class="comment">// size for tournament selection</span>
|
||||
00044 <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> VEC_SIZE = 8; <span class="comment">// Number of object variables in genotypes</span>
|
||||
00045 <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> POP_SIZE = 20; <span class="comment">// Size of population</span>
|
||||
00046
|
||||
00047 <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> MAX_GEN = 500; <span class="comment">// Maximum number of generation before STOP</span>
|
||||
00048 <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> MIN_GEN = 10; <span class="comment">// Minimum number of generation before ...</span>
|
||||
00049 <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> STEADY_GEN = 50; <span class="comment">// stop after STEADY_GEN gen. without improvelent</span>
|
||||
00050
|
||||
00051 <span class="keyword">const</span> <span class="keywordtype">float</span> P_CROSS = 0.8; <span class="comment">// Crossover probability</span>
|
||||
00052 <span class="keyword">const</span> <span class="keywordtype">float</span> P_MUT = 0.5; <span class="comment">// mutation probability</span>
|
||||
00053
|
||||
00054 <span class="keyword">const</span> <span class="keywordtype">double</span> EPSILON = 0.01; <span class="comment">// range for real uniform mutation</span>
|
||||
00055 <span class="keywordtype">double</span> SIGMA = 0.3; <span class="comment">// std dev. for normal mutation</span>
|
||||
00056 <span class="comment">// some parameters for chosing among different operators</span>
|
||||
00057 <span class="keyword">const</span> <span class="keywordtype">double</span> hypercubeRate = 0.5; <span class="comment">// relative weight for hypercube Xover</span>
|
||||
00058 <span class="keyword">const</span> <span class="keywordtype">double</span> segmentRate = 0.5; <span class="comment">// relative weight for segment Xover</span>
|
||||
00059 <span class="keyword">const</span> <span class="keywordtype">double</span> uniformMutRate = 0.5; <span class="comment">// relative weight for uniform mutation</span>
|
||||
00060 <span class="keyword">const</span> <span class="keywordtype">double</span> detMutRate = 0.5; <span class="comment">// relative weight for det-uniform mutation</span>
|
||||
00061 <span class="keyword">const</span> <span class="keywordtype">double</span> normalMutRate = 0.5; <span class="comment">// relative weight for normal mutation</span>
|
||||
00062
|
||||
00063 <span class="comment">// GENERAL</span>
|
||||
00065 <span class="comment"></span> <span class="comment">// Random seed</span>
|
||||
00067 <span class="comment"></span> <span class="comment">//reproducible random seed: if you don't change SEED above,</span>
|
||||
00068 <span class="comment">// you'll aways get the same result, NOT a random run</span>
|
||||
00069 rng.<a class="code" href="classeo_rng.html#a2">reseed</a>(SEED);
|
||||
00070
|
||||
00071 <span class="comment">// EVAL</span>
|
||||
00073 <span class="comment"></span> <span class="comment">// Fitness function</span>
|
||||
00075 <span class="comment"></span> <span class="comment">// Evaluation: from a plain C++ fn to an EvalFunc Object</span>
|
||||
00076 <span class="comment">// you need to give the full description of the function</span>
|
||||
00077 <a class="code" href="structeo_eval_func_ptr.html">eoEvalFuncPtr<Indi, double, const vector<double></a>& > eval( real_value );
|
||||
00078
|
||||
00079 <span class="comment">// INIT</span>
|
||||
00081 <span class="comment"></span> <span class="comment">// Initilisation of population</span>
|
||||
00083 <span class="comment"></span> <span class="comment">// based on a uniform generator</span>
|
||||
00084 <a class="code" href="classeo_uniform_generator.html">eoUniformGenerator<double></a> uGen(-1.0, 1.0);
|
||||
00085 <a class="code" href="classeo_init_fixed_length.html">eoInitFixedLength<Indi></a> random(VEC_SIZE, uGen);
|
||||
00086 <span class="comment">// Initialization of the population</span>
|
||||
00087 <a class="code" href="classeo_pop.html">eoPop<Indi></a> pop(POP_SIZE, random);
|
||||
00088
|
||||
00089 <span class="comment">// and evaluate it in one loop</span>
|
||||
00090 apply<Indi>(eval, pop); <span class="comment">// STL syntax</span>
|
||||
00091
|
||||
00092 <span class="comment">// OUTPUT</span>
|
||||
00093 <span class="comment">// sort pop before printing it!</span>
|
||||
00094 pop.sort();
|
||||
00095 <span class="comment">// Print (sorted) intial population (raw printout)</span>
|
||||
00096 cout << <span class="stringliteral">"Initial Population"</span> << endl;
|
||||
00097 cout << pop;
|
||||
00098
|
||||
00099 <span class="comment">// ENGINE</span>
|
||||
00101 <span class="comment"></span> <span class="comment">// selection and replacement</span>
|
||||
00103 <span class="comment"></span><span class="comment">// SELECT</span>
|
||||
00104 <span class="comment">// The robust tournament selection</span>
|
||||
00105 <a class="code" href="classeo_det_tournament_select.html">eoDetTournamentSelect<Indi></a> selectOne(T_SIZE);
|
||||
00106 <span class="comment">// is now encapsulated in a eoSelectPerc (entage)</span>
|
||||
00107 <a class="code" href="classeo_select_perc.html">eoSelectPerc<Indi></a> select(selectOne);<span class="comment">// by default rate==1</span>
|
||||
00108
|
||||
00109 <span class="comment">// REPLACE</span>
|
||||
00110 <span class="comment">// And we now have the full slection/replacement - though with</span>
|
||||
00111 <span class="comment">// no replacement (== generational replacement) at the moment :-)</span>
|
||||
00112 <a class="code" href="classeo_generational_replacement.html">eoGenerationalReplacement<Indi></a> replace;
|
||||
00113
|
||||
00114 <span class="comment">// OPERATORS</span>
|
||||
00116 <span class="comment"></span> <span class="comment">// The variation operators</span>
|
||||
00118 <span class="comment"></span><span class="comment">// CROSSOVER</span>
|
||||
00119 <span class="comment">// uniform chooce on segment made by the parents</span>
|
||||
00120 <a class="code" href="classeo_segment_crossover.html">eoSegmentCrossover<Indi></a> xoverS;
|
||||
00121 <span class="comment">// uniform choice in hypercube built by the parents</span>
|
||||
00122 eoHypercubeCrossover<Indi> xoverA;
|
||||
00123 <span class="comment">// Combine them with relative weights</span>
|
||||
00124 <a class="code" href="classeo_prop_combined_quad_op.html">eoPropCombinedQuadOp<Indi></a> xover(xoverS, segmentRate);
|
||||
00125 xover.add(xoverA, hypercubeRate, <span class="keyword">true</span>);
|
||||
00126
|
||||
00127 <span class="comment">// MUTATION</span>
|
||||
00128 <span class="comment">// offspring(i) uniformly chosen in [parent(i)-epsilon, parent(i)+epsilon]</span>
|
||||
00129 <a class="code" href="classeo_uniform_mutation.html">eoUniformMutation<Indi></a> mutationU(EPSILON);
|
||||
00130 <span class="comment">// k (=1) coordinates of parents are uniformly modified</span>
|
||||
00131 <a class="code" href="classeo_det_uniform_mutation.html">eoDetUniformMutation<Indi></a> mutationD(EPSILON);
|
||||
00132 <span class="comment">// all coordinates of parents are normally modified (stDev SIGMA)</span>
|
||||
00133 <a class="code" href="classeo_normal_mutation.html">eoNormalMutation<Indi></a> mutationN(SIGMA);
|
||||
00134 <span class="comment">// Combine them with relative weights</span>
|
||||
00135 <a class="code" href="classeo_prop_combined_mon_op.html">eoPropCombinedMonOp<Indi></a> mutation(mutationU, uniformMutRate);
|
||||
00136 mutation.add(mutationD, detMutRate);
|
||||
00137 mutation.add(mutationN, normalMutRate, <span class="keyword">true</span>);
|
||||
00138
|
||||
00139 <span class="comment">// STOP</span>
|
||||
00140 <span class="comment">// CHECKPOINT</span>
|
||||
00142 <span class="comment"></span> <span class="comment">// termination conditions: use more than one</span>
|
||||
00144 <span class="comment"></span> <span class="comment">// stop after MAX_GEN generations</span>
|
||||
00145 <a class="code" href="classeo_gen_continue.html">eoGenContinue<Indi></a> genCont(MAX_GEN);
|
||||
00146 <span class="comment">// do MIN_GEN gen., then stop after STEADY_GEN gen. without improvement</span>
|
||||
00147 <a class="code" href="classeo_steady_fit_continue.html">eoSteadyFitContinue<Indi></a> steadyCont(MIN_GEN, STEADY_GEN);
|
||||
00148 <span class="comment">// stop when fitness reaches a target (here VEC_SIZE)</span>
|
||||
00149 <a class="code" href="classeo_fit_continue.html">eoFitContinue<Indi></a> fitCont(0);
|
||||
00150 <span class="comment">// do stop when one of the above says so</span>
|
||||
00151 <a class="code" href="classeo_combined_continue.html">eoCombinedContinue<Indi></a> continuator(genCont);
|
||||
00152 continuator.add(steadyCont);
|
||||
00153 continuator.add(fitCont);
|
||||
00154
|
||||
00155 <span class="comment">// The operators are encapsulated into an eoTRansform object</span>
|
||||
00156 <a class="code" href="classeo_s_g_a_transform.html">eoSGATransform<Indi></a> transform(xover, P_CROSS, mutation, P_MUT);
|
||||
00157
|
||||
00158 <span class="comment">// GENERATION</span>
|
||||
00160 <span class="comment"></span> <span class="comment">// the algorithm</span>
|
||||
00162 <span class="comment"></span>
|
||||
00163 <span class="comment">// Easy EA requires</span>
|
||||
00164 <span class="comment">// selection, transformation, eval, replacement, and stopping criterion</span>
|
||||
00165 <a class="code" href="classeo_easy_e_a.html">eoEasyEA<Indi></a> gga(continuator, eval, select, transform, replace);
|
||||
00166
|
||||
00167 <span class="comment">// Apply algo to pop - that's it!</span>
|
||||
00168 cout << <span class="stringliteral">"\n Here we go\n\n"</span>;
|
||||
00169 gga(pop);
|
||||
00170
|
||||
00171 <span class="comment">// OUTPUT</span>
|
||||
00172 <span class="comment">// Print (sorted) intial population</span>
|
||||
00173 pop.sort();
|
||||
00174 cout << <span class="stringliteral">"FINAL Population\n"</span> << pop << endl;
|
||||
00175 <span class="comment">// GENERAL</span>
|
||||
00176 }
|
||||
00177
|
||||
00178 <span class="comment">// A main that catches the exceptions</span>
|
||||
00179
|
||||
00180 <span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> **argv)
|
||||
00181 {
|
||||
00182 <span class="keywordflow">try</span>
|
||||
00183 {
|
||||
00184 main_function(argc, argv);
|
||||
00185 }
|
||||
00186 <span class="keywordflow">catch</span>(exception& e)
|
||||
00187 {
|
||||
00188 cout << <span class="stringliteral">"Exception: "</span> << e.what() << <span class="charliteral">'\n'</span>;
|
||||
00189 }
|
||||
00190
|
||||
00191 <span class="keywordflow">return</span> 1;
|
||||
00192 }
|
||||
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:39 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>
|
||||
163
trunk/paradiseo-eo/doc/html/_first_real_g_a_8cpp-source.html
Normal file
|
|
@ -0,0 +1,163 @@
|
|||
<!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: FirstRealGA.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_000003.html">tutorial</a> / <a class="el" href="dir_000019.html">Lesson1</a></div>
|
||||
<h1>FirstRealGA.cpp</h1><div class="fragment"><pre class="fragment">00001 <span class="comment">//-----------------------------------------------------------------------------</span>
|
||||
00002 <span class="comment">// FirstRealGA.cpp</span>
|
||||
00003 <span class="comment">//-----------------------------------------------------------------------------</span>
|
||||
00004 <span class="comment">//*</span>
|
||||
00005 <span class="comment">// An instance of a VERY simple Real-coded Genetic Algorithm</span>
|
||||
00006 <span class="comment">//</span>
|
||||
00007 <span class="comment">//-----------------------------------------------------------------------------</span>
|
||||
00008 <span class="preprocessor">#ifdef HAVE_CONFIG_H</span>
|
||||
00009 <span class="preprocessor"></span><span class="preprocessor">#include <config.h></span>
|
||||
00010 <span class="preprocessor">#endif</span>
|
||||
00011 <span class="preprocessor"></span>
|
||||
00012 <span class="preprocessor">#include <stdexcept></span>
|
||||
00013 <span class="preprocessor">#include <iostream></span>
|
||||
00014 <span class="preprocessor">#include <sstream></span>
|
||||
00015
|
||||
00016 <span class="preprocessor">#include <eo></span>
|
||||
00017 <span class="preprocessor">#include <es.h></span>
|
||||
00018
|
||||
00019 <span class="comment">// Use functions from namespace std</span>
|
||||
00020 <span class="keyword">using</span> <span class="keyword">namespace </span>std;
|
||||
00021
|
||||
00022 <span class="comment">// REPRESENTATION</span>
|
||||
00023 <span class="comment">//-----------------------------------------------------------------------------</span>
|
||||
00024 <span class="comment">// define your individuals</span>
|
||||
00025 <span class="keyword">typedef</span> <a class="code" href="classeo_real.html">eoReal<double></a> <a class="code" href="classeo_real.html">Indi</a>;
|
||||
00026
|
||||
00027 <span class="comment">// EVAL</span>
|
||||
00028 <span class="comment">//-----------------------------------------------------------------------------</span>
|
||||
00029 <span class="comment">// a simple fitness function that computes the euclidian norm of a real vector</span>
|
||||
00030 <span class="comment">// @param _indi A real-valued individual</span>
|
||||
00031
|
||||
00032 <span class="keywordtype">double</span> real_value(<span class="keyword">const</span> Indi & _indi)
|
||||
00033 {
|
||||
00034 <span class="keywordtype">double</span> sum = 0;
|
||||
00035 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < _indi.size(); i++)
|
||||
00036 sum += _indi[i]*_indi[i];
|
||||
00037 <span class="keywordflow">return</span> (-sum); <span class="comment">// maximizing only</span>
|
||||
00038 }
|
||||
00039 <span class="comment">// GENERAL</span>
|
||||
00040 <span class="comment">//-----------------------------------------------------------------------------</span>
|
||||
00041 <span class="keywordtype">void</span> main_function(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> **argv)
|
||||
00042 {
|
||||
00043 <span class="comment">// PARAMETRES</span>
|
||||
00044 <span class="comment">// all parameters are hard-coded!</span>
|
||||
00045 <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> SEED = 42; <span class="comment">// seed for random number generator</span>
|
||||
00046 <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> VEC_SIZE = 8; <span class="comment">// Number of object variables in genotypes</span>
|
||||
00047 <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> POP_SIZE = 20; <span class="comment">// Size of population</span>
|
||||
00048 <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> T_SIZE = 3; <span class="comment">// size for tournament selection</span>
|
||||
00049 <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> MAX_GEN = 500; <span class="comment">// Maximum number of generation before STOP</span>
|
||||
00050 <span class="keyword">const</span> <span class="keywordtype">float</span> CROSS_RATE = 0.8; <span class="comment">// Crossover rate</span>
|
||||
00051 <span class="keyword">const</span> <span class="keywordtype">double</span> EPSILON = 0.01; <span class="comment">// range for real uniform mutation</span>
|
||||
00052 <span class="keyword">const</span> <span class="keywordtype">float</span> MUT_RATE = 0.5; <span class="comment">// mutation rate</span>
|
||||
00053
|
||||
00054 <span class="comment">// GENERAL</span>
|
||||
00056 <span class="comment"></span> <span class="comment">// Random seed</span>
|
||||
00058 <span class="comment"></span> <span class="comment">//reproducible random seed: if you don't change SEED above,</span>
|
||||
00059 <span class="comment">// you'll aways get the same result, NOT a random run</span>
|
||||
00060 rng.<a class="code" href="classeo_rng.html#a2">reseed</a>(SEED);
|
||||
00061
|
||||
00062 <span class="comment">// EVAL</span>
|
||||
00064 <span class="comment"></span> <span class="comment">// Fitness function</span>
|
||||
00066 <span class="comment"></span> <span class="comment">// Evaluation: from a plain C++ fn to an EvalFunc Object</span>
|
||||
00067 <a class="code" href="structeo_eval_func_ptr.html">eoEvalFuncPtr<Indi></a> eval( real_value );
|
||||
00068
|
||||
00069 <span class="comment">// INIT</span>
|
||||
00071 <span class="comment"></span> <span class="comment">// Initilisation of population</span>
|
||||
00073 <span class="comment"></span>
|
||||
00074 <span class="comment">// declare the population</span>
|
||||
00075 <a class="code" href="classeo_pop.html">eoPop<Indi></a> pop;
|
||||
00076 <span class="comment">// fill it!</span>
|
||||
00077 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> igeno=0; igeno<POP_SIZE; igeno++)
|
||||
00078 {
|
||||
00079 Indi v; <span class="comment">// void individual, to be filled</span>
|
||||
00080 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> ivar=0; ivar<VEC_SIZE; ivar++)
|
||||
00081 {
|
||||
00082 <span class="keywordtype">double</span> r = 2*rng.<a class="code" href="classeo_rng.html#a4">uniform</a>() - 1; <span class="comment">// new value, random in [-1,1)</span>
|
||||
00083 v.push_back(r); <span class="comment">// append that random value to v</span>
|
||||
00084 }
|
||||
00085 eval(v); <span class="comment">// evaluate it</span>
|
||||
00086 pop.push_back(v); <span class="comment">// and put it in the population</span>
|
||||
00087 }
|
||||
00088
|
||||
00089 <span class="comment">// OUTPUT</span>
|
||||
00090 <span class="comment">// sort pop before printing it!</span>
|
||||
00091 pop.<a class="code" href="classeo_pop.html#a5">sort</a>();
|
||||
00092 <span class="comment">// Print (sorted) intial population (raw printout)</span>
|
||||
00093 cout << <span class="stringliteral">"Initial Population"</span> << endl;
|
||||
00094 cout << pop;
|
||||
00095
|
||||
00096 <span class="comment">// ENGINE</span>
|
||||
00098 <span class="comment"></span> <span class="comment">// selection and replacement</span>
|
||||
00100 <span class="comment"></span><span class="comment">// SELECT</span>
|
||||
00101 <span class="comment">// The robust tournament selection</span>
|
||||
00102 <a class="code" href="classeo_det_tournament_select.html">eoDetTournamentSelect<Indi></a> select(T_SIZE); <span class="comment">// T_SIZE in [2,POP_SIZE]</span>
|
||||
00103
|
||||
00104 <span class="comment">// REPLACE</span>
|
||||
00105 <span class="comment">// eoSGA uses generational replacement by default</span>
|
||||
00106 <span class="comment">// so no replacement procedure has to be given</span>
|
||||
00107
|
||||
00108 <span class="comment">// OPERATORS</span>
|
||||
00110 <span class="comment"></span> <span class="comment">// The variation operators</span>
|
||||
00112 <span class="comment"></span><span class="comment">// CROSSOVER</span>
|
||||
00113 <span class="comment">// offspring(i) is a linear combination of parent(i)</span>
|
||||
00114 <a class="code" href="classeo_segment_crossover.html">eoSegmentCrossover<Indi></a> xover;
|
||||
00115 <span class="comment">// MUTATION</span>
|
||||
00116 <span class="comment">// offspring(i) uniformly chosen in [parent(i)-epsilon, parent(i)+epsilon]</span>
|
||||
00117 <a class="code" href="classeo_uniform_mutation.html">eoUniformMutation<Indi></a> mutation(EPSILON);
|
||||
00118
|
||||
00119 <span class="comment">// STOP</span>
|
||||
00120 <span class="comment">// CHECKPOINT</span>
|
||||
00122 <span class="comment"></span> <span class="comment">// termination condition</span>
|
||||
00124 <span class="comment"></span> <span class="comment">// stop after MAX_GEN generations</span>
|
||||
00125 <a class="code" href="classeo_gen_continue.html">eoGenContinue<Indi></a> continuator(MAX_GEN);
|
||||
00126
|
||||
00127 <span class="comment">// GENERATION</span>
|
||||
00129 <span class="comment"></span> <span class="comment">// the algorithm</span>
|
||||
00131 <span class="comment"></span> <span class="comment">// standard Generational GA requires</span>
|
||||
00132 <span class="comment">// selection, evaluation, crossover and mutation, stopping criterion</span>
|
||||
00133
|
||||
00134
|
||||
00135 <a class="code" href="classeo_s_g_a.html">eoSGA<Indi></a> gga(select, xover, CROSS_RATE, mutation, MUT_RATE,
|
||||
00136 eval, continuator);
|
||||
00137
|
||||
00138 <span class="comment">// Apply algo to pop - that's it!</span>
|
||||
00139 gga(pop);
|
||||
00140
|
||||
00141 <span class="comment">// OUTPUT</span>
|
||||
00142 <span class="comment">// Print (sorted) intial population</span>
|
||||
00143 pop.<a class="code" href="classeo_pop.html#a5">sort</a>();
|
||||
00144 cout << <span class="stringliteral">"FINAL Population\n"</span> << pop << endl;
|
||||
00145 <span class="comment">// GENERAL</span>
|
||||
00146 }
|
||||
00147
|
||||
00148 <span class="comment">// A main that catches the exceptions</span>
|
||||
00149
|
||||
00150 <span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> **argv)
|
||||
00151 {
|
||||
00152 <span class="keywordflow">try</span>
|
||||
00153 {
|
||||
00154 main_function(argc, argv);
|
||||
00155 }
|
||||
00156 <span class="keywordflow">catch</span>(exception& e)
|
||||
00157 {
|
||||
00158 cout << <span class="stringliteral">"Exception: "</span> << e.what() << <span class="charliteral">'\n'</span>;
|
||||
00159 }
|
||||
00160
|
||||
00161 <span class="keywordflow">return</span> 1;
|
||||
00162 }
|
||||
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:39 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>
|
||||
905
trunk/paradiseo-eo/doc/html/_fun_def_8cpp-source.html
Normal file
|
|
@ -0,0 +1,905 @@
|
|||
<!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: FunDef.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_000007.html">contrib</a> / <a class="el" href="dir_000008.html">mathsym</a> / <a class="el" href="dir_000022.html">fun</a></div>
|
||||
<h1>FunDef.cpp</h1><div class="fragment"><pre class="fragment">00001 <span class="comment">/* </span>
|
||||
00002 <span class="comment"> * Copyright (C) 2005 Maarten Keijzer</span>
|
||||
00003 <span class="comment"> *</span>
|
||||
00004 <span class="comment"> * This program is free software; you can redistribute it and/or modify</span>
|
||||
00005 <span class="comment"> * it under the terms of version 2 of the GNU General Public License as </span>
|
||||
00006 <span class="comment"> * published by the Free Software Foundation. </span>
|
||||
00007 <span class="comment"> *</span>
|
||||
00008 <span class="comment"> * This program is distributed in the hope that it will be useful,</span>
|
||||
00009 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
|
||||
00010 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
|
||||
00011 <span class="comment"> * GNU General Public License for more details.</span>
|
||||
00012 <span class="comment"> *</span>
|
||||
00013 <span class="comment"> * You should have received a copy of the GNU General Public License</span>
|
||||
00014 <span class="comment"> * along with this program; if not, write to the Free Software</span>
|
||||
00015 <span class="comment"> * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>
|
||||
00016 <span class="comment"> */</span>
|
||||
00017
|
||||
00018
|
||||
00019 <span class="preprocessor">#include <sstream></span>
|
||||
00020 <span class="preprocessor">#include "Sym.h"</span>
|
||||
00021 <span class="preprocessor">#include "FunDef.h"</span>
|
||||
00022 <span class="preprocessor">#include <LanguageTable.h></span>
|
||||
00023
|
||||
00024 <span class="keyword">using</span> <span class="keyword">namespace </span>std;
|
||||
00025 <span class="keyword">using</span> <span class="keyword">namespace </span>boost::numeric;
|
||||
00026
|
||||
00027 vector<const FunDef*> language;
|
||||
00028
|
||||
00029 token_t add_function(FunDef* function) {
|
||||
00030 language.push_back(function);
|
||||
00031 <span class="keywordflow">return</span> token_t(language.size()-1);
|
||||
00032 }
|
||||
00033
|
||||
00034 <span class="keyword">const</span> FunDef& get_element(token_t token) { <span class="keywordflow">return</span> *language[token]; }
|
||||
00035
|
||||
00036 <span class="comment">/* Printing */</span>
|
||||
00037
|
||||
00038 string c_print(<span class="keyword">const</span> Sym& sym) {
|
||||
00039 <span class="keywordflow">return</span> c_print(sym, vector<string>());
|
||||
00040 }
|
||||
00041
|
||||
00042 string c_print(<span class="keyword">const</span> Sym& sym, <span class="keyword">const</span> vector<string>& vars) {
|
||||
00043 <span class="keyword">const</span> SymVec& args = sym.args();
|
||||
00044 vector<string> names(args.size());
|
||||
00045 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < args.size(); ++i) {
|
||||
00046 names[i] = c_print(args[i], vars);
|
||||
00047 }
|
||||
00048 <span class="keywordflow">return</span> language[sym.token()]->c_print(names, vars);
|
||||
00049 }
|
||||
00050
|
||||
00051 <span class="comment">/* Evaluation */</span>
|
||||
00052
|
||||
00053
|
||||
00054 <span class="keywordtype">double</span> eval(<span class="keyword">const</span> Sym& sym, <span class="keyword">const</span> std::vector<double>& inputs) {
|
||||
00055 <span class="keywordflow">return</span> language[sym.token()]->eval(sym.args(), inputs);
|
||||
00056 }
|
||||
00057
|
||||
00058
|
||||
00059 <span class="comment">/* Interval Logic */</span>
|
||||
00060 Interval eval(<span class="keyword">const</span> Sym& sym, <span class="keyword">const</span> vector<Interval>& inputs) {
|
||||
00061 <span class="keyword">const</span> SymVec& args = sym.args();
|
||||
00062 vector<Interval> interv(args.size());
|
||||
00063 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < args.size(); ++i) {
|
||||
00064 interv[i] = eval(args[i], inputs);
|
||||
00065
|
||||
00066 <span class="keywordflow">if</span> (!valid(interv[i])) <span class="keywordflow">throw</span> interval_error();
|
||||
00067 }
|
||||
00068 <span class="keywordflow">return</span> language[sym.token()]->eval(interv, inputs);
|
||||
00069 }
|
||||
00070
|
||||
00071 <span class="comment">/* */</span>
|
||||
00072 <span class="keywordtype">void</span> add_function_to_table(LanguageTable& table, token_t token) {
|
||||
00073 <span class="keyword">const</span> FunDef& fundef = *language[token];
|
||||
00074
|
||||
00075 <span class="keywordflow">if</span> (fundef.has_varargs() == <span class="keyword">false</span>) {
|
||||
00076 table.add_function(token, fundef.min_arity());
|
||||
00077 } <span class="keywordflow">else</span> { <span class="comment">// sum or prod (or min or max)</span>
|
||||
00078 table.add_function(token, 2);
|
||||
00079 }
|
||||
00080 }
|
||||
00081
|
||||
00082
|
||||
00083 <span class="comment">// by default it is eager</span>
|
||||
00084 <span class="keywordtype">double</span> FunDef::eval(<span class="keyword">const</span> SymVec& args, <span class="keyword">const</span> vector<double>& inputs)<span class="keyword"> const </span>{
|
||||
00085 vector<double> values(args.size());
|
||||
00086 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < args.size(); ++i) {
|
||||
00087 values[i] = ::eval(args[i], inputs);
|
||||
00088 }
|
||||
00089
|
||||
00090 <span class="keywordflow">return</span> eval(values, inputs);
|
||||
00091 }
|
||||
00092
|
||||
00093 <span class="comment">/* Variable Handling */</span>
|
||||
00094 FunDef* make_var(<span class="keywordtype">int</span> idx); <span class="comment">// defined in FunDefs.h</span>
|
||||
00095 <span class="keyword">static</span> vector<token_t> var_token;
|
||||
00096
|
||||
00097 Sym SymVar(<span class="keywordtype">unsigned</span> idx) {
|
||||
00098 <span class="keywordflow">if</span> (var_token.size() <= idx) {
|
||||
00099 <span class="comment">// it is new</span>
|
||||
00100 var_token.resize(idx+1, token_t(-1));
|
||||
00101 var_token[idx] = add_function( make_var(idx) );
|
||||
00102 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (var_token[idx] == token_t(-1)) {
|
||||
00103 var_token[idx] = add_function( make_var(idx) );
|
||||
00104 }
|
||||
00105 <span class="keywordflow">return</span> Sym(var_token[idx]);
|
||||
00106 }
|
||||
00107
|
||||
00108
|
||||
00109 <span class="comment">/* Constant Handling */</span>
|
||||
00110
|
||||
00111 <span class="keyword">struct </span>HashDouble{
|
||||
00112 size_t operator()(<span class="keywordtype">double</span> val)<span class="keyword"> const </span>{
|
||||
00113 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> h = 0;
|
||||
00114 <span class="keywordtype">char</span>* s = (<span class="keywordtype">char</span>*)&val;
|
||||
00115 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i=0 ; i<<span class="keyword">sizeof</span>(double); ++i)
|
||||
00116 h = 5*h + s[i];
|
||||
00117 <span class="keywordflow">return</span> size_t(h);
|
||||
00118 }
|
||||
00119 };
|
||||
00120
|
||||
00121 <span class="preprocessor">#if USE_TR1</span>
|
||||
00122 <span class="preprocessor"></span><span class="keyword">typedef</span> std::tr1::unordered_map<double, token_t> DoubleSet;
|
||||
00123 <span class="keyword">typedef</span> std::tr1::unordered_map<Sym, token_t> LambdaSet;
|
||||
00124 <span class="preprocessor">#else</span>
|
||||
00125 <span class="preprocessor"></span><span class="keyword">typedef</span> hash_map<double, token_t, HashDouble> DoubleSet;
|
||||
00126 <span class="keyword">typedef</span> hash_map<Sym, token_t, HashSym> LambdaSet;
|
||||
00127 <span class="preprocessor">#endif</span>
|
||||
00128 <span class="preprocessor"></span>
|
||||
00129 <span class="keyword">static</span> DoubleSet doubleSet; <span class="comment">// for quick checking if a constant already exists</span>
|
||||
00130 <span class="keyword">static</span> vector<double> token_value;
|
||||
00131
|
||||
00132 <span class="keyword">static</span> LambdaSet lambdaSet;
|
||||
00133 <span class="keyword">static</span> vector<Sym> token_lambda;
|
||||
00134
|
||||
00135 <span class="keyword">static</span> std::vector<token_t> free_list;
|
||||
00136
|
||||
00137 <span class="keywordtype">void</span> delete_val(token_t token) { <span class="comment">// clean up the information about this value</span>
|
||||
00138
|
||||
00139 <span class="keywordflow">if</span> (is_constant(token)) {
|
||||
00140 <span class="comment">//cout << "Deleting constant token " << token << endl;</span>
|
||||
00141 <span class="keywordtype">double</span> value = token_value[token];
|
||||
00142 doubleSet.erase(value);
|
||||
00143
|
||||
00144 <span class="keyword">delete</span> language[token];
|
||||
00145 language[token] = 0;
|
||||
00146 free_list.push_back(token);
|
||||
00147 }
|
||||
00148 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (is_lambda(token)) {
|
||||
00149 <span class="comment">//cout << "Deleting lambda token " << token << endl;</span>
|
||||
00150
|
||||
00151 Sym expression = token_lambda[token];
|
||||
00152 lambdaSet.erase(expression);
|
||||
00153
|
||||
00154 <span class="keyword">delete</span> language[token];
|
||||
00155 language[token] = 0;
|
||||
00156 free_list.push_back(token);
|
||||
00157 }
|
||||
00158 }
|
||||
00159
|
||||
00160
|
||||
00161 FunDef* make_const(<span class="keywordtype">double</span> value);
|
||||
00162
|
||||
00163 <span class="keywordtype">void</span> extend_free_list();
|
||||
00164
|
||||
00165 Sym SymConst(<span class="keywordtype">double</span> value) {
|
||||
00166
|
||||
00167 DoubleSet::iterator it = doubleSet.find(value);
|
||||
00168
|
||||
00169 <span class="keywordflow">if</span> (it != doubleSet.end()) {
|
||||
00170 <span class="keywordflow">return</span> Sym(it->second); <span class="comment">// already exists</span>
|
||||
00171 }
|
||||
00172
|
||||
00173
|
||||
00174 <span class="keywordflow">if</span> (free_list.empty()) { <span class="comment">// make space for tokens;</span>
|
||||
00175 extend_free_list();
|
||||
00176 }
|
||||
00177
|
||||
00178 token_t token = free_list.back();
|
||||
00179 free_list.pop_back();
|
||||
00180 <span class="comment">//cout << "Creating constant with token " << token << endl; </span>
|
||||
00181 assert(language[token] == 0);
|
||||
00182
|
||||
00183 language[token] = make_const(value);
|
||||
00184
|
||||
00185 doubleSet[value] = token;
|
||||
00186 <span class="keywordflow">if</span> (token_value.size() < token) token_value.resize(token+1);
|
||||
00187 token_value[token] = value;
|
||||
00188
|
||||
00189 <span class="keywordflow">return</span> Sym(token);
|
||||
00190 }
|
||||
00191
|
||||
00192 <span class="comment">/* LanguageTable depends on this one, XXX move somewhere safe.*/</span>
|
||||
00193 <span class="preprocessor">#include <utils/eoRNG.h></span>
|
||||
00194 <span class="keyword">extern</span> Sym default_const() { <span class="keywordflow">return</span> SymConst(rng.<a class="code" href="classeo_rng.html#a7">normal</a>()); }
|
||||
00195
|
||||
00196 <span class="comment">/* The functions */</span>
|
||||
00197 <span class="keyword">namespace </span>{
|
||||
00198
|
||||
00199 <span class="keyword">class </span>Var : <span class="keyword">public</span> FunDef {
|
||||
00200 <span class="keyword">public</span> :
|
||||
00201 <span class="keywordtype">unsigned</span> idx;
|
||||
00202 string default_str;
|
||||
00203
|
||||
00204 Var(<span class="keywordtype">unsigned</span> _idx) : idx(_idx) {
|
||||
00205 ostringstream os;
|
||||
00206 os << <span class="stringliteral">"x["</span> << idx << <span class="charliteral">']'</span>; <span class="comment">// CompiledCode expects this form</span>
|
||||
00207 default_str = os.str();
|
||||
00208 }
|
||||
00209
|
||||
00210 <span class="keywordtype">double</span> eval(<span class="keyword">const</span> vector<double>& _, <span class="keyword">const</span> vector<double>& inputs)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> inputs[idx]; }
|
||||
00211 <span class="keywordtype">double</span> eval(<span class="keyword">const</span> SymVec& _, <span class="keyword">const</span> vector<double>& inputs)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> inputs[idx]; }
|
||||
00212 string c_print(<span class="keyword">const</span> vector<string>& _, <span class="keyword">const</span> vector<string>& names)<span class="keyword"> const </span>{
|
||||
00213 <span class="keywordflow">if</span> (names.empty()) {
|
||||
00214 <span class="keywordflow">return</span> default_str;
|
||||
00215 }
|
||||
00216 <span class="keywordflow">return</span> names[idx];
|
||||
00217 }
|
||||
00218
|
||||
00219 Interval eval(<span class="keyword">const</span> vector<Interval>& _, <span class="keyword">const</span> vector<Interval>& inputs)<span class="keyword"> const </span>{
|
||||
00220 <span class="keywordflow">return</span> inputs[idx];
|
||||
00221 }
|
||||
00222
|
||||
00223 <span class="keywordtype">unsigned</span> min_arity()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> 0; }
|
||||
00224
|
||||
00225 string name()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <span class="stringliteral">"var"</span>; }
|
||||
00226
|
||||
00227 };
|
||||
00228
|
||||
00229 <span class="keyword">class </span>Const : <span class="keyword">public</span> FunDef {
|
||||
00230 <span class="keyword">public</span>:
|
||||
00231 <span class="keywordtype">double</span> value;
|
||||
00232 string value_str;
|
||||
00233
|
||||
00234 Const(<span class="keywordtype">double</span> _value) : value(_value) {
|
||||
00235 ostringstream os;
|
||||
00236 os.precision(17);
|
||||
00237 os.setf(ios::showpoint);
|
||||
00238 os << <span class="charliteral">'('</span> << value << <span class="charliteral">')'</span>;
|
||||
00239 value_str = os.str();
|
||||
00240 }
|
||||
00241
|
||||
00242
|
||||
00243 <span class="keywordtype">double</span> eval(<span class="keyword">const</span> vector<double>& _, <span class="keyword">const</span> vector<double>& inputs)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> value; }
|
||||
00244 <span class="keywordtype">double</span> eval(<span class="keyword">const</span> SymVec& _, <span class="keyword">const</span> vector<double>& inputs)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> value; }
|
||||
00245 string c_print(<span class="keyword">const</span> vector<string>& _, <span class="keyword">const</span> vector<string>& names)<span class="keyword"> const </span>{
|
||||
00246 <span class="keywordflow">return</span> value_str;
|
||||
00247 }
|
||||
00248
|
||||
00249 Interval eval(<span class="keyword">const</span> vector<Interval>& _, <span class="keyword">const</span> vector<Interval>& inputs)<span class="keyword"> const </span>{
|
||||
00250 <span class="comment">// Profil/Bias seems to have a problem with 0 * inf when the Interval is exact zero (fpe)</span>
|
||||
00251 <span class="comment">//if (value == 0.0) return Interval(-BiasEpsilon,BiasEpsilon);</span>
|
||||
00252 <span class="keywordflow">return</span> Interval(value);
|
||||
00253 }
|
||||
00254
|
||||
00255 <span class="keywordtype">unsigned</span> min_arity()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> 0; }
|
||||
00256
|
||||
00257 string name()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <span class="stringliteral">"parameter"</span>; }
|
||||
00258 };
|
||||
00259
|
||||
00260 } <span class="comment">// namespace </span>
|
||||
00261
|
||||
00262 <span class="keywordtype">void</span> get_constants(Sym sym, vector<double>& ret) {
|
||||
00263 token_t token = sym.token();
|
||||
00264 <span class="keywordflow">if</span> (is_constant(token)) {
|
||||
00265 <span class="keywordtype">double</span> val = static_cast<const Const*>(language[token])->value;
|
||||
00266 ret.push_back(val);
|
||||
00267 }
|
||||
00268
|
||||
00269 <span class="keyword">const</span> SymVec& args = sym.args();
|
||||
00270 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < args.size(); ++i) {
|
||||
00271 get_constants(args[i], ret);
|
||||
00272 }
|
||||
00273
|
||||
00274 }
|
||||
00275
|
||||
00276 <span class="keywordtype">double</span> get_constant_value(token_t token) {
|
||||
00277 <span class="keywordflow">return</span> static_cast<const Const*>(language[token])->value;
|
||||
00278 }
|
||||
00279
|
||||
00281 vector<double> get_constants(Sym sym) {
|
||||
00282 vector<double> retval;
|
||||
00283 get_constants(sym, retval);
|
||||
00284 <span class="keywordflow">return</span> retval;
|
||||
00285 }
|
||||
00286
|
||||
00289 Sym set_constants(Sym sym, vector<double>::const_iterator& it) {
|
||||
00290
|
||||
00291 token_t token = sym.token();
|
||||
00292 <span class="keywordflow">if</span> (is_constant(token)) {
|
||||
00293 <span class="keywordflow">return</span> SymConst(*it++);
|
||||
00294 }
|
||||
00295
|
||||
00296 SymVec args = sym.args();
|
||||
00297 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < args.size(); ++i) {
|
||||
00298 args[i] = set_constants(args[i], it);
|
||||
00299 }
|
||||
00300
|
||||
00301 <span class="keywordflow">return</span> Sym(token, args);
|
||||
00302 }
|
||||
00303
|
||||
00304 Sym set_constants(Sym sym, <span class="keyword">const</span> vector<double>& constants) {
|
||||
00305 vector<double>::const_iterator it = constants.begin();
|
||||
00306 <span class="keywordflow">return</span> set_constants(sym, it);
|
||||
00307 }
|
||||
00308
|
||||
00309 <span class="comment">// Get functions out, excluding Const and Var</span>
|
||||
00310 vector<const FunDef*> get_defined_functions() {
|
||||
00311 vector<const FunDef*> res;
|
||||
00312 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < language.size(); ++i) {
|
||||
00313 res.push_back(language[i]);
|
||||
00314
|
||||
00315 <span class="keywordflow">if</span> (is_constant(i) || is_variable(i)) {
|
||||
00316 res.back() = 0; <span class="comment">// erase</span>
|
||||
00317 }
|
||||
00318 }
|
||||
00319
|
||||
00320 <span class="keywordflow">return</span> res;
|
||||
00321 }
|
||||
00322
|
||||
00323 FunDef* make_var(<span class="keywordtype">int</span> idx) { <span class="keywordflow">return</span> <span class="keyword">new</span> Var(idx); }
|
||||
00324 FunDef* make_const(<span class="keywordtype">double</span> value) { <span class="keywordflow">return</span> <span class="keyword">new</span> Const(value); }
|
||||
00325
|
||||
00326 <span class="keywordtype">bool</span> is_constant(token_t token) {
|
||||
00327 <span class="keyword">const</span> Const* cnst = dynamic_cast<const Const*>( language[token] );
|
||||
00328 <span class="keywordflow">return</span> cnst != 0;
|
||||
00329 }
|
||||
00330
|
||||
00331 <span class="keywordtype">bool</span> is_variable(token_t token) {
|
||||
00332 <span class="keyword">const</span> Var* var = dynamic_cast<const Var*>( language[token] );
|
||||
00333 <span class="keywordflow">return</span> var != 0;
|
||||
00334 }
|
||||
00335
|
||||
00336 <span class="keywordtype">unsigned</span> get_variable_index(token_t token) {
|
||||
00337 <span class="keyword">const</span> Var* var = static_cast<const Var*>( language[token] );
|
||||
00338 <span class="keywordflow">return</span> var->idx;
|
||||
00339 }
|
||||
00340
|
||||
00341 <span class="keyword">namespace </span>{
|
||||
00342 <span class="keyword">class </span>Lambda : <span class="keyword">public</span> FunDef {
|
||||
00343 <span class="keyword">public</span>:
|
||||
00344 Sym expression;
|
||||
00345 <span class="keywordtype">int</span> arity;
|
||||
00346
|
||||
00347 Lambda(Sym expr, <span class="keywordtype">int</span> arity_) : expression(expr), arity(arity_) {}
|
||||
00348
|
||||
00349 <span class="keywordtype">double</span> eval(<span class="keyword">const</span> vector<double>& vals, <span class="keyword">const</span> vector<double>& _)<span class="keyword"> const </span>{
|
||||
00350 return ::eval(expression, vals);
|
||||
00351 }
|
||||
00352
|
||||
00353 string c_print(<span class="keyword">const</span> vector<string>& args, <span class="keyword">const</span> vector<string>& _)<span class="keyword"> const </span>{
|
||||
00354 <span class="keywordflow">return</span> string(<span class="stringliteral">"/*f*/"</span>) + ::c_print(expression, args) + string(<span class="stringliteral">"/*eof*/"</span>);
|
||||
00355 }
|
||||
00356
|
||||
00357 Interval eval(<span class="keyword">const</span> vector<Interval>& args, <span class="keyword">const</span> vector<Interval>& _)<span class="keyword"> const </span>{
|
||||
00358 return ::eval(expression, args);
|
||||
00359 }
|
||||
00360
|
||||
00361 <span class="keywordtype">unsigned</span> min_arity()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> arity; }
|
||||
00362 string name()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <span class="stringliteral">"F"</span>; }
|
||||
00363
|
||||
00364 };
|
||||
00365 Sym normalize(Sym sym, SymVec& args) {
|
||||
00366 <span class="comment">// check if it's a variable</span>
|
||||
00367 token_t token = sym.token();
|
||||
00368 <span class="keyword">const</span> Var* var = dynamic_cast< const Var*>(language[token]);
|
||||
00369
|
||||
00370 <span class="keywordflow">if</span> (var != 0) {
|
||||
00371 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < args.size(); ++i) {
|
||||
00372 <span class="keywordflow">if</span> (sym == args[i]) {
|
||||
00373 <span class="keywordflow">return</span> SymVar(i); <span class="comment">// replace with reference to arg</span>
|
||||
00374 }
|
||||
00375 }
|
||||
00376
|
||||
00377 <span class="comment">// not replaced, add it</span>
|
||||
00378 args.push_back(sym);
|
||||
00379 <span class="keywordflow">return</span> SymVar(args.size()-1);
|
||||
00380
|
||||
00381 }
|
||||
00382
|
||||
00383 SymVec a = sym.args();
|
||||
00384 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < a.size(); ++i) {
|
||||
00385 a[i] = normalize(a[i], args);
|
||||
00386 }
|
||||
00387
|
||||
00388 <span class="keywordflow">return</span> Sym(token, a);
|
||||
00389 }
|
||||
00390 }
|
||||
00391
|
||||
00392 <span class="keywordtype">bool</span> is_lambda(token_t token) {
|
||||
00393 <span class="keyword">const</span> Lambda* lambda = dynamic_cast<const Lambda*>( language[token]);
|
||||
00394 <span class="keywordflow">return</span> lambda != 0;
|
||||
00395 }
|
||||
00396
|
||||
00397 std::ostream& print_list(Sym sym, ostream& os) {
|
||||
00398 os << sym.token() << <span class="charliteral">' '</span>;
|
||||
00399
|
||||
00400 <span class="keyword">const</span> SymVec& args = sym.args();
|
||||
00401 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < args.size(); ++i) {
|
||||
00402 print_list(args[i], os);
|
||||
00403 }
|
||||
00404 <span class="keywordflow">return</span> os;
|
||||
00405 }
|
||||
00406
|
||||
00407 token_t new_lambda(Sym sym, <span class="keywordtype">int</span> arity) {
|
||||
00408 <span class="comment">// check if already present</span>
|
||||
00409
|
||||
00410 LambdaSet::iterator it = lambdaSet.find(sym);
|
||||
00411 <span class="keywordflow">if</span> (it != lambdaSet.end()) {
|
||||
00412 <span class="keywordflow">return</span> it->second;
|
||||
00413 }
|
||||
00414
|
||||
00415
|
||||
00416 <span class="comment">// new, insert</span>
|
||||
00417 Lambda* lambda = <span class="keyword">new</span> Lambda(sym, arity);
|
||||
00418
|
||||
00419 <span class="keywordflow">if</span> (free_list.empty()) {
|
||||
00420 extend_free_list();
|
||||
00421 }
|
||||
00422
|
||||
00423 token_t token = free_list.back();
|
||||
00424 free_list.pop_back();
|
||||
00425 language[token] = lambda;
|
||||
00426
|
||||
00427 lambdaSet[sym] = token;
|
||||
00428 <span class="keywordflow">if</span> (token_lambda.size() <= token) token_lambda.resize(token+1);
|
||||
00429 token_lambda[token] = sym;
|
||||
00430
|
||||
00431 <span class="keywordflow">return</span> token;
|
||||
00432 }
|
||||
00433
|
||||
00434 <span class="comment">/* Compression */</span>
|
||||
00435 <span class="keyword">typedef</span> hash_map<Sym, unsigned, HashSym> OccMap;
|
||||
00436
|
||||
00437 <span class="keywordtype">void</span> count_occurances(Sym sym, OccMap& occ) {
|
||||
00438 occ[sym]++;
|
||||
00439 <span class="keyword">const</span> SymVec& args = sym.args();
|
||||
00440 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < args.size(); ++i) {
|
||||
00441 count_occurances(args[i], occ);
|
||||
00442 }
|
||||
00443 }
|
||||
00444
|
||||
00445 Sym create_lambda(Sym sym, OccMap& occ, <span class="keywordtype">unsigned</span> nvars, vector<Sym>& args) {
|
||||
00446 <span class="keywordtype">unsigned</span> o = occ[sym];
|
||||
00447 <span class="keywordtype">unsigned</span> sz = sym.size();
|
||||
00448
|
||||
00449 <span class="keywordflow">if</span> (o * sz > o + sz + nvars || is_variable(sym.token()) ) {
|
||||
00450 <span class="comment">// check if it's already present</span>
|
||||
00451 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < args.size(); ++i) {
|
||||
00452 <span class="keywordflow">if</span> (args[i] == sym) {
|
||||
00453 <span class="keywordflow">return</span> SymVar(i);
|
||||
00454 }
|
||||
00455 }
|
||||
00456 <span class="comment">// push_back</span>
|
||||
00457 args.push_back(sym);
|
||||
00458 <span class="keywordflow">return</span> SymVar(args.size()-1);
|
||||
00459 }
|
||||
00460
|
||||
00461 SymVec sym_args = sym.args();
|
||||
00462 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < sym_args.size(); ++i) {
|
||||
00463 sym_args[i] = create_lambda(sym_args[i], occ, nvars, args);
|
||||
00464 }
|
||||
00465
|
||||
00466 <span class="keywordflow">return</span> Sym(sym.token(), sym_args);
|
||||
00467
|
||||
00468 }
|
||||
00469
|
||||
00470 Sym compress(Sym sym) {
|
||||
00471 OccMap occ(sym.size());
|
||||
00472 count_occurances(sym, occ);
|
||||
00473
|
||||
00474 <span class="keywordtype">unsigned</span> nvars = 0;
|
||||
00475 <span class="keywordflow">for</span> (OccMap::iterator it = occ.begin(); it != occ.end(); ++it) {
|
||||
00476 <span class="keywordflow">if</span> (is_variable(it->first.token())) nvars++;
|
||||
00477 }
|
||||
00478
|
||||
00479 SymVec args;
|
||||
00480 Sym body = create_lambda(sym, occ, nvars, args);
|
||||
00481
|
||||
00482
|
||||
00483 <span class="keywordflow">if</span> (body.size() < sym.size()) {
|
||||
00484 <span class="comment">// see if the body can be compressed some more</span>
|
||||
00485 body = compress(body);
|
||||
00486
|
||||
00487 token_t token = new_lambda(body, args.size());
|
||||
00488
|
||||
00489 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < args.size(); ++i) {
|
||||
00490 args[i] = compress(args[i]);
|
||||
00491 }
|
||||
00492
|
||||
00493 Sym result = Sym(token, args);
|
||||
00494 <span class="keywordflow">return</span> compress(result); <span class="comment">// see if it can be compressed some more</span>
|
||||
00495 }
|
||||
00496
|
||||
00497 <span class="keywordflow">return</span> sym;
|
||||
00498 }
|
||||
00499
|
||||
00500 Sym SymLambda(Sym expr) { <span class="keywordflow">return</span> compress(expr); }
|
||||
00501
|
||||
00502 Sym expand(Sym expr, <span class="keyword">const</span> SymVec& args) {
|
||||
00503
|
||||
00504 <span class="keyword">const</span> Var* var = dynamic_cast<const Var*>( language[expr.token()] );
|
||||
00505 <span class="keywordflow">if</span> (var != 0) {
|
||||
00506 <span class="keywordflow">return</span> args[var->idx];
|
||||
00507 }
|
||||
00508
|
||||
00509 SymVec expr_args = expr.args();
|
||||
00510 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < expr_args.size(); ++i) {
|
||||
00511 expr_args[i] = expand(expr_args[i], args);
|
||||
00512 }
|
||||
00513
|
||||
00514 <span class="keywordflow">return</span> Sym(expr.token(), expr_args);
|
||||
00515 }
|
||||
00516
|
||||
00517 Sym SymUnlambda(Sym sym) {
|
||||
00518 Sym retval = sym;
|
||||
00519 <span class="keyword">const</span> Lambda* lambda = dynamic_cast<const Lambda*>( language[sym.token()] );
|
||||
00520 <span class="keywordflow">if</span> (lambda != 0) {
|
||||
00521 retval = expand(lambda->expression, sym.args());
|
||||
00522 }
|
||||
00523
|
||||
00524 <span class="keywordflow">return</span> retval;
|
||||
00525 }
|
||||
00526
|
||||
00527 Sym expand_all(Sym sym) {
|
||||
00528 SymVec args = sym.args();
|
||||
00529 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < args.size(); ++i) {
|
||||
00530 args[i] = expand_all(args[i]);
|
||||
00531 }
|
||||
00532
|
||||
00533 Sym nw = SymUnlambda( Sym(sym.token(), args) );
|
||||
00534
|
||||
00535 <span class="keywordflow">if</span> (nw != sym) {
|
||||
00536 nw = expand_all(nw);
|
||||
00537 }
|
||||
00538
|
||||
00539 <span class="keywordflow">return</span> nw;
|
||||
00540 }
|
||||
00541
|
||||
00542 <span class="keyword">namespace </span>{
|
||||
00543
|
||||
00544 <span class="keyword">class </span>Sum : <span class="keyword">public</span> FunDef {
|
||||
00545
|
||||
00546 <span class="keyword">public</span> :
|
||||
00547
|
||||
00548 <span class="keywordtype">double</span> eval(<span class="keyword">const</span> vector<double>& vals, <span class="keyword">const</span> vector<double>& _)<span class="keyword"> const </span>{
|
||||
00549 <span class="keywordtype">double</span> res = 0;
|
||||
00550 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < vals.size(); ++i) res += vals[i];
|
||||
00551 <span class="keywordflow">return</span> res;
|
||||
00552 }
|
||||
00553
|
||||
00554 string c_print(<span class="keyword">const</span> vector<string>& args, <span class="keyword">const</span> vector<string>& _)<span class="keyword"> const </span>{
|
||||
00555 <span class="keywordflow">if</span> (args.empty()) { <span class="keywordflow">return</span> <span class="stringliteral">"0.0"</span>; }
|
||||
00556
|
||||
00557 ostringstream os;
|
||||
00558 os << <span class="stringliteral">"("</span> << args[0];
|
||||
00559 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 1; i < args.size(); ++i) {
|
||||
00560 os << <span class="stringliteral">"+"</span> << args[i];
|
||||
00561 }
|
||||
00562 os << <span class="stringliteral">")"</span>;
|
||||
00563 <span class="keywordflow">return</span> os.str();
|
||||
00564 }
|
||||
00565
|
||||
00566 Interval eval(<span class="keyword">const</span> vector<Interval>& args, <span class="keyword">const</span> vector<Interval>& inputs)<span class="keyword"> const </span>{
|
||||
00567 Interval interv(0.0);
|
||||
00568 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < args.size(); ++i) {
|
||||
00569 interv += args[i];
|
||||
00570 }
|
||||
00571 <span class="keywordflow">return</span> interv;
|
||||
00572 }
|
||||
00573
|
||||
00574 <span class="keywordtype">unsigned</span> min_arity()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> 0; }
|
||||
00575 <span class="keywordtype">bool</span> has_varargs()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <span class="keyword">true</span>; }
|
||||
00576
|
||||
00577 string name()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <span class="stringliteral">"sum"</span>; }
|
||||
00578 };
|
||||
00579
|
||||
00580
|
||||
00581 <span class="keyword">class </span>Prod : <span class="keyword">public</span> FunDef {
|
||||
00582
|
||||
00583 <span class="keyword">public</span> :
|
||||
00584
|
||||
00585 <span class="keywordtype">double</span> eval(<span class="keyword">const</span> vector<double>& vals, <span class="keyword">const</span> vector<double>& _)<span class="keyword"> const </span>{
|
||||
00586 <span class="keywordtype">double</span> res = 1;
|
||||
00587 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < vals.size(); ++i) res *= vals[i];
|
||||
00588 <span class="keywordflow">return</span> res;
|
||||
00589 }
|
||||
00590
|
||||
00591 string c_print(<span class="keyword">const</span> vector<string>& args, <span class="keyword">const</span> vector<string>& _)<span class="keyword"> const </span>{
|
||||
00592 <span class="keywordflow">if</span> (args.empty()) { <span class="keywordflow">return</span> <span class="stringliteral">"1.0"</span>; }
|
||||
00593
|
||||
00594 ostringstream os;
|
||||
00595 os << <span class="stringliteral">"("</span> << args[0];
|
||||
00596 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 1; i < args.size(); ++i) {
|
||||
00597 os << <span class="stringliteral">"*"</span> << args[i];
|
||||
00598 }
|
||||
00599 os << <span class="stringliteral">")"</span>;
|
||||
00600
|
||||
00601 <span class="keywordflow">return</span> os.str();
|
||||
00602 }
|
||||
00603
|
||||
00604 Interval eval(<span class="keyword">const</span> vector<Interval>& args, <span class="keyword">const</span> vector<Interval>& inputs)<span class="keyword"> const </span>{
|
||||
00605 Interval interv(1.0);
|
||||
00606 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < args.size(); ++i) {
|
||||
00607 interv *= args[i];
|
||||
00608 }
|
||||
00609 <span class="keywordflow">return</span> interv;
|
||||
00610 }
|
||||
00611
|
||||
00612 <span class="keywordtype">unsigned</span> min_arity()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> 0; }
|
||||
00613 <span class="keywordtype">bool</span> has_varargs()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <span class="keyword">true</span>; }
|
||||
00614
|
||||
00615 string name()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <span class="stringliteral">"prod"</span>; }
|
||||
00616 };
|
||||
00617
|
||||
00618
|
||||
00619 <span class="keyword">class </span>Power : <span class="keyword">public</span> FunDef {
|
||||
00620 <span class="keyword">public</span> :
|
||||
00621 <span class="keywordtype">double</span> eval(<span class="keyword">const</span> vector<double>& vals, <span class="keyword">const</span> vector<double>& _)<span class="keyword"> const </span>{
|
||||
00622 <span class="keywordflow">return</span> pow(vals[0], vals[1]);
|
||||
00623 }
|
||||
00624
|
||||
00625 string c_print(<span class="keyword">const</span> vector<string>& args, <span class="keyword">const</span> vector<string>& _)<span class="keyword"> const </span>{
|
||||
00626 <span class="keywordflow">return</span> <span class="stringliteral">"pow("</span> + args[0] + <span class="charliteral">','</span> + args[1] + <span class="charliteral">')'</span>;
|
||||
00627 }
|
||||
00628
|
||||
00629 Interval eval(<span class="keyword">const</span> vector<Interval>& args, <span class="keyword">const</span> vector<Interval>& _)<span class="keyword"> const </span>{
|
||||
00630 Interval first = args[0];
|
||||
00631 Interval second = args[1];
|
||||
00632 Interval lg = log(first);
|
||||
00633 <span class="keywordflow">if</span> (!valid(lg)) <span class="keywordflow">throw</span> interval_error();
|
||||
00634 <span class="keywordflow">return</span> exp(second * lg);
|
||||
00635 }
|
||||
00636
|
||||
00637 <span class="keywordtype">unsigned</span> min_arity()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> 2; }
|
||||
00638
|
||||
00639 string name()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <span class="stringliteral">"pow"</span>; }
|
||||
00640 };
|
||||
00641
|
||||
00642 <span class="keyword">class </span>IsNeg : <span class="keyword">public</span> FunDef {
|
||||
00643
|
||||
00644 <span class="keyword">public</span>:
|
||||
00645 <span class="keywordtype">double</span> eval(<span class="keyword">const</span> vector<double>& vals, <span class="keyword">const</span> vector<double>& _)<span class="keyword"> const </span>{
|
||||
00646 <span class="keywordflow">if</span> (vals[0] < 0.0) <span class="keywordflow">return</span> vals[1];
|
||||
00647 <span class="keywordflow">return</span> vals[2];
|
||||
00648 }
|
||||
00649
|
||||
00650 <span class="keywordtype">double</span> eval(<span class="keyword">const</span> Sym& sym, <span class="keyword">const</span> vector<double>& inputs)<span class="keyword"> const </span>{
|
||||
00651 <span class="keyword">const</span> SymVec& args = sym.args();
|
||||
00652 <span class="keywordtype">double</span> arg0 = ::eval(args[0], inputs);
|
||||
00653 <span class="keywordflow">if</span> (arg0 < 0.0) {
|
||||
00654 return ::eval(args[1], inputs);
|
||||
00655 }
|
||||
00656 return ::eval(args[2], inputs);
|
||||
00657 }
|
||||
00658
|
||||
00659 string c_print(<span class="keyword">const</span> vector<string>& args, <span class="keyword">const</span> vector<string>& _)<span class="keyword"> const </span>{
|
||||
00660 <span class="keywordflow">return</span> <span class="stringliteral">"(("</span> + args[0] + <span class="stringliteral">"<0.0)?"</span> + args[1] + <span class="stringliteral">":"</span> + args[2]+<span class="stringliteral">")"</span>;
|
||||
00661 }
|
||||
00662
|
||||
00663 Interval eval(<span class="keyword">const</span> vector<Interval>& args, <span class="keyword">const</span> vector<Interval>& _)<span class="keyword"> const </span>{
|
||||
00664 Interval a0 = args[0];
|
||||
00665 <span class="keywordflow">if</span> (a0.upper() < 0.0) <span class="keywordflow">return</span> args[1];
|
||||
00666 <span class="keywordflow">if</span> (a0.lower() >= 0.0) <span class="keywordflow">return</span> args[2];
|
||||
00667
|
||||
00668 <span class="keywordflow">return</span> Interval( std::min(args[1].lower(), args[2].lower()), std::max(args[1].upper(), args[2].upper()));
|
||||
00669 }
|
||||
00670
|
||||
00671 <span class="keywordtype">unsigned</span> min_arity()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> 3; }
|
||||
00672
|
||||
00673 string name()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <span class="stringliteral">"ifltz"</span>; }
|
||||
00674 };
|
||||
00675
|
||||
00676 <span class="keyword">template</span> <<span class="keyword">typename</span> Func>
|
||||
00677 <span class="keyword">class </span>Unary : <span class="keyword">public</span> FunDef {
|
||||
00678
|
||||
00679 Func un;
|
||||
00680
|
||||
00681 <span class="keywordtype">double</span> eval(<span class="keyword">const</span> vector<double>& vals, <span class="keyword">const</span> vector<double>& _)<span class="keyword"> const </span>{
|
||||
00682 <span class="keywordflow">return</span> un(vals[0]);
|
||||
00683 }
|
||||
00684
|
||||
00685 string c_print(<span class="keyword">const</span> vector<string>& args, <span class="keyword">const</span> vector<string>& _)<span class="keyword"> const </span>{
|
||||
00686 <span class="keywordflow">return</span> un(args[0]);
|
||||
00687 }
|
||||
00688
|
||||
00689 Interval eval(<span class="keyword">const</span> vector<Interval>& args, <span class="keyword">const</span> vector<Interval>& _)<span class="keyword"> const </span>{
|
||||
00690 <span class="keywordflow">return</span> un(args[0]);
|
||||
00691 }
|
||||
00692
|
||||
00693 <span class="keywordtype">unsigned</span> min_arity()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> 1; }
|
||||
00694
|
||||
00695 string name()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> un.name(); }
|
||||
00696
|
||||
00697 };
|
||||
00698
|
||||
00699 <span class="keyword">struct </span>Inv {
|
||||
00700 <span class="keywordtype">double</span> operator()(<span class="keywordtype">double</span> val)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> 1.0 / val; }
|
||||
00701 string operator()(string v)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <span class="stringliteral">"(1./"</span> + v + <span class="stringliteral">")"</span>; }
|
||||
00702 Interval operator()(Interval v)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> 1.0 / v; }
|
||||
00703
|
||||
00704 string name()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <span class="stringliteral">"inv"</span>; }
|
||||
00705 };
|
||||
00706
|
||||
00707 <span class="keyword">struct </span>Min {
|
||||
00708 <span class="keywordtype">double</span> operator()(<span class="keywordtype">double</span> val)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> -val; }
|
||||
00709 string operator()(string v)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <span class="stringliteral">"(-"</span> + v + <span class="stringliteral">")"</span>; }
|
||||
00710 Interval operator()(Interval v)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> -v; }
|
||||
00711
|
||||
00712 string name()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <span class="stringliteral">"min"</span>; }
|
||||
00713 };
|
||||
00714
|
||||
00715 } <span class="comment">// namespace</span>
|
||||
00716
|
||||
00717 string prototypes = <span class="stringliteral">"double pow(double, double);"</span>;
|
||||
00718 string get_prototypes() { <span class="keywordflow">return</span> prototypes; }
|
||||
00719 <span class="keywordtype">unsigned</span> add_prototype(string str) { prototypes += string(<span class="stringliteral">"double "</span>) + str + <span class="stringliteral">"(double);"</span>; <span class="keywordflow">return</span> prototypes.size(); }
|
||||
00720
|
||||
00721 token_t add_function(FunDef* function, token_t where) {
|
||||
00722 <span class="keywordflow">if</span> (language.size() <= where) language.resize(where+1);
|
||||
00723 language[where] = function;
|
||||
00724 <span class="keywordflow">return</span> 0;
|
||||
00725 }
|
||||
00726
|
||||
00727 <span class="keyword">namespace </span>{
|
||||
00728
|
||||
00729 <span class="preprocessor">#define FUNCDEF(funcname) struct funcname##_struct { \</span>
|
||||
00730 <span class="preprocessor"> double operator()(double val) const { return funcname(val); }\</span>
|
||||
00731 <span class="preprocessor"> string operator()(string val) const { return string(#funcname) + '(' + val + ')'; }\</span>
|
||||
00732 <span class="preprocessor"> Interval operator()(Interval val) const { return funcname(val); }\</span>
|
||||
00733 <span class="preprocessor"> string name() const { return string(#funcname); }\</span>
|
||||
00734 <span class="preprocessor">};\</span>
|
||||
00735 <span class="preprocessor">static const token_t funcname##_token_static = add_function( new Unary<funcname##_struct>, funcname##_token);\</span>
|
||||
00736 <span class="preprocessor">unsigned funcname##_size = add_prototype(#funcname);</span>
|
||||
00737 <span class="preprocessor"></span>
|
||||
00738 <span class="keyword">static</span> token_t ssum_token = add_function( <span class="keyword">new</span> Sum , sum_token);
|
||||
00739 <span class="keyword">static</span> token_t sprod_token = add_function( <span class="keyword">new</span> Prod, prod_token);
|
||||
00740 <span class="keyword">static</span> token_t sinv_token = add_function( <span class="keyword">new</span> Unary<Inv>, inv_token);
|
||||
00741 <span class="keyword">static</span> token_t smin_token = add_function( <span class="keyword">new</span> Unary<Min>, min_token);
|
||||
00742 <span class="keyword">static</span> token_t spow_token = add_function( <span class="keyword">new</span> Power, pow_token);
|
||||
00743 <span class="keyword">static</span> token_t sifltz_token = add_function( <span class="keyword">new</span> IsNeg, ifltz_token);
|
||||
00744
|
||||
00745 FUNCDEF(sin);
|
||||
00746 FUNCDEF(cos);
|
||||
00747 FUNCDEF(tan);
|
||||
00748 FUNCDEF(asin);
|
||||
00749 FUNCDEF(acos);
|
||||
00750 FUNCDEF(atan);
|
||||
00751
|
||||
00752 FUNCDEF(sinh);
|
||||
00753 FUNCDEF(cosh);
|
||||
00754 FUNCDEF(tanh);
|
||||
00755 FUNCDEF(asinh);
|
||||
00756 FUNCDEF(acosh);
|
||||
00757 FUNCDEF(atanh);
|
||||
00758
|
||||
00759 FUNCDEF(exp);
|
||||
00760 FUNCDEF(log);
|
||||
00761 } <span class="comment">// namespace</span>
|
||||
00762
|
||||
00763 <span class="keywordtype">double</span> sqr(<span class="keywordtype">double</span> x) { <span class="keywordflow">return</span> x*x; }
|
||||
00764
|
||||
00765 <span class="keyword">namespace </span>{
|
||||
00766 FUNCDEF(sqr);
|
||||
00767 FUNCDEF(sqrt);
|
||||
00768
|
||||
00769 <span class="keyword">const</span> <span class="keywordtype">int</span> buildInFunctionOffset = language.size();
|
||||
00770 } <span class="comment">// namespace </span>
|
||||
00771
|
||||
00772 <span class="keywordtype">void</span> add_tokens() {
|
||||
00773 <span class="keywordtype">unsigned</span> sz = language.size();
|
||||
00774 language.resize(sz + sz+1); <span class="comment">// double</span>
|
||||
00775
|
||||
00776 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = sz; i < language.size(); ++i) {
|
||||
00777 free_list.push_back(i);
|
||||
00778 }
|
||||
00779 }
|
||||
00780
|
||||
00781 <span class="keywordtype">void</span> extend_free_list() {
|
||||
00782 <span class="comment">// first check if we can clean up unused tokens;</span>
|
||||
00783 <span class="keyword">const</span> vector<unsigned>& refcount = Sym::token_refcount();
|
||||
00784 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = buildInFunctionOffset; i < refcount.size(); ++i) {
|
||||
00785 <span class="keywordflow">if</span> (language[i] == 0) <span class="keywordflow">continue</span>;
|
||||
00786
|
||||
00787 <span class="keywordtype">bool</span> c = is_constant(i);
|
||||
00788 <span class="keywordtype">bool</span> l = is_lambda(i);
|
||||
00789
|
||||
00790 <span class="keywordflow">if</span> (refcount[i] == 0 && (c || l)) {
|
||||
00791
|
||||
00792 <span class="keywordflow">if</span> (c) {
|
||||
00793 doubleSet.erase(token_value[i]);
|
||||
00794 }
|
||||
00795
|
||||
00796 <span class="keywordflow">if</span> (l) {
|
||||
00797 lambdaSet.erase(token_lambda[i]);
|
||||
00798 }
|
||||
00799
|
||||
00800 <span class="keyword">delete</span> language[i];
|
||||
00801 language[i] = 0;
|
||||
00802 free_list.push_back(i);
|
||||
00803 }
|
||||
00804 }
|
||||
00805
|
||||
00806 <span class="comment">// if still empty, add new tokens</span>
|
||||
00807 <span class="keywordflow">if</span> (free_list.empty()) {
|
||||
00808 add_tokens();
|
||||
00809 }
|
||||
00810 }
|
||||
00811
|
||||
00812
|
||||
00813 <span class="comment">/* Serialization */</span>
|
||||
00814 <span class="keywordtype">void</span> write_raw(ostream& os, <span class="keyword">const</span> Sym& sym) {
|
||||
00815 token_t token = sym.token();
|
||||
00816 <span class="keyword">const</span> SymVec& args = sym.args();
|
||||
00817
|
||||
00818 <span class="keywordflow">if</span> (is_constant(token)) {
|
||||
00819 os << <span class="stringliteral">"c"</span> << language[token]->c_print(vector<string>(), vector<string>());
|
||||
00820 } <span class="keywordflow">else</span> {
|
||||
00821
|
||||
00822 <span class="keyword">const</span> Var* var = dynamic_cast<const Var*>( language[token] );
|
||||
00823
|
||||
00824 <span class="keywordflow">if</span> (var != 0) {
|
||||
00825 os << <span class="stringliteral">"v"</span> << var->idx;
|
||||
00826 } <span class="keywordflow">else</span> {
|
||||
00827 os << <span class="stringliteral">"f"</span> << token << <span class="charliteral">' '</span> << args.size();
|
||||
00828 }
|
||||
00829 }
|
||||
00830
|
||||
00831 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < args.size(); ++i) {
|
||||
00832 write_raw(os, args[i]);
|
||||
00833 }
|
||||
00834 }
|
||||
00835
|
||||
00836 string write_raw(<span class="keyword">const</span> Sym& sym) {
|
||||
00837
|
||||
00838 ostringstream os;
|
||||
00839 write_raw(os, sym);
|
||||
00840
|
||||
00841 <span class="keywordflow">return</span> os.str();
|
||||
00842 }
|
||||
00843
|
||||
00844 Sym read_raw(istream& is) {
|
||||
00845 <span class="keywordtype">char</span> <span class="keywordtype">id</span> = is.get();
|
||||
00846
|
||||
00847 <span class="keywordflow">switch</span> (id) {
|
||||
00848 <span class="keywordflow">case</span> <span class="charliteral">'c'</span> :
|
||||
00849 {
|
||||
00850 <span class="keywordtype">double</span> val;
|
||||
00851 is.get(); <span class="comment">// skip '('</span>
|
||||
00852 is >> val;
|
||||
00853 is.get(); <span class="comment">// skip ')'</span>
|
||||
00854 <span class="keywordflow">return</span> SymConst(val);
|
||||
00855 }
|
||||
00856 <span class="keywordflow">case</span> <span class="charliteral">'v'</span> :
|
||||
00857 {
|
||||
00858 <span class="keywordtype">unsigned</span> idx;
|
||||
00859 is >> idx;
|
||||
00860 <span class="keywordflow">return</span> SymVar(idx);
|
||||
00861 }
|
||||
00862 <span class="keywordflow">case</span> <span class="charliteral">'f'</span> :
|
||||
00863 {
|
||||
00864 token_t token;
|
||||
00865 <span class="keywordtype">unsigned</span> arity;
|
||||
00866 is >> token;
|
||||
00867 is >> arity;
|
||||
00868 SymVec args(arity);
|
||||
00869 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < arity; ++i) {
|
||||
00870 args[i] = read_raw(is);
|
||||
00871 }
|
||||
00872
|
||||
00873 <span class="keywordflow">return</span> Sym(token, args);
|
||||
00874 }
|
||||
00875 <span class="keywordflow">default</span> : {
|
||||
00876 cerr << <span class="stringliteral">"Character = "</span> << <span class="keywordtype">id</span> << <span class="stringliteral">" Could not read formula from stream"</span> << endl;
|
||||
00877 exit(1);
|
||||
00878 }
|
||||
00879
|
||||
00880 }
|
||||
00881
|
||||
00882 <span class="keywordflow">return</span> Sym();
|
||||
00883 }
|
||||
00884
|
||||
00885 Sym read_raw(string str) {
|
||||
00886 istringstream is(str);
|
||||
00887 <span class="keywordflow">return</span> read_raw(is);
|
||||
00888 }
|
||||
00889
|
||||
00890 <span class="keywordtype">void</span> read_raw(istream& is, Sym& sym) {
|
||||
00891 sym = read_raw(is);
|
||||
00892 }
|
||||
00893
|
||||
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:40 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>
|
||||
171
trunk/paradiseo-eo/doc/html/_fun_def_8h-source.html
Normal file
|
|
@ -0,0 +1,171 @@
|
|||
<!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: FunDef.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_000008.html">mathsym</a> / <a class="el" href="dir_000022.html">fun</a></div>
|
||||
<h1>FunDef.h</h1><div class="fragment"><pre class="fragment">00001 <span class="comment">/* </span>
|
||||
00002 <span class="comment"> * Copyright (C) 2005 Maarten Keijzer</span>
|
||||
00003 <span class="comment"> *</span>
|
||||
00004 <span class="comment"> * This program is free software; you can redistribute it and/or modify</span>
|
||||
00005 <span class="comment"> * it under the terms of version 2 of the GNU General Public License as </span>
|
||||
00006 <span class="comment"> * published by the Free Software Foundation. </span>
|
||||
00007 <span class="comment"> *</span>
|
||||
00008 <span class="comment"> * This program is distributed in the hope that it will be useful,</span>
|
||||
00009 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
|
||||
00010 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
|
||||
00011 <span class="comment"> * GNU General Public License for more details.</span>
|
||||
00012 <span class="comment"> *</span>
|
||||
00013 <span class="comment"> * You should have received a copy of the GNU General Public License</span>
|
||||
00014 <span class="comment"> * along with this program; if not, write to the Free Software</span>
|
||||
00015 <span class="comment"> * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>
|
||||
00016 <span class="comment"> */</span>
|
||||
00017
|
||||
00018 <span class="preprocessor">#ifndef FUNCTION_DEF_H_</span>
|
||||
00019 <span class="preprocessor"></span><span class="preprocessor">#define FUNCTION_DEF_H_</span>
|
||||
00020 <span class="preprocessor"></span>
|
||||
00021 <span class="preprocessor">#include <string></span>
|
||||
00022 <span class="preprocessor">#include <vector></span>
|
||||
00023 <span class="preprocessor">#include <memory></span>
|
||||
00024 <span class="preprocessor">#include <iostream></span>
|
||||
00025
|
||||
00026 <span class="preprocessor">#include "Sym.h"</span>
|
||||
00027 <span class="preprocessor">#include "Interval.h"</span>
|
||||
00028
|
||||
00029 <span class="keyword">class </span>FunDef {
|
||||
00030 <span class="keyword">public</span>:
|
||||
00031
|
||||
00032 <span class="keyword">virtual</span> ~FunDef() {}
|
||||
00033
|
||||
00034 <span class="comment">// (possibly) lazy evaluation function, default implementation calls 'eager' eval</span>
|
||||
00035 <span class="keyword">virtual</span> <span class="keywordtype">double</span> eval(<span class="keyword">const</span> SymVec& args, <span class="keyword">const</span> std::vector<double>& inputs) <span class="keyword">const</span>;
|
||||
00036
|
||||
00037 <span class="comment">// eager evaluation function </span>
|
||||
00038 <span class="keyword">virtual</span> <span class="keywordtype">double</span> eval(<span class="keyword">const</span> std::vector<double>& args, <span class="keyword">const</span> std::vector<double>& inputs) <span class="keyword">const </span>= 0;
|
||||
00039
|
||||
00040 <span class="comment">// interval evaluation</span>
|
||||
00041 <span class="keyword">virtual</span> Interval eval(<span class="keyword">const</span> std::vector<Interval>& args, <span class="keyword">const</span> std::vector<Interval>& inputs) <span class="keyword">const </span>= 0;
|
||||
00042
|
||||
00043 <span class="comment">// prints 'c' like code</span>
|
||||
00044 <span class="keyword">virtual</span> std::string c_print(<span class="keyword">const</span> std::vector<std::string>& names, <span class="keyword">const</span> std::vector<std::string>& names) <span class="keyword">const </span>= 0;
|
||||
00045
|
||||
00046 <span class="keyword">virtual</span> <span class="keywordtype">unsigned</span> min_arity() <span class="keyword">const </span>= 0;
|
||||
00047 <span class="keyword">virtual</span> <span class="keywordtype">bool</span> has_varargs()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <span class="keyword">false</span>; } <span class="comment">// sum, prod, min, max are variable arity</span>
|
||||
00048
|
||||
00049 <span class="keyword">virtual</span> std::string name() <span class="keyword">const </span>= 0;
|
||||
00050
|
||||
00051 <span class="keyword">protected</span>:
|
||||
00052
|
||||
00053 };
|
||||
00054
|
||||
00056 <span class="keyword">extern</span> std::vector<const FunDef*> get_defined_functions();
|
||||
00057
|
||||
00059 <span class="keyword">extern</span> <span class="keyword">const</span> FunDef& get_element(token_t token);
|
||||
00060
|
||||
00062 <span class="keyword">extern</span> <span class="keywordtype">double</span> eval(<span class="keyword">const</span> Sym& sym, <span class="keyword">const</span> std::vector<double>& inputs);
|
||||
00063
|
||||
00065 <span class="keyword">extern</span> Interval eval(<span class="keyword">const</span> Sym& sym, <span class="keyword">const</span> std::vector<Interval>& inputs);
|
||||
00066
|
||||
00068 <span class="keyword">extern</span> std::string c_print(<span class="keyword">const</span> Sym& sym);
|
||||
00069
|
||||
00071 <span class="keyword">extern</span> std::string c_print(<span class="keyword">const</span> Sym& sym, <span class="keyword">const</span> std::vector<std::string>& var_names);
|
||||
00072
|
||||
00074 <span class="keyword">inline</span> std::ostream& operator<<(std::ostream& os, <span class="keyword">const</span> Sym& sym) { <span class="keywordflow">return</span> os << c_print(sym); }
|
||||
00075
|
||||
00076 <span class="comment">/* Support for Ephemeral Random Constants (ERC) */</span>
|
||||
00077
|
||||
00079 <span class="keyword">extern</span> Sym SymConst(<span class="keywordtype">double</span> value);
|
||||
00081 <span class="keyword">extern</span> Sym SymVar(<span class="keywordtype">unsigned</span> idx);
|
||||
00082
|
||||
00093 <span class="keyword">extern</span> Sym SymLambda(Sym expression);
|
||||
00094
|
||||
00095 <span class="keyword">extern</span> Sym SymUnlambda(Sym sym);
|
||||
00096
|
||||
00098 <span class="keyword">extern</span> Sym expand_all(Sym sym);
|
||||
00099 <span class="keyword">extern</span> Sym compress(Sym sym);
|
||||
00100
|
||||
00102 std::vector<double> get_constants(Sym sym);
|
||||
00103
|
||||
00106 Sym set_constants(Sym sym, <span class="keyword">const</span> std::vector<double>& constants);
|
||||
00107
|
||||
00109 <span class="keyword">extern</span> <span class="keywordtype">bool</span> is_constant(token_t token);
|
||||
00110 <span class="keyword">extern</span> <span class="keywordtype">double</span> get_constant_value(token_t token);
|
||||
00112 <span class="keyword">extern</span> <span class="keywordtype">bool</span> is_variable(token_t token);
|
||||
00113 <span class="keyword">extern</span> <span class="keywordtype">unsigned</span> get_variable_index(token_t token);
|
||||
00114
|
||||
00116 <span class="keyword">extern</span> <span class="keywordtype">bool</span> is_lambda(token_t token);
|
||||
00117
|
||||
00118
|
||||
00120 <span class="keyword">extern</span> Sym simplify(Sym sym);
|
||||
00121
|
||||
00125 <span class="keyword">extern</span> Sym differentiate(Sym sym, token_t dx);
|
||||
00126 <span class="keyword">struct </span>differentiation_error{}; <span class="comment">// thrown in case of ifltz</span>
|
||||
00127
|
||||
00128 <span class="comment">/* Add function to the language table (and take a guess at the arity) */</span>
|
||||
00129 <span class="keyword">class </span>LanguageTable;
|
||||
00130 <span class="keyword">extern</span> <span class="keywordtype">void</span> add_function_to_table(LanguageTable& table, token_t token);
|
||||
00131
|
||||
00132 <span class="keyword">enum</span> {
|
||||
00133 sum_token,
|
||||
00134 prod_token,
|
||||
00135 inv_token,
|
||||
00136 min_token,
|
||||
00137 pow_token,
|
||||
00138 ifltz_token,
|
||||
00139 sin_token, cos_token, tan_token,
|
||||
00140 asin_token, acos_token, atan_token,
|
||||
00141 sinh_token, cosh_token, tanh_token,
|
||||
00142 acosh_token, asinh_token, atanh_token,
|
||||
00143 exp_token, log_token,
|
||||
00144 sqr_token, sqrt_token
|
||||
00145 };
|
||||
00146
|
||||
00147 <span class="comment">/* Defition of function overloads: for example, this define the function 'Sym sin(Sym)' */</span>
|
||||
00148
|
||||
00149 <span class="preprocessor">#define HEADERFUNC(name) inline Sym name(Sym arg) { return Sym(name##_token, arg); }</span>
|
||||
00150 <span class="preprocessor"></span>
|
||||
00151 <span class="comment">/* This defines the tokens: sin_token, cos_token, etc. */</span>
|
||||
00152 HEADERFUNC(inv);
|
||||
00153 HEADERFUNC(sin);
|
||||
00154 HEADERFUNC(cos);
|
||||
00155 HEADERFUNC(tan);
|
||||
00156 HEADERFUNC(asin);
|
||||
00157 HEADERFUNC(acos);
|
||||
00158 HEADERFUNC(atan);
|
||||
00159
|
||||
00160 HEADERFUNC(sinh);
|
||||
00161 HEADERFUNC(cosh);
|
||||
00162 HEADERFUNC(tanh);
|
||||
00163 HEADERFUNC(asinh);
|
||||
00164 HEADERFUNC(acosh);
|
||||
00165 HEADERFUNC(atanh);
|
||||
00166
|
||||
00167 HEADERFUNC(exp);
|
||||
00168 HEADERFUNC(log);
|
||||
00169
|
||||
00170 HEADERFUNC(sqr);
|
||||
00171 HEADERFUNC(sqrt);
|
||||
00172
|
||||
00173 <span class="comment">/* Get the prototype functions out, this is needed for compilation */</span>
|
||||
00174 <span class="keyword">extern</span> std::string get_prototypes();
|
||||
00175
|
||||
00176 <span class="comment">// reading and writing in internal format, no parser for symbolic functions implemented yet</span>
|
||||
00177 <span class="keyword">extern</span> std::string write_raw(<span class="keyword">const</span> Sym& sym);
|
||||
00178 <span class="keyword">extern</span> <span class="keywordtype">void</span> write_raw(std::ostream& os, <span class="keyword">const</span> Sym& sym);
|
||||
00179 <span class="keyword">extern</span> Sym read_raw(std::string str);
|
||||
00180 <span class="keyword">extern</span> Sym read_raw(std::istream& is);
|
||||
00181 <span class="keyword">extern</span> <span class="keywordtype">void</span> read_raw(std::istream& is, Sym& sym);
|
||||
00182
|
||||
00183 <span class="preprocessor">#include "SymOps.h"</span>
|
||||
00184
|
||||
00185 <span class="preprocessor">#endif</span>
|
||||
00186 <span class="preprocessor"></span>
|
||||
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:40 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>
|
||||
130
trunk/paradiseo-eo/doc/html/_interval_8h-source.html
Normal file
|
|
@ -0,0 +1,130 @@
|
|||
<!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: Interval.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_000008.html">mathsym</a> / <a class="el" href="dir_000009.html">eval</a></div>
|
||||
<h1>Interval.h</h1><div class="fragment"><pre class="fragment">00001 <span class="comment">/* </span>
|
||||
00002 <span class="comment"> * Copyright (C) 2005 Maarten Keijzer</span>
|
||||
00003 <span class="comment"> *</span>
|
||||
00004 <span class="comment"> * This program is free software; you can redistribute it and/or modify</span>
|
||||
00005 <span class="comment"> * it under the terms of version 2 of the GNU General Public License as </span>
|
||||
00006 <span class="comment"> * published by the Free Software Foundation. </span>
|
||||
00007 <span class="comment"> *</span>
|
||||
00008 <span class="comment"> * This program is distributed in the hope that it will be useful,</span>
|
||||
00009 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
|
||||
00010 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
|
||||
00011 <span class="comment"> * GNU General Public License for more details.</span>
|
||||
00012 <span class="comment"> *</span>
|
||||
00013 <span class="comment"> * You should have received a copy of the GNU General Public License</span>
|
||||
00014 <span class="comment"> * along with this program; if not, write to the Free Software</span>
|
||||
00015 <span class="comment"> * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>
|
||||
00016 <span class="comment"> */</span>
|
||||
00017
|
||||
00018 <span class="preprocessor">#ifndef INTERVAL__H__</span>
|
||||
00019 <span class="preprocessor"></span><span class="preprocessor">#define INTERVAL__H__</span>
|
||||
00020 <span class="preprocessor"></span>
|
||||
00021 <span class="preprocessor">#include <boost/numeric/interval.hpp></span>
|
||||
00022 <span class="preprocessor">#include <iostream></span>
|
||||
00023 <span class="preprocessor">#include <limits></span>
|
||||
00024
|
||||
00025
|
||||
00026 <span class="keyword">typedef</span> boost::numeric::interval_lib::rounded_transc_exact<double> RoundingTransc;
|
||||
00027 <span class="keyword">typedef</span> boost::numeric::interval_lib::save_state<RoundingTransc> Rounding;
|
||||
00028 <span class="keyword">typedef</span> boost::numeric::interval_lib::checking_base<double> Checking;
|
||||
00029 <span class="keyword">typedef</span> boost::numeric::interval_lib::policies<Rounding,Checking> Policy;
|
||||
00030 <span class="keyword">typedef</span> boost::numeric::interval<double, Policy> Interval;
|
||||
00031
|
||||
00032 <span class="keyword">struct </span>interval_error{};
|
||||
00033
|
||||
00034 <span class="keyword">inline</span> <span class="keywordtype">bool</span> valid(<span class="keyword">const</span> Interval& val) {
|
||||
00035 <span class="keywordflow">if</span> (!finite(val.lower()) || !finite(val.upper())) <span class="keywordflow">return</span> <span class="keyword">false</span>;
|
||||
00036
|
||||
00037 <span class="keywordflow">return</span> val.lower() > -1e10 && val.upper() < 1e10;
|
||||
00038 }
|
||||
00039
|
||||
00040 <span class="keyword">inline</span> Interval sqrt(<span class="keyword">const</span> Interval& val) {
|
||||
00041 <span class="keywordflow">if</span> (val.lower() < 0.0) {
|
||||
00042 <span class="keywordflow">return</span> Interval::whole();
|
||||
00043 }
|
||||
00044
|
||||
00045 <span class="keywordflow">return</span> boost::numeric::sqrt(val);
|
||||
00046 }
|
||||
00047
|
||||
00048 <span class="keyword">inline</span> Interval sqr(<span class="keyword">const</span> Interval& val) {
|
||||
00049 <span class="keywordflow">return</span> square(val);
|
||||
00050 }
|
||||
00051
|
||||
00052 <span class="keyword">inline</span> Interval acos(<span class="keyword">const</span> Interval& val) {
|
||||
00053 <span class="keywordflow">if</span> (val.lower() < 1.0 || val.upper() > 1.0) {
|
||||
00054 <span class="keywordflow">return</span> Interval::whole();
|
||||
00055 }
|
||||
00056
|
||||
00057 <span class="keywordflow">return</span> boost::numeric::acos(val);
|
||||
00058 }
|
||||
00059
|
||||
00060 <span class="keyword">inline</span> Interval asin(<span class="keyword">const</span> Interval& val) {
|
||||
00061 <span class="keywordflow">if</span> (val.lower() < 1.0 || val.upper() > 1.0) {
|
||||
00062 <span class="keywordflow">return</span> Interval::whole();
|
||||
00063 }
|
||||
00064
|
||||
00065 <span class="keywordflow">return</span> boost::numeric::asin(val);
|
||||
00066 }
|
||||
00067
|
||||
00068 <span class="keyword">inline</span> Interval acosh(<span class="keyword">const</span> Interval& val) {
|
||||
00069 <span class="keywordflow">if</span> (val.lower() < 1.0) <span class="keywordflow">return</span> Interval::whole();
|
||||
00070 <span class="keywordflow">return</span> boost::numeric::acosh(val);
|
||||
00071 }
|
||||
00072
|
||||
00073 <span class="keyword">inline</span>
|
||||
00074 std::ostream& operator<<(std::ostream& os, <span class="keyword">const</span> Interval& val) {
|
||||
00075 os << <span class="charliteral">'['</span> << val.lower() << <span class="stringliteral">", "</span> << val.upper() << <span class="charliteral">']'</span>;
|
||||
00076 <span class="keywordflow">return</span> os;
|
||||
00077 }
|
||||
00078
|
||||
00079 <span class="preprocessor">#ifdef TEST_INTERVAL</span>
|
||||
00080 <span class="preprocessor"></span><span class="keyword">using</span> <span class="keyword">namespace </span>std;
|
||||
00081 <span class="keyword">using</span> <span class="keyword">namespace </span>boost::numeric;
|
||||
00082
|
||||
00083 <span class="keywordtype">int</span> main() {
|
||||
00084 Interval a(0, 10);
|
||||
00085 Interval b(-1.5, 2);
|
||||
00086 cout << <span class="stringliteral">"a = "</span> << a << endl;
|
||||
00087 cout << <span class="stringliteral">"b = "</span> << b << endl;
|
||||
00088 cout << <span class="stringliteral">"a + b = "</span> << a + b << endl;
|
||||
00089 cout << <span class="stringliteral">"a - b = "</span> << a - b << endl;
|
||||
00090 cout << <span class="stringliteral">"b - a = "</span> << b - a << endl;
|
||||
00091 cout << <span class="stringliteral">"-a = "</span> << -a << endl;
|
||||
00092 cout << <span class="stringliteral">"a * b = "</span> << a * b << endl;
|
||||
00093 cout << <span class="stringliteral">"b/(a+1) = "</span> << b / (a + 1.0) << endl;
|
||||
00094 cout << <span class="stringliteral">"b * a = "</span> << b * a << endl;
|
||||
00095
|
||||
00096 cout << <span class="stringliteral">"b / a = "</span> << b/a << endl;
|
||||
00097
|
||||
00098 cout << <span class="stringliteral">"cos(a) = "</span> << cos(a) << endl;
|
||||
00099 cout << <span class="stringliteral">"cos(b) = "</span> << cos(b) << endl;
|
||||
00100
|
||||
00101 cout << <span class="stringliteral">"log(b) = "</span> << log(b) << endl;
|
||||
00102
|
||||
00103 cout << <span class="stringliteral">"sqrt(b) = "</span> << sqrt(b) << endl;
|
||||
00104 cout << <span class="stringliteral">"sqrt(a) = "</span> << sqrt(a) << endl;
|
||||
00105 cout << <span class="stringliteral">"sqr(b) = "</span> << sqr(b) << endl;
|
||||
00106
|
||||
00107 cout << <span class="stringliteral">"exp(b*a)= "</span> << exp(b*a) << endl;
|
||||
00108
|
||||
00109 cout << <span class="stringliteral">"atan(a) = "</span> << atan(a) << endl;
|
||||
00110 cout << <span class="stringliteral">"cosh(b) = "</span> << cosh(b) << endl;
|
||||
00111
|
||||
00112 }
|
||||
00113 <span class="preprocessor">#endif</span>
|
||||
00114 <span class="preprocessor"></span>
|
||||
00115 <span class="preprocessor">#endif</span>
|
||||
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:40 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>
|
||||
113
trunk/paradiseo-eo/doc/html/_language_table_8cpp-source.html
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
<!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: LanguageTable.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_000007.html">contrib</a> / <a class="el" href="dir_000008.html">mathsym</a> / <a class="el" href="dir_000024.html">gen</a></div>
|
||||
<h1>LanguageTable.cpp</h1><div class="fragment"><pre class="fragment">00001 <span class="comment">/* </span>
|
||||
00002 <span class="comment"> * Copyright (C) 2005 Maarten Keijzer</span>
|
||||
00003 <span class="comment"> *</span>
|
||||
00004 <span class="comment"> * This program is free software; you can redistribute it and/or modify</span>
|
||||
00005 <span class="comment"> * it under the terms of version 2 of the GNU General Public License as </span>
|
||||
00006 <span class="comment"> * published by the Free Software Foundation. </span>
|
||||
00007 <span class="comment"> *</span>
|
||||
00008 <span class="comment"> * This program is distributed in the hope that it will be useful,</span>
|
||||
00009 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
|
||||
00010 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
|
||||
00011 <span class="comment"> * GNU General Public License for more details.</span>
|
||||
00012 <span class="comment"> *</span>
|
||||
00013 <span class="comment"> * You should have received a copy of the GNU General Public License</span>
|
||||
00014 <span class="comment"> * along with this program; if not, write to the Free Software</span>
|
||||
00015 <span class="comment"> * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>
|
||||
00016 <span class="comment"> */</span>
|
||||
00017
|
||||
00018
|
||||
00019 <span class="preprocessor">#include "LanguageTable.h"</span>
|
||||
00020 <span class="preprocessor">#include "Sym.h"</span>
|
||||
00021
|
||||
00022 <span class="preprocessor">#include <utils/eoRNG.h></span>
|
||||
00023
|
||||
00024 <span class="keyword">using</span> <span class="keyword">namespace </span>std;
|
||||
00025
|
||||
00026 <span class="keyword">extern</span> Sym default_const();
|
||||
00027
|
||||
00028 <span class="keyword">class </span>LanguageImpl {
|
||||
00029 <span class="keyword">public</span> :
|
||||
00030 std::vector<Sym> vars;
|
||||
00031 LanguageTable::erc_func erc;
|
||||
00032
|
||||
00033 std::vector<functor_t> functions;
|
||||
00034 std::vector< std::vector<token_t> > functions_per_arity;
|
||||
00035
|
||||
00036 LanguageImpl() : erc(default_const) {}
|
||||
00037 };
|
||||
00038
|
||||
00039 LanguageTable::LanguageTable() {
|
||||
00040 pimpl = <span class="keyword">new</span> LanguageImpl;
|
||||
00041 }
|
||||
00042
|
||||
00043 LanguageTable::~LanguageTable() {
|
||||
00044 <span class="keyword">delete</span> pimpl;
|
||||
00045 }
|
||||
00046
|
||||
00047 LanguageTable::LanguageTable(<span class="keyword">const</span> LanguageTable& that) {
|
||||
00048 pimpl = <span class="keyword">new</span> LanguageImpl(*that.pimpl);
|
||||
00049 }
|
||||
00050
|
||||
00051 LanguageTable& LanguageTable::operator=(<span class="keyword">const</span> LanguageTable& that) {
|
||||
00052 *pimpl = *that.pimpl;
|
||||
00053 <span class="keywordflow">return</span> *<span class="keyword">this</span>;
|
||||
00054 }
|
||||
00055
|
||||
00056 <span class="keywordtype">void</span> LanguageTable::add_function(token_t token, <span class="keywordtype">unsigned</span> arity) {
|
||||
00057 functor_t f = {token, arity};
|
||||
00058 add_function( f );
|
||||
00059 }
|
||||
00060
|
||||
00061 <span class="keywordtype">void</span> LanguageTable::add_function(functor_t f) {
|
||||
00062
|
||||
00063 <span class="keywordflow">if</span> (f.arity > 0) {
|
||||
00064 pimpl->functions.push_back(f);
|
||||
00065
|
||||
00066 } <span class="keywordflow">else</span> {
|
||||
00067 pimpl->vars.push_back(Sym(f.token));
|
||||
00068 }
|
||||
00069
|
||||
00070 <span class="keywordflow">if</span> (pimpl->functions_per_arity.size() <= f.arity) pimpl->functions_per_arity.resize(f.arity+1);
|
||||
00071 pimpl->functions_per_arity[f.arity].push_back(f.token);
|
||||
00072
|
||||
00073 }
|
||||
00074
|
||||
00075 <span class="keywordtype">void</span> LanguageTable::set_erc( erc_func func) { pimpl->erc = func; }
|
||||
00076
|
||||
00077 <span class="comment">/* Getting info out */</span>
|
||||
00078
|
||||
00079 <span class="keyword">extern</span> Sym SymConst(<span class="keywordtype">double</span> val);
|
||||
00080
|
||||
00081 Sym LanguageTable::get_random_var()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> rng.<a class="code" href="classeo_rng.html#a14">choice</a>(pimpl->vars); }
|
||||
00082 Sym LanguageTable::get_random_const()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> pimpl->erc(); }
|
||||
00083
|
||||
00084 functor_t LanguageTable::get_random_function()<span class="keyword"> const </span>
|
||||
00085 <span class="keyword"></span>{
|
||||
00086 <span class="keywordflow">return</span> rng.<a class="code" href="classeo_rng.html#a14">choice</a>(pimpl->functions);
|
||||
00087 }
|
||||
00088
|
||||
00089 token_t LanguageTable::get_random_function(token_t token, <span class="keywordtype">unsigned</span> arity)<span class="keyword"> const </span>
|
||||
00090 <span class="keyword"></span>{
|
||||
00091 <span class="keywordflow">if</span> (pimpl->functions_per_arity.size() <= arity || pimpl->functions_per_arity[arity].empty()) {
|
||||
00092 <span class="keywordflow">return</span> token; <span class="comment">// return original token if no functions of this arity are found</span>
|
||||
00093 }
|
||||
00094 <span class="keywordflow">return</span> rng.<a class="code" href="classeo_rng.html#a14">choice</a>(pimpl->functions_per_arity[arity]);
|
||||
00095 }
|
||||
00096
|
||||
00097
|
||||
00098
|
||||
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:40 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>
|
||||
71
trunk/paradiseo-eo/doc/html/_language_table_8h-source.html
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
<!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: LanguageTable.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_000008.html">mathsym</a> / <a class="el" href="dir_000024.html">gen</a></div>
|
||||
<h1>LanguageTable.h</h1><div class="fragment"><pre class="fragment">00001 <span class="comment">/* </span>
|
||||
00002 <span class="comment"> * Copyright (C) 2005 Maarten Keijzer</span>
|
||||
00003 <span class="comment"> *</span>
|
||||
00004 <span class="comment"> * This program is free software; you can redistribute it and/or modify</span>
|
||||
00005 <span class="comment"> * it under the terms of version 2 of the GNU General Public License as </span>
|
||||
00006 <span class="comment"> * published by the Free Software Foundation. </span>
|
||||
00007 <span class="comment"> *</span>
|
||||
00008 <span class="comment"> * This program is distributed in the hope that it will be useful,</span>
|
||||
00009 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
|
||||
00010 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
|
||||
00011 <span class="comment"> * GNU General Public License for more details.</span>
|
||||
00012 <span class="comment"> *</span>
|
||||
00013 <span class="comment"> * You should have received a copy of the GNU General Public License</span>
|
||||
00014 <span class="comment"> * along with this program; if not, write to the Free Software</span>
|
||||
00015 <span class="comment"> * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>
|
||||
00016 <span class="comment"> */</span>
|
||||
00017
|
||||
00018 <span class="preprocessor">#ifndef LANGUAGE_TABLE_H</span>
|
||||
00019 <span class="preprocessor"></span><span class="preprocessor">#define LANGUAGE_TABLE_H</span>
|
||||
00020 <span class="preprocessor"></span>
|
||||
00021 <span class="preprocessor">#include "token.h"</span>
|
||||
00022
|
||||
00023 <span class="keyword">class </span>LanguageImpl;
|
||||
00024 <span class="keyword">class </span>Sym;
|
||||
00025
|
||||
00026 <span class="keyword">class </span>LanguageTable {
|
||||
00027
|
||||
00028 LanguageImpl* pimpl;
|
||||
00029
|
||||
00030 <span class="keyword">public</span>:
|
||||
00031
|
||||
00032 LanguageTable();
|
||||
00033 ~LanguageTable();
|
||||
00034
|
||||
00035 LanguageTable(<span class="keyword">const</span> LanguageTable& org);
|
||||
00036
|
||||
00037 LanguageTable& operator=(<span class="keyword">const</span> LanguageTable& org);
|
||||
00038
|
||||
00039 <span class="comment">/* setting it up */</span>
|
||||
00040 <span class="keyword">typedef</span> Sym (*erc_func)();
|
||||
00041
|
||||
00042 <span class="keywordtype">void</span> add_function(token_t token, <span class="keywordtype">unsigned</span> arity);
|
||||
00043 <span class="keywordtype">void</span> add_function(functor_t functor);
|
||||
00044 <span class="keywordtype">void</span> set_erc(erc_func func);
|
||||
00045
|
||||
00046 <span class="comment">/* Getting info out */</span>
|
||||
00047
|
||||
00048 Sym get_random_var() <span class="keyword">const</span>;
|
||||
00049 Sym get_random_const() <span class="keyword">const</span>;
|
||||
00050
|
||||
00051 functor_t get_random_function() <span class="keyword">const</span>;
|
||||
00052 token_t get_random_function(token_t org, <span class="keywordtype">unsigned</span> arity) <span class="keyword">const</span>;
|
||||
00053 };
|
||||
00054
|
||||
00055 <span class="preprocessor">#endif</span>
|
||||
00056 <span class="preprocessor"></span>
|
||||
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:40 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>
|
||||
41
trunk/paradiseo-eo/doc/html/_multi_funcs_8cpp-source.html
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
<!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: MultiFuncs.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_000007.html">contrib</a> / <a class="el" href="dir_000008.html">mathsym</a> / <a class="el" href="dir_000009.html">eval</a></div>
|
||||
<h1>MultiFuncs.cpp</h1><div class="fragment"><pre class="fragment">00001
|
||||
00002 <span class="keyword">namespace </span>multi_function {
|
||||
00003
|
||||
00004 <span class="keywordtype">double</span> plus(arg_ptr args) {
|
||||
00005 <span class="keywordflow">return</span> *args[0] + *args[1];
|
||||
00006 }
|
||||
00007
|
||||
00008 <span class="keywordtype">double</span> mult(arg_ptr args) {
|
||||
00009 <span class="keywordflow">return</span> *args[0] * *args[1];
|
||||
00010 }
|
||||
00011
|
||||
00012 <span class="keywordtype">double</span> min(arg_ptr args) {
|
||||
00013 <span class="keywordflow">return</span> -**args;
|
||||
00014 }
|
||||
00015
|
||||
00016 <span class="keywordtype">double</span> inv(arg_ptr args) {
|
||||
00017 <span class="keywordflow">return</span> 1 / **args;
|
||||
00018 }
|
||||
00019
|
||||
00020 <span class="comment">//template <typename f> class F { public: double operator()(double a) { return f(a); } };</span>
|
||||
00021
|
||||
00022 <span class="keywordtype">double</span> exp(arg_ptr args) {
|
||||
00023 return ::exp(**args);
|
||||
00024 }
|
||||
00025
|
||||
00026 } <span class="comment">// namespace</span>
|
||||
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:41 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>
|
||||
356
trunk/paradiseo-eo/doc/html/_multi_function_8cpp-source.html
Normal file
|
|
@ -0,0 +1,356 @@
|
|||
<!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: MultiFunction.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_000007.html">contrib</a> / <a class="el" href="dir_000008.html">mathsym</a> / <a class="el" href="dir_000009.html">eval</a></div>
|
||||
<h1>MultiFunction.cpp</h1><div class="fragment"><pre class="fragment">00001 <span class="preprocessor">#include <vector.h></span>
|
||||
00002
|
||||
00003
|
||||
00004 <span class="preprocessor">#include "MultiFunction.h"</span>
|
||||
00005 <span class="preprocessor">#include "Sym.h"</span>
|
||||
00006 <span class="preprocessor">#include "FunDef.h"</span>
|
||||
00007
|
||||
00008 <span class="keyword">using</span> <span class="keyword">namespace </span>std;
|
||||
00009
|
||||
00010
|
||||
00011 <span class="keyword">typedef</span> vector<double>::const_iterator data_ptr;
|
||||
00012 <span class="keyword">typedef</span> vector<data_ptr> data_ptrs;
|
||||
00013 <span class="keyword">typedef</span> data_ptrs::const_iterator arg_ptr;
|
||||
00014
|
||||
00015 <span class="preprocessor">#include "MultiFuncs.cpp"</span>
|
||||
00016
|
||||
00017 <span class="keyword">typedef</span> double (*fptr)( arg_ptr );
|
||||
00018
|
||||
00019 string print_function( fptr f) {
|
||||
00020 <span class="keywordflow">if</span> (f == multi_function::plus) <span class="keywordflow">return</span> <span class="stringliteral">"+"</span>;
|
||||
00021 <span class="keywordflow">if</span> (f == multi_function::mult) <span class="keywordflow">return</span> <span class="stringliteral">"*"</span>;
|
||||
00022 <span class="keywordflow">if</span> (f == multi_function::min) <span class="keywordflow">return</span> <span class="stringliteral">"-"</span>;
|
||||
00023 <span class="keywordflow">if</span> (f == multi_function::inv) <span class="keywordflow">return</span> <span class="stringliteral">"/"</span>;
|
||||
00024 <span class="keywordflow">if</span> (f == multi_function::exp) <span class="keywordflow">return</span> <span class="stringliteral">"e"</span>;
|
||||
00025 <span class="keywordflow">return</span> <span class="stringliteral">"unknown"</span>;
|
||||
00026 }
|
||||
00027
|
||||
00028
|
||||
00029 <span class="keyword">struct </span>Function {
|
||||
00030
|
||||
00031 fptr function;
|
||||
00032 arg_ptr args;
|
||||
00033
|
||||
00034 <span class="keywordtype">double</span> operator()()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> function(args); }
|
||||
00035 };
|
||||
00036
|
||||
00037 <span class="keyword">static</span> vector<Function> token_2_function;
|
||||
00038
|
||||
00039 Sym make_binary(Sym sym) {
|
||||
00040 <span class="keywordflow">if</span> (sym.args().size() == 2) <span class="keywordflow">return</span> sym;
|
||||
00041 SymVec args = sym.args();
|
||||
00042 Sym an = args.back();
|
||||
00043 args.pop_back();
|
||||
00044 Sym nw = make_binary( Sym( sym.token(), args) );
|
||||
00045 args.resize(2);
|
||||
00046 args[0] = nw;
|
||||
00047 args[1] = an;
|
||||
00048 <span class="keywordflow">return</span> Sym(sym.token(), args);
|
||||
00049 }
|
||||
00050
|
||||
00051 <span class="keyword">class </span>Compiler {
|
||||
00052
|
||||
00053 <span class="keyword">public</span>:
|
||||
00054
|
||||
00055 <span class="keyword">enum</span> func_type {constant, variable, function};
|
||||
00056
|
||||
00057 <span class="keyword">typedef</span> pair<func_type, unsigned> entry;
|
||||
00058
|
||||
00059 <span class="preprocessor">#if USE_TR1</span>
|
||||
00060 <span class="preprocessor"></span> <span class="keyword">typedef</span> std::tr1::unordered_map<Sym, entry, HashSym> HashMap;
|
||||
00061 <span class="preprocessor">#else</span>
|
||||
00062 <span class="preprocessor"></span> <span class="keyword">typedef</span> hash_map<Sym, entry, HashSym> HashMap;
|
||||
00063 <span class="preprocessor">#endif </span>
|
||||
00064 <span class="preprocessor"></span>
|
||||
00065 HashMap map;
|
||||
00066
|
||||
00067 vector<double> constants;
|
||||
00068 vector<unsigned> variables;
|
||||
00069 vector< fptr > functions;
|
||||
00070 vector< vector<entry> > function_args;
|
||||
00071
|
||||
00072 <span class="keywordtype">unsigned</span> total_args;
|
||||
00073
|
||||
00074 vector<entry> outputs;
|
||||
00075
|
||||
00076 Compiler() : total_args(0) {}
|
||||
00077
|
||||
00078 entry do_add(Sym sym) {
|
||||
00079
|
||||
00080 HashMap::iterator it = map.find(sym);
|
||||
00081
|
||||
00082 <span class="keywordflow">if</span> (it == map.end()) { <span class="comment">// new entry</span>
|
||||
00083
|
||||
00084 token_t token = sym.token();
|
||||
00085
|
||||
00086 <span class="keywordflow">if</span> (is_constant(token)) {
|
||||
00087 constants.push_back( get_constant_value(token) ); <span class="comment">// set value</span>
|
||||
00088 entry e = make_pair(constant, constants.size()-1);
|
||||
00089 map.insert( make_pair(sym, e) );
|
||||
00090 <span class="keywordflow">return</span> e;
|
||||
00091
|
||||
00092 } <span class="keywordflow">else</span> <span class="keywordflow">if</span> (is_variable(token)) {
|
||||
00093 <span class="keywordtype">unsigned</span> idx = get_variable_index(token);
|
||||
00094 variables.push_back(idx);
|
||||
00095 entry e = make_pair(variable, variables.size()-1);
|
||||
00096 map.insert( make_pair(sym, e) );
|
||||
00097 <span class="keywordflow">return</span> e;
|
||||
00098 } <span class="comment">// else </span>
|
||||
00099
|
||||
00100 fptr f;
|
||||
00101 vector<entry> vec;
|
||||
00102 <span class="keyword">const</span> SymVec& args = sym.args();
|
||||
00103
|
||||
00104 <span class="keywordflow">switch</span> (token) {
|
||||
00105 <span class="keywordflow">case</span> sum_token:
|
||||
00106 {
|
||||
00107 <span class="keywordflow">if</span> (args.size() == 0) {
|
||||
00108 <span class="keywordflow">return</span> do_add( SymConst(0.0));
|
||||
00109 }
|
||||
00110 <span class="keywordflow">if</span> (args.size() == 1) {
|
||||
00111 <span class="keywordflow">return</span> do_add(args[0]);
|
||||
00112 }
|
||||
00113 <span class="keywordflow">if</span> (args.size() == 2) {
|
||||
00114 vec.push_back(do_add(args[0]));
|
||||
00115 vec.push_back(do_add(args[1]));
|
||||
00116 f = multi_function::plus;
|
||||
00117 <span class="comment">//cout << "Adding + " << vec[0].second << ' ' << vec[1].second << endl;</span>
|
||||
00118 <span class="keywordflow">break</span>;
|
||||
00119
|
||||
00120 } <span class="keywordflow">else</span> {
|
||||
00121 <span class="keywordflow">return</span> do_add( make_binary(sym) );
|
||||
00122 }
|
||||
00123
|
||||
00124 }
|
||||
00125 <span class="keywordflow">case</span> prod_token:
|
||||
00126 {
|
||||
00127 <span class="keywordflow">if</span> (args.size() == 0) {
|
||||
00128 <span class="keywordflow">return</span> do_add( SymConst(1.0));
|
||||
00129 }
|
||||
00130 <span class="keywordflow">if</span> (args.size() == 1) {
|
||||
00131 <span class="keywordflow">return</span> do_add(args[0]);
|
||||
00132 }
|
||||
00133 <span class="keywordflow">if</span> (args.size() == 2) {
|
||||
00134 vec.push_back(do_add(args[0]));
|
||||
00135 vec.push_back(do_add(args[1]));
|
||||
00136 f = multi_function::mult;
|
||||
00137 <span class="comment">//cout << "Adding * " << vec[0].second << ' ' << vec[1].second << endl;</span>
|
||||
00138 <span class="keywordflow">break</span>;
|
||||
00139
|
||||
00140
|
||||
00141 } <span class="keywordflow">else</span> {
|
||||
00142 <span class="keywordflow">return</span> do_add( make_binary(sym) );
|
||||
00143 }
|
||||
00144 }
|
||||
00145 <span class="keywordflow">case</span> sqr_token:
|
||||
00146 {
|
||||
00147 SymVec newargs(2);
|
||||
00148 newargs[0] = args[0];
|
||||
00149 newargs[1] = args[0];
|
||||
00150 <span class="keywordflow">return</span> do_add( Sym(prod_token, newargs));
|
||||
00151 }
|
||||
00152 <span class="keywordflow">default</span> :
|
||||
00153 {
|
||||
00154 <span class="keywordflow">if</span> (args.size() != 1) {
|
||||
00155 cerr << <span class="stringliteral">"Unknown function "</span> << sym << <span class="stringliteral">" encountered"</span> << endl;
|
||||
00156 exit(1);
|
||||
00157 }
|
||||
00158
|
||||
00159 vec.push_back(do_add(args[0]));
|
||||
00160
|
||||
00161 <span class="keywordflow">switch</span> (token) {
|
||||
00162 <span class="keywordflow">case</span> min_token: f = multi_function::min; <span class="keywordflow">break</span>;
|
||||
00163 <span class="keywordflow">case</span> inv_token: f = multi_function::inv; <span class="keywordflow">break</span>;
|
||||
00164 <span class="keywordflow">case</span> exp_token :f = multi_function::exp; <span class="keywordflow">break</span>;
|
||||
00165 <span class="keywordflow">default</span> :
|
||||
00166 {
|
||||
00167 cerr << <span class="stringliteral">"Unimplemented token encountered "</span> << sym << endl;
|
||||
00168 exit(1);
|
||||
00169 }
|
||||
00170 }
|
||||
00171
|
||||
00172 <span class="comment">//cout << "Adding " << print_function(f) << ' ' << vec[0].second << endl;</span>
|
||||
00173
|
||||
00174
|
||||
00175 }
|
||||
00176
|
||||
00177 }
|
||||
00178
|
||||
00179 total_args += vec.size();
|
||||
00180 function_args.push_back(vec);
|
||||
00181 functions.push_back(f);
|
||||
00182
|
||||
00183 entry e = make_pair(function, functions.size()-1);
|
||||
00184 map.insert( make_pair(sym, e) );
|
||||
00185 <span class="keywordflow">return</span> e;
|
||||
00186
|
||||
00187 }
|
||||
00188
|
||||
00189 <span class="keywordflow">return</span> it->second; <span class="comment">// entry</span>
|
||||
00190 }
|
||||
00191
|
||||
00192 <span class="keywordtype">void</span> add(Sym sym) {
|
||||
00193 entry e = do_add(sym);
|
||||
00194 outputs.push_back(e);
|
||||
00195 }
|
||||
00196
|
||||
00197 };
|
||||
00198
|
||||
00199 <span class="keyword">class </span>MultiFunctionImpl {
|
||||
00200 <span class="keyword">public</span>:
|
||||
00201
|
||||
00202 <span class="comment">// input mapping</span>
|
||||
00203 vector<unsigned> input_idx;
|
||||
00204
|
||||
00205 <span class="keywordtype">unsigned</span> constant_offset;
|
||||
00206 <span class="keywordtype">unsigned</span> var_offset;
|
||||
00207
|
||||
00208 <span class="comment">// evaluation</span>
|
||||
00209 vector<double> data;
|
||||
00210 vector<Function> funcs;
|
||||
00211 data_ptrs args;
|
||||
00212
|
||||
00213 vector<unsigned> output_idx;
|
||||
00214
|
||||
00215 MultiFunctionImpl() {}
|
||||
00216
|
||||
00217 <span class="keywordtype">void</span> clear() {
|
||||
00218 input_idx.clear();
|
||||
00219 data.clear();
|
||||
00220 funcs.clear();
|
||||
00221 args.clear();
|
||||
00222 output_idx.clear();
|
||||
00223 constant_offset = 0;
|
||||
00224 }
|
||||
00225
|
||||
00226 <span class="keywordtype">void</span> eval(<span class="keyword">const</span> <span class="keywordtype">double</span>* x, <span class="keywordtype">double</span>* y) {
|
||||
00227 <span class="keywordtype">unsigned</span> i;
|
||||
00228 <span class="comment">// evaluate variables</span>
|
||||
00229 <span class="keywordflow">for</span> (i = constant_offset; i < constant_offset + input_idx.size(); ++i) {
|
||||
00230 data[i] = x[input_idx[i-constant_offset]];
|
||||
00231 }
|
||||
00232
|
||||
00233 <span class="keywordflow">for</span>(; i < data.size(); ++i) {
|
||||
00234 data[i] = funcs[i-var_offset]();
|
||||
00235 <span class="comment">//cout << i << " " << data[i] << endl;</span>
|
||||
00236 }
|
||||
00237
|
||||
00238 <span class="keywordflow">for</span> (i = 0; i < output_idx.size(); ++i) {
|
||||
00239 y[i] = data[output_idx[i]];
|
||||
00240 }
|
||||
00241 }
|
||||
00242
|
||||
00243 <span class="keywordtype">void</span> eval(<span class="keyword">const</span> vector<double>& x, vector<double>& y) {
|
||||
00244 eval(&x[0], &y[0]);
|
||||
00245 }
|
||||
00246
|
||||
00247 <span class="keywordtype">void</span> setup(<span class="keyword">const</span> vector<Sym>& pop) {
|
||||
00248
|
||||
00249 clear();
|
||||
00250 Compiler compiler;
|
||||
00251
|
||||
00252 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < pop.size(); ++i) {
|
||||
00253 Sym sym = (expand_all(pop[i]));
|
||||
00254 compiler.add(sym);
|
||||
00255 }
|
||||
00256
|
||||
00257 <span class="comment">// compiler is setup so get the data</span>
|
||||
00258 constant_offset = compiler.constants.size();
|
||||
00259 var_offset = constant_offset + compiler.variables.size();
|
||||
00260 <span class="keywordtype">int</span> n = var_offset + compiler.functions.size();
|
||||
00261
|
||||
00262 data.resize(n);
|
||||
00263 funcs.resize(compiler.functions.size());
|
||||
00264 args.resize(compiler.total_args);
|
||||
00265
|
||||
00266 <span class="comment">// constants</span>
|
||||
00267 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < constant_offset; ++i) {
|
||||
00268 data[i] = compiler.constants[i];
|
||||
00269 <span class="comment">//cout << i << ' ' << data[i] << endl;</span>
|
||||
00270 }
|
||||
00271
|
||||
00272 <span class="comment">// variables</span>
|
||||
00273 input_idx = compiler.variables;
|
||||
00274
|
||||
00275 <span class="comment">//for (unsigned i = constant_offset; i < var_offset; ++i) {</span>
|
||||
00276 <span class="comment">//cout << i << " x" << input_idx[i-constant_offset] << endl;</span>
|
||||
00277 <span class="comment">//}</span>
|
||||
00278
|
||||
00279 <span class="comment">// functions</span>
|
||||
00280 <span class="keywordtype">unsigned</span> which_arg = 0;
|
||||
00281 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < funcs.size(); ++i) {
|
||||
00282
|
||||
00283 Function f;
|
||||
00284 f.function = compiler.functions[i];
|
||||
00285
|
||||
00286 <span class="comment">//cout << i+var_offset << ' ' << print_function(f.function);</span>
|
||||
00287
|
||||
00288 <span class="comment">// interpret args</span>
|
||||
00289 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> j = 0; j < compiler.function_args[i].size(); ++j) {
|
||||
00290
|
||||
00291 Compiler::entry e = compiler.function_args[i][j];
|
||||
00292
|
||||
00293 <span class="keywordtype">unsigned</span> idx = e.second;
|
||||
00294
|
||||
00295 <span class="keywordflow">switch</span> (e.first) {
|
||||
00296 <span class="keywordflow">case</span> Compiler::function: idx += compiler.variables.size();
|
||||
00297 <span class="keywordflow">case</span> Compiler::variable: idx += compiler.constants.size();
|
||||
00298 <span class="keywordflow">case</span> Compiler::constant: {}
|
||||
00299 }
|
||||
00300
|
||||
00301 args[which_arg + j] = data.begin() + idx;
|
||||
00302 <span class="comment">//cout << ' ' << idx << "(" << e.second << ")";</span>
|
||||
00303 }
|
||||
00304
|
||||
00305 <span class="comment">//cout << endl;</span>
|
||||
00306
|
||||
00307 f.args = args.begin() + which_arg;
|
||||
00308 which_arg += compiler.function_args[i].size();
|
||||
00309 funcs[i] = f;
|
||||
00310 }
|
||||
00311
|
||||
00312 <span class="comment">// output indices</span>
|
||||
00313 output_idx.resize(compiler.outputs.size());
|
||||
00314 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < output_idx.size(); ++i) {
|
||||
00315 output_idx[i] = compiler.outputs[i].second;
|
||||
00316 <span class="keywordflow">switch</span>(compiler.outputs[i].first) {
|
||||
00317 <span class="keywordflow">case</span> Compiler::function: output_idx[i] += compiler.variables.size();
|
||||
00318 <span class="keywordflow">case</span> Compiler::variable: output_idx[i] += compiler.constants.size();
|
||||
00319 <span class="keywordflow">case</span> Compiler::constant: {}
|
||||
00320 }
|
||||
00321 <span class="comment">//cout << "out " << output_idx[i] << endl;</span>
|
||||
00322 }
|
||||
00323 }
|
||||
00324
|
||||
00325 };
|
||||
00326
|
||||
00327
|
||||
00328
|
||||
00329 MultiFunction::MultiFunction(<span class="keyword">const</span> std::vector<Sym>& pop) : pimpl(new MultiFunctionImpl) {
|
||||
00330 pimpl->setup(pop);
|
||||
00331 }
|
||||
00332
|
||||
00333 MultiFunction::~MultiFunction() { <span class="keyword">delete</span> pimpl; }
|
||||
00334
|
||||
00335 <span class="keywordtype">void</span> MultiFunction::operator()(<span class="keyword">const</span> std::vector<double>& x, std::vector<double>& y) {
|
||||
00336 pimpl->eval(x,y);
|
||||
00337 }
|
||||
00338
|
||||
00339 <span class="keywordtype">void</span> MultiFunction::operator()(<span class="keyword">const</span> <span class="keywordtype">double</span>* x, <span class="keywordtype">double</span>* y) {
|
||||
00340 pimpl->eval(x,y);
|
||||
00341 }
|
||||
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:41 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>
|
||||
41
trunk/paradiseo-eo/doc/html/_multi_function_8h-source.html
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
<!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: MultiFunction.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_000008.html">mathsym</a> / <a class="el" href="dir_000009.html">eval</a></div>
|
||||
<h1>MultiFunction.h</h1><div class="fragment"><pre class="fragment">00001 <span class="preprocessor">#ifndef MULTIFUNCTION_H_</span>
|
||||
00002 <span class="preprocessor"></span><span class="preprocessor">#define MULTIFUNCTION_H_</span>
|
||||
00003 <span class="preprocessor"></span>
|
||||
00004 <span class="preprocessor">#include <vector></span>
|
||||
00005
|
||||
00006 <span class="keyword">class </span>Sym;
|
||||
00007 <span class="keyword">class </span>MultiFunctionImpl;
|
||||
00008
|
||||
00009 <span class="keyword">class </span>MultiFunction {
|
||||
00010 MultiFunction& operator=(<span class="keyword">const</span> MultiFunction&);
|
||||
00011 MultiFunction(<span class="keyword">const</span> MultiFunction&);
|
||||
00012
|
||||
00013 MultiFunctionImpl* pimpl;
|
||||
00014
|
||||
00015 <span class="keyword">public</span>:
|
||||
00016
|
||||
00017 MultiFunction(<span class="keyword">const</span> std::vector<Sym>& pop);
|
||||
00018 ~MultiFunction();
|
||||
00019
|
||||
00020 <span class="keywordtype">void</span> operator()(<span class="keyword">const</span> std::vector<double>& x, std::vector<double>& y);
|
||||
00021 <span class="keywordtype">void</span> operator()(<span class="keyword">const</span> <span class="keywordtype">double</span>* x, <span class="keywordtype">double</span>* y);
|
||||
00022
|
||||
00023 };
|
||||
00024
|
||||
00025 <span class="preprocessor">#endif</span>
|
||||
00026 <span class="preprocessor"></span>
|
||||
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:41 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>
|
||||
181
trunk/paradiseo-eo/doc/html/_my_struct_e_a_8cpp-source.html
Normal file
|
|
@ -0,0 +1,181 @@
|
|||
<!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: MyStructEA.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_000003.html">tutorial</a> / <a class="el" href="dir_000026.html">Templates</a></div>
|
||||
<h1>MyStructEA.cpp</h1><div class="fragment"><pre class="fragment">00001
|
||||
00006 <span class="comment">/*</span>
|
||||
00007 <span class="comment">Template for creating a new representation in EO</span>
|
||||
00008 <span class="comment">================================================</span>
|
||||
00009 <span class="comment"></span>
|
||||
00010 <span class="comment">This is the template main file.</span>
|
||||
00011 <span class="comment">It includes all other files that have been generated by the script create.sh</span>
|
||||
00012 <span class="comment">so it is the only file to compile.</span>
|
||||
00013 <span class="comment"></span>
|
||||
00014 <span class="comment">In case you want to build up a separate library for your new Evolving Object,</span>
|
||||
00015 <span class="comment">you'll need some work - follow what's done in the src/ga dir, used in the</span>
|
||||
00016 <span class="comment">main file BitEA in tutorial/Lesson4 dir.</span>
|
||||
00017 <span class="comment">Or you can wait until we do it :-)</span>
|
||||
00018 <span class="comment">*/</span>
|
||||
00019
|
||||
00020 <span class="comment">// Miscilaneous include and declaration </span>
|
||||
00021 <span class="preprocessor">#include <iostream></span>
|
||||
00022 <span class="keyword">using</span> <span class="keyword">namespace </span>std;
|
||||
00023
|
||||
00024 <span class="comment">// eo general include</span>
|
||||
00025 <span class="preprocessor">#include "eo"</span>
|
||||
00026 <span class="comment">// the real bounds (not yet in general eo include)</span>
|
||||
00027 <span class="preprocessor">#include "utils/eoRealVectorBounds.h"</span>
|
||||
00028
|
||||
00029 <span class="comment">// include here whatever specific files for your representation</span>
|
||||
00030 <span class="comment">// Basically, this should include at least the following</span>
|
||||
00031
|
||||
00035 <span class="preprocessor">#include "eoMyStruct.h"</span>
|
||||
00036
|
||||
00040 <span class="preprocessor">#include "eoMyStructInit.h"</span>
|
||||
00041
|
||||
00047 <span class="preprocessor">#include "eoMyStructEvalFunc.h"</span>
|
||||
00048
|
||||
00049 <span class="comment">// GENOTYPE eoMyStruct ***MUST*** be templatized over the fitness</span>
|
||||
00050
|
||||
00051 <span class="comment">//*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*</span>
|
||||
00052 <span class="comment">// START fitness type: double or eoMaximizingFitness if you are maximizing</span>
|
||||
00053 <span class="comment">// eoMinimizingFitness if you are minimizing</span>
|
||||
00054 <span class="keyword">typedef</span> <a class="code" href="classeo_scalar_fitness.html">eoMinimizingFitness</a> <a class="code" href="classeo_scalar_fitness.html">MyFitT</a> ; <span class="comment">// type of fitness </span>
|
||||
00055 <span class="comment">// END fitness type</span>
|
||||
00056 <span class="comment">//*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*</span>
|
||||
00057
|
||||
00058 <span class="comment">// Then define your EO objects using that fitness type</span>
|
||||
00059 <span class="keyword">typedef</span> eoMyStruct<MyFitT> <a class="code" href="classeo_real.html">Indi</a>; <span class="comment">// ***MUST*** derive from EO </span>
|
||||
00060
|
||||
00061 <span class="comment">// create an initializer</span>
|
||||
00062 <span class="preprocessor">#include "make_genotype_MyStruct.h"</span>
|
||||
00063 <a class="code" href="classeo_init.html">eoInit<Indi></a> & make_genotype(eoParser& _parser, <a class="code" href="classeo_state.html">eoState</a>&_state, Indi _eo)
|
||||
00064 {
|
||||
00065 <span class="keywordflow">return</span> do_make_genotype(_parser, _state, _eo);
|
||||
00066 }
|
||||
00067
|
||||
00068 <span class="comment">// and the variation operaotrs</span>
|
||||
00069 <span class="preprocessor">#include "make_op_MyStruct.h"</span>
|
||||
00070 <a class="code" href="classeo_gen_op.html">eoGenOp<Indi></a>& make_op(eoParser& _parser, <a class="code" href="classeo_state.html">eoState</a>& _state, <a class="code" href="classeo_init.html">eoInit<Indi></a>& _init)
|
||||
00071 {
|
||||
00072 <span class="keywordflow">return</span> do_make_op(_parser, _state, _init);
|
||||
00073 }
|
||||
00074
|
||||
00075 <span class="comment">// Use existing modules to define representation independent routines</span>
|
||||
00076 <span class="comment">// These are parser-based definitions of objects</span>
|
||||
00077
|
||||
00078 <span class="comment">// how to initialize the population </span>
|
||||
00079 <span class="comment">// it IS representation independent if an eoInit is given</span>
|
||||
00080 <span class="preprocessor">#include <do/make_pop.h></span>
|
||||
00081 <a class="code" href="classeo_pop.html">eoPop<Indi ></a>& make_pop(eoParser& _parser, <a class="code" href="classeo_state.html">eoState</a>& _state, <a class="code" href="classeo_init.html">eoInit<Indi></a> & _init)
|
||||
00082 {
|
||||
00083 <span class="keywordflow">return</span> do_make_pop(_parser, _state, _init);
|
||||
00084 }
|
||||
00085
|
||||
00086 <span class="comment">// the stopping criterion</span>
|
||||
00087 <span class="preprocessor">#include <do/make_continue.h></span>
|
||||
00088 <a class="code" href="classeo_continue.html">eoContinue<Indi></a>& make_continue(eoParser& _parser, <a class="code" href="classeo_state.html">eoState</a>& _state, <a class="code" href="classeo_eval_func_counter.html">eoEvalFuncCounter<Indi></a> & _eval)
|
||||
00089 {
|
||||
00090 <span class="keywordflow">return</span> do_make_continue(_parser, _state, _eval);
|
||||
00091 }
|
||||
00092
|
||||
00093 <span class="comment">// outputs (stats, population dumps, ...)</span>
|
||||
00094 <span class="preprocessor">#include <do/make_checkpoint.h></span>
|
||||
00095 <a class="code" href="classeo_check_point.html">eoCheckPoint<Indi></a>& make_checkpoint(eoParser& _parser, <a class="code" href="classeo_state.html">eoState</a>& _state, <a class="code" href="classeo_eval_func_counter.html">eoEvalFuncCounter<Indi></a>& _eval, <a class="code" href="classeo_continue.html">eoContinue<Indi></a>& _continue)
|
||||
00096 {
|
||||
00097 <span class="keywordflow">return</span> do_make_checkpoint(_parser, _state, _eval, _continue);
|
||||
00098 }
|
||||
00099
|
||||
00100 <span class="comment">// evolution engine (selection and replacement)</span>
|
||||
00101 <span class="preprocessor">#include <do/make_algo_scalar.h></span>
|
||||
00102 <a class="code" href="classeo_algo.html">eoAlgo<Indi></a>& make_algo_scalar(eoParser& _parser, <a class="code" href="classeo_state.html">eoState</a>& _state, <a class="code" href="classeo_eval_func.html">eoEvalFunc<Indi></a>& _eval, <a class="code" href="classeo_continue.html">eoContinue<Indi></a>& _continue, <a class="code" href="classeo_gen_op.html">eoGenOp<Indi></a>& _op)
|
||||
00103 {
|
||||
00104 <span class="keywordflow">return</span> do_make_algo_scalar(_parser, _state, _eval, _continue, _op);
|
||||
00105 }
|
||||
00106
|
||||
00107 <span class="comment">// simple call to the algo. stays there for consistency reasons </span>
|
||||
00108 <span class="comment">// no template for that one</span>
|
||||
00109 <span class="preprocessor">#include <do/make_run.h></span>
|
||||
00110 <span class="comment">// the instanciating fitnesses</span>
|
||||
00111 <span class="preprocessor">#include <eoScalarFitness.h></span>
|
||||
00112 <span class="keywordtype">void</span> run_ea(<a class="code" href="classeo_algo.html">eoAlgo<Indi></a>& _ga, <a class="code" href="classeo_pop.html">eoPop<Indi></a>& _pop)
|
||||
00113 {
|
||||
00114 do_run(_ga, _pop);
|
||||
00115 }
|
||||
00116
|
||||
00117 <span class="comment">// checks for help demand, and writes the status file</span>
|
||||
00118 <span class="comment">// and make_help; in libutils</span>
|
||||
00119 <span class="keywordtype">void</span> make_help(eoParser & _parser);
|
||||
00120
|
||||
00121 <span class="comment">// now use all of the above, + representation dependent things</span>
|
||||
00122 <span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span>* argv[])
|
||||
00123 {
|
||||
00124
|
||||
00125 <span class="keywordflow">try</span>
|
||||
00126 {
|
||||
00127 eoParser parser(argc, argv); <span class="comment">// for user-parameter reading</span>
|
||||
00128
|
||||
00129 <a class="code" href="classeo_state.html">eoState</a> state; <span class="comment">// keeps all things allocated</span>
|
||||
00130
|
||||
00131 <span class="comment">// The fitness</span>
|
||||
00133 <span class="comment"></span> eoMyStructEvalFunc<Indi> plainEval<span class="comment">/* (varType _anyVariable) */</span>;
|
||||
00134 <span class="comment">// turn that object into an evaluation counter</span>
|
||||
00135 <a class="code" href="classeo_eval_func_counter.html">eoEvalFuncCounter<Indi></a> eval(plainEval);
|
||||
00136
|
||||
00137 <span class="comment">// the genotype - through a genotype initializer</span>
|
||||
00138 <a class="code" href="classeo_init.html">eoInit<Indi></a>& init = make_genotype(parser, state, Indi());
|
||||
00139
|
||||
00140 <span class="comment">// Build the variation operator (any seq/prop construct)</span>
|
||||
00141 <a class="code" href="classeo_gen_op.html">eoGenOp<Indi></a>& op = make_op(parser, state, init);
|
||||
00142
|
||||
00143
|
||||
00145 <span class="comment">//</span>
|
||||
00146 <span class="comment">// YOU SHOULD NOT NEED TO MODIFY ANYTHING BEYOND THIS POINT</span>
|
||||
00147 <span class="comment">// unless you want to add specific statistics to the checkpoint</span>
|
||||
00149 <span class="comment"></span>
|
||||
00150 <span class="comment">// initialize the population</span>
|
||||
00151 <span class="comment">// yes, this is representation indepedent once you have an eoInit</span>
|
||||
00152 <a class="code" href="classeo_pop.html">eoPop<Indi></a>& pop = make_pop(parser, state, init);
|
||||
00153
|
||||
00154 <span class="comment">// stopping criteria</span>
|
||||
00155 <a class="code" href="classeo_continue.html">eoContinue<Indi></a> & term = make_continue(parser, state, eval);
|
||||
00156 <span class="comment">// output</span>
|
||||
00157 <a class="code" href="classeo_check_point.html">eoCheckPoint<Indi></a> & checkpoint = make_checkpoint(parser, state, eval, term);
|
||||
00158 <span class="comment">// algorithm (need the operator!)</span>
|
||||
00159 <a class="code" href="classeo_algo.html">eoAlgo<Indi></a>& ga = make_algo_scalar(parser, state, eval, checkpoint, op);
|
||||
00160
|
||||
00162
|
||||
00164 <span class="comment">// to be called AFTER all parameters have been read!!!</span>
|
||||
00165 make_help(parser);
|
||||
00166
|
||||
00169 <span class="comment">// evaluate intial population AFTER help and status in case it takes time</span>
|
||||
00170 apply<Indi>(eval, pop);
|
||||
00171 <span class="comment">// if you want to print it out</span>
|
||||
00172 <span class="comment">// cout << "Initial Population\n";</span>
|
||||
00173 <span class="comment">// pop.sortedPrintOn(cout);</span>
|
||||
00174 <span class="comment">// cout << endl;</span>
|
||||
00175
|
||||
00176 run_ea(ga, pop); <span class="comment">// run the ga</span>
|
||||
00177
|
||||
00178 cout << <span class="stringliteral">"Final Population\n"</span>;
|
||||
00179 pop.<a class="code" href="classeo_pop.html#a17">sortedPrintOn</a>(cout);
|
||||
00180 cout << endl;
|
||||
00181
|
||||
00182 }
|
||||
00183 <span class="keywordflow">catch</span>(exception& e)
|
||||
00184 {
|
||||
00185 cout << e.what() << endl;
|
||||
00186 }
|
||||
00187 <span class="keywordflow">return</span> 0;
|
||||
00188 }
|
||||
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:41 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>
|
||||
155
trunk/paradiseo-eo/doc/html/_my_struct_lib_e_a_8cpp-source.html
Normal file
|
|
@ -0,0 +1,155 @@
|
|||
<!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: MyStructLibEA.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_000003.html">tutorial</a> / <a class="el" href="dir_000026.html">Templates</a></div>
|
||||
<h1>MyStructLibEA.cpp</h1><div class="fragment"><pre class="fragment">00001
|
||||
00006 <span class="comment">/*</span>
|
||||
00007 <span class="comment">Template for creating a new representation in EO</span>
|
||||
00008 <span class="comment">================================================</span>
|
||||
00009 <span class="comment"></span>
|
||||
00010 <span class="comment">This is the template main file for compiling after creating a</span>
|
||||
00011 <span class="comment">"library", i.e. putting everything but the fitness in a separate file </span>
|
||||
00012 <span class="comment">(make_MyStruct.cpp) and compiling it once and for all.</span>
|
||||
00013 <span class="comment">*/</span>
|
||||
00014
|
||||
00015 <span class="comment">// Miscilaneous include and declaration </span>
|
||||
00016 <span class="preprocessor">#include <iostream></span>
|
||||
00017 <span class="keyword">using</span> <span class="keyword">namespace </span>std;
|
||||
00018
|
||||
00019 <span class="comment">// eo general include</span>
|
||||
00020 <span class="preprocessor">#include "eo"</span>
|
||||
00021 <span class="comment">// the real bounds (not yet in general eo include)</span>
|
||||
00022 <span class="preprocessor">#include "utils/eoRealVectorBounds.h"</span>
|
||||
00023
|
||||
00024 <span class="comment">// include here whatever specific files for your representation</span>
|
||||
00025 <span class="comment">// Basically, this should include at least the following</span>
|
||||
00026
|
||||
00030 <span class="preprocessor">#include "eoMyStruct.h"</span>
|
||||
00031
|
||||
00035 <span class="preprocessor">#include "eoMyStructInit.h"</span>
|
||||
00036
|
||||
00042 <span class="preprocessor">#include "eoMyStructEvalFunc.h"</span>
|
||||
00043
|
||||
00044 <span class="comment">// GENOTYPE eoMyStruct ***MUST*** be templatized over the fitness</span>
|
||||
00045
|
||||
00046 <span class="comment">//</span>
|
||||
00047 <span class="comment">// START fitness type: double or eoMaximizingFitness if you are maximizing</span>
|
||||
00048 <span class="comment">// eoMinimizingFitness if you are minimizing</span>
|
||||
00049 <span class="keyword">typedef</span> <a class="code" href="classeo_scalar_fitness.html">eoMinimizingFitness</a> <a class="code" href="classeo_scalar_fitness.html">MyFitT</a> ; <span class="comment">// type of fitness </span>
|
||||
00050 <span class="comment">// END fitness type</span>
|
||||
00051 <span class="comment">//</span>
|
||||
00052
|
||||
00053 <span class="comment">// Then define your EO objects using that fitness type</span>
|
||||
00054 <span class="keyword">typedef</span> eoMyStruct<MyFitT> <a class="code" href="classeo_real.html">Indi</a>; <span class="comment">// ***MUST*** derive from EO </span>
|
||||
00055
|
||||
00056 <span class="comment">// create an initializer - done here and NOT in make_MyStruct.cpp</span>
|
||||
00057 <span class="comment">// because it is NOT representation independent</span>
|
||||
00058 <span class="preprocessor">#include "make_genotype_MyStruct.h"</span>
|
||||
00059 <a class="code" href="classeo_init.html">eoInit<Indi></a> & make_genotype(eoParser& _parser, <a class="code" href="classeo_state.html">eoState</a>&_state, Indi _eo)
|
||||
00060 {
|
||||
00061 <span class="keywordflow">return</span> do_make_genotype(_parser, _state, _eo);
|
||||
00062 }
|
||||
00063
|
||||
00064 <span class="comment">// same thing for the variation operaotrs</span>
|
||||
00065 <span class="preprocessor">#include "make_op_MyStruct.h"</span>
|
||||
00066 <a class="code" href="classeo_gen_op.html">eoGenOp<Indi></a>& make_op(eoParser& _parser, <a class="code" href="classeo_state.html">eoState</a>& _state, <a class="code" href="classeo_init.html">eoInit<Indi></a>& _init)
|
||||
00067 {
|
||||
00068 <span class="keywordflow">return</span> do_make_op(_parser, _state, _init);
|
||||
00069 }
|
||||
00070
|
||||
00071 <span class="comment">// The representation independent routines are simply declared here</span>
|
||||
00072
|
||||
00073 <span class="comment">// how to initialize the population </span>
|
||||
00074 <span class="comment">// it IS representation independent if an eoInit is given</span>
|
||||
00075 <a class="code" href="classeo_pop.html">eoPop<Indi ></a>& make_pop(eoParser& _parser, <a class="code" href="classeo_state.html">eoState</a>& _state, <a class="code" href="classeo_init.html">eoInit<Indi></a> & _init);
|
||||
00076
|
||||
00077 <span class="comment">// the stopping criterion</span>
|
||||
00078 <a class="code" href="classeo_continue.html">eoContinue<Indi></a>& make_continue(eoParser& _parser, <a class="code" href="classeo_state.html">eoState</a>& _state, <a class="code" href="classeo_eval_func_counter.html">eoEvalFuncCounter<Indi></a> & _eval);
|
||||
00079
|
||||
00080 <span class="comment">// outputs (stats, population dumps, ...)</span>
|
||||
00081 <a class="code" href="classeo_check_point.html">eoCheckPoint<Indi></a>& make_checkpoint(eoParser& _parser, <a class="code" href="classeo_state.html">eoState</a>& _state, <a class="code" href="classeo_eval_func_counter.html">eoEvalFuncCounter<Indi></a>& _eval, <a class="code" href="classeo_continue.html">eoContinue<Indi></a>& _continue);
|
||||
00082
|
||||
00083 <span class="comment">// evolution engine (selection and replacement)</span>
|
||||
00084 <a class="code" href="classeo_algo.html">eoAlgo<Indi></a>& make_algo_scalar(eoParser& _parser, <a class="code" href="classeo_state.html">eoState</a>& _state, <a class="code" href="classeo_eval_func.html">eoEvalFunc<Indi></a>& _eval, <a class="code" href="classeo_continue.html">eoContinue<Indi></a>& _continue, <a class="code" href="classeo_gen_op.html">eoGenOp<Indi></a>& _op);
|
||||
00085
|
||||
00086 <span class="comment">// simple call to the algo. stays there for consistency reasons </span>
|
||||
00087 <span class="comment">// no template for that one</span>
|
||||
00088 <span class="keywordtype">void</span> run_ea(<a class="code" href="classeo_algo.html">eoAlgo<Indi></a>& _ga, <a class="code" href="classeo_pop.html">eoPop<Indi></a>& _pop);
|
||||
00089
|
||||
00090 <span class="comment">// checks for help demand, and writes the status file</span>
|
||||
00091 <span class="comment">// and make_help; in libutils - just a declaration, code in libeoutils.a</span>
|
||||
00092 <span class="keywordtype">void</span> make_help(eoParser & _parser);
|
||||
00093
|
||||
00094 <span class="comment">// now use all of the above, + representation dependent things</span>
|
||||
00095 <span class="comment">// from here on, no difference with eoMyStruct.cpp</span>
|
||||
00096 <span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span>* argv[])
|
||||
00097 {
|
||||
00098
|
||||
00099 <span class="keywordflow">try</span>
|
||||
00100 {
|
||||
00101 eoParser parser(argc, argv); <span class="comment">// for user-parameter reading</span>
|
||||
00102
|
||||
00103 <a class="code" href="classeo_state.html">eoState</a> state; <span class="comment">// keeps all things allocated</span>
|
||||
00104
|
||||
00105 <span class="comment">// The fitness</span>
|
||||
00107 <span class="comment"></span> eoMyStructEvalFunc<Indi> plainEval<span class="comment">/* (varType _anyVariable) */</span>;
|
||||
00108 <span class="comment">// turn that object into an evaluation counter</span>
|
||||
00109 <a class="code" href="classeo_eval_func_counter.html">eoEvalFuncCounter<Indi></a> eval(plainEval);
|
||||
00110
|
||||
00111 <span class="comment">// the genotype - through a genotype initializer</span>
|
||||
00112 <a class="code" href="classeo_init.html">eoInit<Indi></a>& init = make_genotype(parser, state, Indi());
|
||||
00113
|
||||
00114 <span class="comment">// Build the variation operator (any seq/prop construct)</span>
|
||||
00115 <a class="code" href="classeo_gen_op.html">eoGenOp<Indi></a>& op = make_op(parser, state, init);
|
||||
00116
|
||||
00117
|
||||
00119 <span class="comment">//</span>
|
||||
00120 <span class="comment">// YOU SHOULD NOT NEED TO MODIFY ANYTHING BEYOND THIS POINT</span>
|
||||
00121 <span class="comment">// unless you want to add specific statistics to the checkpoint</span>
|
||||
00123 <span class="comment"></span>
|
||||
00124 <span class="comment">// initialize the population</span>
|
||||
00125 <span class="comment">// yes, this is representation indepedent once you have an eoInit</span>
|
||||
00126 <a class="code" href="classeo_pop.html">eoPop<Indi></a>& pop = make_pop(parser, state, init);
|
||||
00127
|
||||
00128 <span class="comment">// stopping criteria</span>
|
||||
00129 <a class="code" href="classeo_continue.html">eoContinue<Indi></a> & term = make_continue(parser, state, eval);
|
||||
00130 <span class="comment">// output</span>
|
||||
00131 <a class="code" href="classeo_check_point.html">eoCheckPoint<Indi></a> & checkpoint = make_checkpoint(parser, state, eval, term);
|
||||
00132 <span class="comment">// algorithm (need the operator!)</span>
|
||||
00133 <a class="code" href="classeo_algo.html">eoAlgo<Indi></a>& ga = make_algo_scalar(parser, state, eval, checkpoint, op);
|
||||
00134
|
||||
00136
|
||||
00138 <span class="comment">// to be called AFTER all parameters have been read!!!</span>
|
||||
00139 make_help(parser);
|
||||
00140
|
||||
00143 <span class="comment">// evaluate intial population AFTER help and status in case it takes time</span>
|
||||
00144 apply<Indi>(eval, pop);
|
||||
00145 <span class="comment">// if you want to print it out</span>
|
||||
00146 cout << <span class="stringliteral">"Initial Population\n"</span>;
|
||||
00147 pop.<a class="code" href="classeo_pop.html#a17">sortedPrintOn</a>(cout);
|
||||
00148 cout << endl;
|
||||
00149
|
||||
00150 run_ea(ga, pop); <span class="comment">// run the ga</span>
|
||||
00151
|
||||
00152 cout << <span class="stringliteral">"Final Population\n"</span>;
|
||||
00153 pop.<a class="code" href="classeo_pop.html#a17">sortedPrintOn</a>(cout);
|
||||
00154 cout << endl;
|
||||
00155
|
||||
00156 }
|
||||
00157 <span class="keywordflow">catch</span>(exception& e)
|
||||
00158 {
|
||||
00159 cout << e.what() << endl;
|
||||
00160 }
|
||||
00161 <span class="keywordflow">return</span> 0;
|
||||
00162 }
|
||||
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:41 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>
|
||||
338
trunk/paradiseo-eo/doc/html/_my_struct_s_e_a_8cpp-source.html
Normal file
|
|
@ -0,0 +1,338 @@
|
|||
<!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: MyStructSEA.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_000003.html">tutorial</a> / <a class="el" href="dir_000026.html">Templates</a></div>
|
||||
<h1>MyStructSEA.cpp</h1><div class="fragment"><pre class="fragment">00001
|
||||
00006 <span class="comment">/*</span>
|
||||
00007 <span class="comment">Template for creating a new representation in EO</span>
|
||||
00008 <span class="comment">================================================</span>
|
||||
00009 <span class="comment"></span>
|
||||
00010 <span class="comment">This is the template main file.</span>
|
||||
00011 <span class="comment">It includes all other files that have been generated by the script create.sh</span>
|
||||
00012 <span class="comment">so it is the only file to compile.</span>
|
||||
00013 <span class="comment"></span>
|
||||
00014 <span class="comment">In case you want to build up a separate library for your new Evolving Object,</span>
|
||||
00015 <span class="comment">you'll need some work - follow what's done in the src/ga dir, used in the</span>
|
||||
00016 <span class="comment">main file BitEA in tutorial/Lesson4 dir.</span>
|
||||
00017 <span class="comment">Or you can wait until we do it :-)</span>
|
||||
00018 <span class="comment">*/</span>
|
||||
00019
|
||||
00020 <span class="comment">// Miscilaneous include and declaration</span>
|
||||
00021 <span class="preprocessor">#include <iostream></span>
|
||||
00022 <span class="keyword">using</span> <span class="keyword">namespace </span>std;
|
||||
00023
|
||||
00024 <span class="comment">// eo general include</span>
|
||||
00025 <span class="preprocessor">#include "eo"</span>
|
||||
00026 <span class="comment">// the real bounds (not yet in general eo include)</span>
|
||||
00027 <span class="preprocessor">#include "utils/eoRealVectorBounds.h"</span>
|
||||
00028
|
||||
00029 <span class="comment">// include here whatever specific files for your representation</span>
|
||||
00030 <span class="comment">// Basically, this should include at least the following</span>
|
||||
00031
|
||||
00035 <span class="preprocessor">#include "eoMyStruct.h"</span>
|
||||
00036
|
||||
00040 <span class="preprocessor">#include "eoMyStructInit.h"</span>
|
||||
00041
|
||||
00047 <span class="preprocessor">#include "eoMyStructEvalFunc.h"</span>
|
||||
00048
|
||||
00053 <span class="preprocessor">#include "eoMyStructQuadCrossover.h"</span>
|
||||
00054 <span class="preprocessor">#include "eoMyStructMutation.h"</span>
|
||||
00055
|
||||
00056 <span class="comment">/* and (possibly) your personal statistics */</span>
|
||||
00057 <span class="preprocessor">#include "eoMyStructStat.h"</span>
|
||||
00058
|
||||
00059 <span class="comment">// GENOTYPE eoMyStruct ***MUST*** be templatized over the fitness</span>
|
||||
00060
|
||||
00061 <span class="comment">//*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*</span>
|
||||
00062 <span class="comment">// START fitness type: double or eoMaximizingFitness if you are maximizing</span>
|
||||
00063 <span class="comment">// eoMinimizingFitness if you are minimizing</span>
|
||||
00064 <span class="keyword">typedef</span> <a class="code" href="classeo_scalar_fitness.html">eoMinimizingFitness</a> <a class="code" href="classeo_scalar_fitness.html">MyFitT</a> ; <span class="comment">// type of fitness</span>
|
||||
00065 <span class="comment">// END fitness type</span>
|
||||
00066 <span class="comment">//*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*</span>
|
||||
00067
|
||||
00068 <span class="comment">// Then define your EO objects using that fitness type</span>
|
||||
00069 <span class="keyword">typedef</span> eoMyStruct<MyFitT> <a class="code" href="classeo_real.html">Indi</a>; <span class="comment">// ***MUST*** derive from EO</span>
|
||||
00070
|
||||
00071
|
||||
00072 <span class="comment">// Use existing modules to define representation independent routines</span>
|
||||
00073
|
||||
00074 <span class="comment">// how to initialize the population</span>
|
||||
00075 <span class="comment">// it IS representation independent if an eoInit is given</span>
|
||||
00076 <span class="preprocessor">#include <do/make_pop.h></span>
|
||||
00077 <a class="code" href="classeo_pop.html">eoPop<Indi ></a>& make_pop(eoParser& _parser, <a class="code" href="classeo_state.html">eoState</a>& _state, <a class="code" href="classeo_init.html">eoInit<Indi></a> & _init)
|
||||
00078 {
|
||||
00079 <span class="keywordflow">return</span> do_make_pop(_parser, _state, _init);
|
||||
00080 }
|
||||
00081
|
||||
00082 <span class="comment">// the stopping criterion</span>
|
||||
00083 <span class="preprocessor">#include <do/make_continue.h></span>
|
||||
00084 <a class="code" href="classeo_continue.html">eoContinue<Indi></a>& make_continue(eoParser& _parser, <a class="code" href="classeo_state.html">eoState</a>& _state, <a class="code" href="classeo_eval_func_counter.html">eoEvalFuncCounter<Indi></a> & _eval)
|
||||
00085 {
|
||||
00086 <span class="keywordflow">return</span> do_make_continue(_parser, _state, _eval);
|
||||
00087 }
|
||||
00088
|
||||
00089 <span class="comment">// outputs (stats, population dumps, ...)</span>
|
||||
00090 <span class="preprocessor">#include <do/make_checkpoint.h></span>
|
||||
00091 <a class="code" href="classeo_check_point.html">eoCheckPoint<Indi></a>& make_checkpoint(eoParser& _parser, <a class="code" href="classeo_state.html">eoState</a>& _state, <a class="code" href="classeo_eval_func_counter.html">eoEvalFuncCounter<Indi></a>& _eval, <a class="code" href="classeo_continue.html">eoContinue<Indi></a>& _continue)
|
||||
00092 {
|
||||
00093 <span class="keywordflow">return</span> do_make_checkpoint(_parser, _state, _eval, _continue);
|
||||
00094 }
|
||||
00095
|
||||
00096 <span class="comment">// evolution engine (selection and replacement)</span>
|
||||
00097 <span class="preprocessor">#include <do/make_algo_scalar.h></span>
|
||||
00098 <a class="code" href="classeo_algo.html">eoAlgo<Indi></a>& make_algo_scalar(eoParser& _parser, <a class="code" href="classeo_state.html">eoState</a>& _state, <a class="code" href="classeo_eval_func.html">eoEvalFunc<Indi></a>& _eval, <a class="code" href="classeo_continue.html">eoContinue<Indi></a>& _continue, <a class="code" href="classeo_gen_op.html">eoGenOp<Indi></a>& _op, <a class="code" href="classeo_distance.html">eoDistance<Indi></a> *_dist = NULL)
|
||||
00099 {
|
||||
00100 <span class="keywordflow">return</span> do_make_algo_scalar(_parser, _state, _eval, _continue, _op, _dist);
|
||||
00101 }
|
||||
00102
|
||||
00103 <span class="comment">// simple call to the algo. stays there for consistency reasons</span>
|
||||
00104 <span class="comment">// no template for that one</span>
|
||||
00105 <span class="preprocessor">#include <do/make_run.h></span>
|
||||
00106 <span class="comment">// the instanciating fitnesses</span>
|
||||
00107 <span class="preprocessor">#include <eoScalarFitness.h></span>
|
||||
00108 <span class="keywordtype">void</span> run_ea(<a class="code" href="classeo_algo.html">eoAlgo<Indi></a>& _ga, <a class="code" href="classeo_pop.html">eoPop<Indi></a>& _pop)
|
||||
00109 {
|
||||
00110 do_run(_ga, _pop);
|
||||
00111 }
|
||||
00112
|
||||
00113 <span class="comment">// checks for help demand, and writes the status file</span>
|
||||
00114 <span class="comment">// and make_help; in libutils</span>
|
||||
00115 <span class="keywordtype">void</span> make_help(eoParser & _parser);
|
||||
00116
|
||||
00117 <span class="comment">// now use all of the above, + representation dependent things</span>
|
||||
00118 <span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span>* argv[])
|
||||
00119 {
|
||||
00120 <span class="keywordflow">try</span>
|
||||
00121 {
|
||||
00122 eoParser parser(argc, argv); <span class="comment">// for user-parameter reading</span>
|
||||
00123
|
||||
00124 <a class="code" href="classeo_state.html">eoState</a> state; <span class="comment">// keeps all things allocated</span>
|
||||
00125
|
||||
00126 <span class="comment">// The fitness</span>
|
||||
00128 <span class="comment"></span> eoMyStructEvalFunc<Indi> plainEval<span class="comment">/* (varType _anyVariable) */</span>;
|
||||
00129 <span class="comment">// turn that object into an evaluation counter</span>
|
||||
00130 <a class="code" href="classeo_eval_func_counter.html">eoEvalFuncCounter<Indi></a> eval(plainEval);
|
||||
00131
|
||||
00132 <span class="comment">// a genotype initializer</span>
|
||||
00133 eoMyStructInit<Indi> init;
|
||||
00134 <span class="comment">// or, if you need some parameters, you might as well</span>
|
||||
00135 <span class="comment">// - write a constructor of the eoMyStructInit that uses a parser</span>
|
||||
00136 <span class="comment">// - call it from here:</span>
|
||||
00137 <span class="comment">// eoMyStructInit<Indi> init(parser);</span>
|
||||
00138
|
||||
00139 <span class="comment">// if you want to do sharing, you'll need a distance.</span>
|
||||
00140 <span class="comment">// see file utils/eoDistance.h</span>
|
||||
00141 <span class="comment">//</span>
|
||||
00142 <span class="comment">// IF you representation has an operator[]() double-castable,</span>
|
||||
00143 <span class="comment">// then you can use for instance the quadratic distance (L2 norm)</span>
|
||||
00144 <span class="comment">// eoQuadDistance<Indi> dist;</span>
|
||||
00145 <span class="comment">// or the Hamming distance (L1 norm)</span>
|
||||
00146 <span class="comment">// eoHammingDistance<Indi> dist;</span>
|
||||
00147
|
||||
00148
|
||||
00149 <span class="comment">// Build the variation operator (any seq/prop construct)</span>
|
||||
00150 <span class="comment">// here, a simple example with only 1 crossover (2->2, a QuadOp) and</span>
|
||||
00151 <span class="comment">// one mutation, is given.</span>
|
||||
00152 <span class="comment">// Hints to have choice among multiple crossovers and mutations are given</span>
|
||||
00153
|
||||
00154 <span class="comment">// A (first) crossover (possibly use the parser in its Ctor)</span>
|
||||
00155 eoMyStructQuadCrossover<Indi> cross <span class="comment">/* (eoParser parser) */</span>;
|
||||
00156
|
||||
00157 <span class="comment">// IF MORE THAN ONE:</span>
|
||||
00158
|
||||
00159 <span class="comment">// read its relative rate in the combination</span>
|
||||
00160 <span class="comment">// double cross1Rate = parser.createParam(1.0, "cross1Rate", "Relative rate for crossover 1", '1', "Variation Operators").value();</span>
|
||||
00161
|
||||
00162 <span class="comment">// create the combined operator with the first one (rename it cross1 !!!)</span>
|
||||
00163 <span class="comment">// eoPropCombinedQuadOp<Indi> cross(cross1, cross1Rate);</span>
|
||||
00164
|
||||
00165 <span class="comment">// and as many as you want the following way:</span>
|
||||
00166 <span class="comment">// 1- write the new class by mimicking eoMyStructQuadCrossover.h</span>
|
||||
00167 <span class="comment">// 2- include that file here together with eoMyStructQuadCrossover above</span>
|
||||
00168 <span class="comment">// 3- uncomment and duplicate the following lines:</span>
|
||||
00169 <span class="comment">//</span>
|
||||
00170 <span class="comment">// eoMyStructSecondCrossover<Indi> cross2(eoParser parser);</span>
|
||||
00171 <span class="comment">// double cross2Rate = parser.createParam(1.0, "cross2Rate", "Relative rate for crossover 2", '2', "Variation Operators").value();</span>
|
||||
00172 <span class="comment">// cross.add(cross2, cross2Rate);</span>
|
||||
00173
|
||||
00174 <span class="comment">// NOTE: if you want some gentle output, the last one shoudl be like</span>
|
||||
00175 <span class="comment">// cross.add(cross, crossXXXRate, true);</span>
|
||||
00176
|
||||
00178
|
||||
00179 <span class="comment">// a (first) mutation (possibly use the parser in its Ctor)</span>
|
||||
00180 eoMyStructMutation<Indi> mut <span class="comment">/* (parser) */</span>;
|
||||
00181
|
||||
00182 <span class="comment">// IF MORE THAN ONE:</span>
|
||||
00183
|
||||
00184 <span class="comment">// read its relative rate in the combination</span>
|
||||
00185 <span class="comment">// double mut1Rate = parser.createParam(1.0, "mut1Rate", "Relative rate for mutation 1", '1', "Variation Operators").value();</span>
|
||||
00186
|
||||
00187 <span class="comment">// create the combined operator with the first one (rename it cross1 !!!)</span>
|
||||
00188 <span class="comment">// eoPropCombinedMonOp<Indi> mut(mut1, mut1Rate);</span>
|
||||
00189
|
||||
00190 <span class="comment">// and as many as you want the following way:</span>
|
||||
00191 <span class="comment">// 1- write the new class by mimicking eoMyStructMutation.h</span>
|
||||
00192 <span class="comment">// 2- include that file here together with eoMyStructMutation above</span>
|
||||
00193 <span class="comment">// 3- uncomment and duplicate the following lines:</span>
|
||||
00194 <span class="comment">//</span>
|
||||
00195 <span class="comment">// eoMyStructSecondMutation<Indi> mut2(eoParser parser);</span>
|
||||
00196 <span class="comment">// double mut2Rate = parser.createParam(1.0, "mut2Rate", "Relative rate for mutation 2", '2', "Variation Operators").value();</span>
|
||||
00197 <span class="comment">// mut.add(mut2, mut2Rate);</span>
|
||||
00198
|
||||
00199 <span class="comment">// NOTE: if you want some gentle output, the last one shoudl be like</span>
|
||||
00200 <span class="comment">// mut.add(mut, mutXXXRate, true);</span>
|
||||
00201
|
||||
00202 <span class="comment">// now encapsulate your crossover(s) and mutation(s) into an eoGeneralOp</span>
|
||||
00203 <span class="comment">// so you can fully benefit of the existing evolution engines</span>
|
||||
00204
|
||||
00205 <span class="comment">// First read the individual level parameters</span>
|
||||
00206 <span class="keywordtype">double</span> pCross = parser.createParam(0.6, <span class="stringliteral">"pCross"</span>, <span class="stringliteral">"Probability of Crossover"</span>, <span class="charliteral">'C'</span>, <span class="stringliteral">"Variation Operators"</span> ).value();
|
||||
00207 <span class="comment">// minimum check</span>
|
||||
00208 <span class="keywordflow">if</span> ( (pCross < 0) || (pCross > 1) )
|
||||
00209 <span class="keywordflow">throw</span> runtime_error(<span class="stringliteral">"Invalid pCross"</span>);
|
||||
00210
|
||||
00211 <span class="keywordtype">double</span> pMut = parser.createParam(0.1, <span class="stringliteral">"pMut"</span>, <span class="stringliteral">"Probability of Mutation"</span>, <span class="charliteral">'M'</span>, <span class="stringliteral">"Variation Operators"</span> ).value();
|
||||
00212 <span class="comment">// minimum check</span>
|
||||
00213 <span class="keywordflow">if</span> ( (pMut < 0) || (pMut > 1) )
|
||||
00214 <span class="keywordflow">throw</span> runtime_error(<span class="stringliteral">"Invalid pMut"</span>);
|
||||
00215
|
||||
00216 <span class="comment">// now create the generalOp</span>
|
||||
00217 <a class="code" href="classeo_s_g_a_gen_op.html">eoSGAGenOp<Indi></a> op(cross, pCross, mut, pMut);
|
||||
00218
|
||||
00219
|
||||
00221 <span class="comment">//</span>
|
||||
00222 <span class="comment">// You do not need to modify anything beyond this point</span>
|
||||
00223 <span class="comment">// unless you want to add specific statistics to the checkpoint</span>
|
||||
00224 <span class="comment">// in which case you should uncomment the corresponding block</span>
|
||||
00225 <span class="comment">// and possibly modify the parameters in the stat object creation</span>
|
||||
00227 <span class="comment"></span>
|
||||
00228 <span class="comment">// initialize the population</span>
|
||||
00229 <span class="comment">// yes, this is representation indepedent once you have an eoInit</span>
|
||||
00230 <a class="code" href="classeo_pop.html">eoPop<Indi></a>& pop = make_pop(parser, state, init);
|
||||
00231
|
||||
00232 <span class="comment">// stopping criteria</span>
|
||||
00233 <a class="code" href="classeo_continue.html">eoContinue<Indi></a> & term = make_continue(parser, state, eval);
|
||||
00234 <span class="comment">// output</span>
|
||||
00235 <a class="code" href="classeo_check_point.html">eoCheckPoint<Indi></a> & checkpoint = make_checkpoint(parser, state, eval, term);
|
||||
00236
|
||||
00237
|
||||
00238 <span class="comment">// UNCOMMENT the following commented block if you want to add you stats</span>
|
||||
00239
|
||||
00240 <span class="comment">// if uncommented, it is assumed that you will want to print some stat.</span>
|
||||
00241 <span class="comment">// if not, then the following objects will be created uselessly - but what the heck!</span>
|
||||
00242
|
||||
00243 eoMyStructStat<Indi> myStat; <span class="comment">// or maybe myStat(parser);</span>
|
||||
00244 checkpoint.<a class="code" href="classeo_check_point.html#a2">add</a>(myStat);
|
||||
00245 <span class="comment">// This one is probably redundant with the one in make_checkpoint, but w.t.h.</span>
|
||||
00246 <a class="code" href="classeo_incrementor_param.html">eoIncrementorParam<unsigned></a> generationCounter(<span class="stringliteral">"Gen."</span>);
|
||||
00247 checkpoint.<a class="code" href="classeo_check_point.html#a2">add</a>(generationCounter);
|
||||
00248 <span class="comment">// need to get the name of the redDir param (if any)</span>
|
||||
00249 std::string dirName = parser.getORcreateParam(std::string(<span class="stringliteral">"Res"</span>), <span class="stringliteral">"resDir"</span>, <span class="stringliteral">"Directory to store DISK outputs"</span>, <span class="charliteral">'\0'</span>, <span class="stringliteral">"Output - Disk"</span>).value() + <span class="stringliteral">"/"</span>;
|
||||
00250
|
||||
00251
|
||||
00252 <span class="comment">// those need to be pointers because of the if's</span>
|
||||
00253 <a class="code" href="classeo_stdout_monitor.html">eoStdoutMonitor</a> *myStdOutMonitor;
|
||||
00254 <a class="code" href="classeo_file_monitor.html">eoFileMonitor</a> *myFileMonitor;
|
||||
00255 <span class="preprocessor">#ifdef HAVE_GNUPLOT</span>
|
||||
00256 <span class="preprocessor"></span> <a class="code" href="classeo_gnuplot1_d_monitor.html">eoGnuplot1DMonitor</a> *myGnuMonitor;
|
||||
00257 <span class="preprocessor">#endif</span>
|
||||
00258 <span class="preprocessor"></span>
|
||||
00259 <span class="comment">// now check how you want to output the stat:</span>
|
||||
00260 <span class="keywordtype">bool</span> printMyStructStat = parser.createParam(<span class="keyword">false</span>, <span class="stringliteral">"coutMyStructStat"</span>, <span class="stringliteral">"Prints my stat to screen, one line per generation"</span>, <span class="charliteral">'\0'</span>, <span class="stringliteral">"My application"</span>).value();
|
||||
00261 <span class="keywordtype">bool</span> fileMyStructStat = parser.createParam(<span class="keyword">false</span>, <span class="stringliteral">"fileMyStructStat"</span>, <span class="stringliteral">"Saves my stat to file (in resDir"</span>, <span class="charliteral">'\0'</span>, <span class="stringliteral">"My application"</span>).value();
|
||||
00262 <span class="keywordtype">bool</span> plotMyStructStat = parser.createParam(<span class="keyword">false</span>, <span class="stringliteral">"plotMyStructStat"</span>, <span class="stringliteral">"On-line plots my stat using gnuplot"</span>, <span class="charliteral">'\0'</span>, <span class="stringliteral">"My application"</span>).value();
|
||||
00263
|
||||
00264 <span class="comment">// should we write it on StdOut ?</span>
|
||||
00265 <span class="keywordflow">if</span> (printMyStructStat)
|
||||
00266 {
|
||||
00267 myStdOutMonitor = <span class="keyword">new</span> <a class="code" href="classeo_stdout_monitor.html">eoStdoutMonitor</a>(<span class="keyword">false</span>);
|
||||
00268 <span class="comment">// don't forget to store the memory in the state</span>
|
||||
00269 state.<a class="code" href="classeo_functor_store.html#a2">storeFunctor</a>(myStdOutMonitor);
|
||||
00270 <span class="comment">// and of course to add the monitor to the checkpoint</span>
|
||||
00271 checkpoint.<a class="code" href="classeo_check_point.html#a2">add</a>(*myStdOutMonitor);
|
||||
00272 <span class="comment">// and the different fields to the monitor</span>
|
||||
00273 myStdOutMonitor-><a class="code" href="classeo_monitor.html#a1">add</a>(generationCounter);
|
||||
00274 myStdOutMonitor-><a class="code" href="classeo_monitor.html#a1">add</a>(eval);
|
||||
00275 myStdOutMonitor-><a class="code" href="classeo_monitor.html#a1">add</a>(myStat);
|
||||
00276 }
|
||||
00277
|
||||
00278 <span class="comment">// first check the directory (and creates it if not exists already):</span>
|
||||
00279 <span class="keywordflow">if</span> (fileMyStructStat || plotMyStructStat)
|
||||
00280 <span class="keywordflow">if</span> (! testDirRes(dirName, <span class="keyword">true</span>) )
|
||||
00281 <span class="keywordflow">throw</span> runtime_error(<span class="stringliteral">"Problem with resDir"</span>);
|
||||
00282
|
||||
00283 <span class="comment">// should we write it to a file ?</span>
|
||||
00284 <span class="keywordflow">if</span> (fileMyStructStat)
|
||||
00285 {
|
||||
00286 <span class="comment">// the file name is hard-coded - of course you can read</span>
|
||||
00287 <span class="comment">// a string parameter in the parser if you prefer</span>
|
||||
00288 myFileMonitor = <span class="keyword">new</span> <a class="code" href="classeo_file_monitor.html">eoFileMonitor</a>(dirName + <span class="stringliteral">"myStat.xg"</span>);
|
||||
00289 <span class="comment">// don't forget to store the memory in the state</span>
|
||||
00290 state.<a class="code" href="classeo_functor_store.html#a2">storeFunctor</a>(myFileMonitor);
|
||||
00291 <span class="comment">// and of course to add the monitor to the checkpoint</span>
|
||||
00292 checkpoint.<a class="code" href="classeo_check_point.html#a2">add</a>(*myFileMonitor);
|
||||
00293 <span class="comment">// and the different fields to the monitor</span>
|
||||
00294 myFileMonitor-><a class="code" href="classeo_monitor.html#a1">add</a>(generationCounter);
|
||||
00295 myFileMonitor-><a class="code" href="classeo_monitor.html#a1">add</a>(eval);
|
||||
00296 myFileMonitor-><a class="code" href="classeo_monitor.html#a1">add</a>(myStat);
|
||||
00297 }
|
||||
00298
|
||||
00299 <span class="preprocessor">#ifdef HAVE_GNUPLOT</span>
|
||||
00300 <span class="preprocessor"></span> <span class="comment">// should we PLOT it on StdOut ? (one dot per generation, incremental plot)</span>
|
||||
00301 <span class="keywordflow">if</span> (plotMyStructStat)
|
||||
00302 {
|
||||
00303 myGnuMonitor = <span class="keyword">new</span> <a class="code" href="classeo_gnuplot1_d_monitor.html">eoGnuplot1DMonitor</a>(dirName+<span class="stringliteral">"plot_myStat.xg"</span>,minimizing_fitness<Indi>());
|
||||
00304 <span class="comment">// NOTE: you cand send commands to gnuplot at any time with the method</span>
|
||||
00305 <span class="comment">// myGnuMonitor->gnuplotCommand(string)</span>
|
||||
00306 <span class="comment">// par exemple, gnuplotCommand("set logscale y")</span>
|
||||
00307
|
||||
00308 <span class="comment">// don't forget to store the memory in the state</span>
|
||||
00309 state.<a class="code" href="classeo_functor_store.html#a2">storeFunctor</a>(myGnuMonitor);
|
||||
00310 <span class="comment">// and of course to add the monitor to the checkpoint</span>
|
||||
00311 checkpoint.<a class="code" href="classeo_check_point.html#a2">add</a>(*myGnuMonitor);
|
||||
00312 <span class="comment">// and the different fields to the monitor (X = eval, Y = myStat)</span>
|
||||
00313 myGnuMonitor-><a class="code" href="classeo_monitor.html#a1">add</a>(eval);
|
||||
00314 myGnuMonitor-><a class="code" href="classeo_monitor.html#a1">add</a>(myStat);
|
||||
00315 }
|
||||
00316 <span class="preprocessor">#endif</span>
|
||||
00317 <span class="preprocessor"></span>
|
||||
00318 <span class="comment">// algorithm (need the operator!)</span>
|
||||
00319 <a class="code" href="classeo_algo.html">eoAlgo<Indi></a>& ga = make_algo_scalar(parser, state, eval, checkpoint, op);
|
||||
00320 <span class="comment">// and the distance if you want to do sharing</span>
|
||||
00321 <span class="comment">// eoAlgo<Indi>& ga = make_algo_scalar(parser, state, eval, checkpoint, op, &dist);</span>
|
||||
00322
|
||||
00324
|
||||
00326 <span class="comment">// to be called AFTER all parameters have been read!!!</span>
|
||||
00327 make_help(parser);
|
||||
00328
|
||||
00331 <span class="comment">// evaluate intial population AFTER help and status in case it takes time</span>
|
||||
00332 apply<Indi>(eval, pop);
|
||||
00333 <span class="comment">// if you want to print it out</span>
|
||||
00334 <span class="comment">// cout << "Initial Population\n";</span>
|
||||
00335 <span class="comment">// pop.sortedPrintOn(cout);</span>
|
||||
00336 <span class="comment">// cout << endl;</span>
|
||||
00337
|
||||
00338 run_ea(ga, pop); <span class="comment">// run the ga</span>
|
||||
00339
|
||||
00340 cout << <span class="stringliteral">"Final Population\n"</span>;
|
||||
00341 pop.<a class="code" href="classeo_pop.html#a17">sortedPrintOn</a>(cout);
|
||||
00342 cout << endl;
|
||||
00343
|
||||
00344 }
|
||||
00345 <span class="keywordflow">catch</span>(exception& e)
|
||||
00346 {
|
||||
00347 cout << e.what() << endl;
|
||||
00348 }
|
||||
00349 <span class="keywordflow">return</span> 0;
|
||||
00350 }
|
||||
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:41 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>
|
||||
30
trunk/paradiseo-eo/doc/html/_n_e_w_s-source.html
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
<!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: NEWS 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>
|
||||
<h1>NEWS</h1><div class="fragment"><pre class="fragment">00001 * release 0.9.4 (not yet released)
|
||||
00002 - Update introductory pages of documentation and webpage.
|
||||
00003 - Remove support <span class="keywordflow">for</span> pre-standard C++ compiler (i.e. gcc-2.x), which allows to
|
||||
00004 clean up the code considerably. Assume availability of sstream and limits.
|
||||
00005 - Implement CMA-ES.
|
||||
00006
|
||||
00007
|
||||
00008 * release 0.9.3z.1 (1. Oct. 2005)
|
||||
00009 - Support gcc-3.4 and gcc.4.x.
|
||||
00010 - Provide full automake/autoconf/configure support.
|
||||
00011
|
||||
00012
|
||||
00013 # Local Variables:
|
||||
00014 <span class="preprocessor"># coding: iso-8859-1</span>
|
||||
00015 <span class="preprocessor"></span><span class="preprocessor"># mode: text</span>
|
||||
00016 <span class="preprocessor"></span><span class="preprocessor"># fill-column: 80</span>
|
||||
00017 <span class="preprocessor"></span><span class="preprocessor"># End:</span>
|
||||
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:41 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>
|
||||
65
trunk/paradiseo-eo/doc/html/_node_selector_8cpp-source.html
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
<!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: NodeSelector.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_000007.html">contrib</a> / <a class="el" href="dir_000008.html">mathsym</a> / <a class="el" href="dir_000024.html">gen</a></div>
|
||||
<h1>NodeSelector.cpp</h1><div class="fragment"><pre class="fragment">00001 <span class="comment">/* </span>
|
||||
00002 <span class="comment"> * Copyright (C) 2005 Maarten Keijzer</span>
|
||||
00003 <span class="comment"> *</span>
|
||||
00004 <span class="comment"> * This program is free software; you can redistribute it and/or modify</span>
|
||||
00005 <span class="comment"> * it under the terms of version 2 of the GNU General Public License as </span>
|
||||
00006 <span class="comment"> * published by the Free Software Foundation. </span>
|
||||
00007 <span class="comment"> *</span>
|
||||
00008 <span class="comment"> * This program is distributed in the hope that it will be useful,</span>
|
||||
00009 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
|
||||
00010 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
|
||||
00011 <span class="comment"> * GNU General Public License for more details.</span>
|
||||
00012 <span class="comment"> *</span>
|
||||
00013 <span class="comment"> * You should have received a copy of the GNU General Public License</span>
|
||||
00014 <span class="comment"> * along with this program; if not, write to the Free Software</span>
|
||||
00015 <span class="comment"> * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>
|
||||
00016 <span class="comment"> */</span>
|
||||
00017
|
||||
00018 <span class="preprocessor">#include "NodeSelector.h"</span>
|
||||
00019 <span class="preprocessor">#include "Sym.h"</span>
|
||||
00020
|
||||
00021 <span class="preprocessor">#include <utils/eoRNG.h></span>
|
||||
00022
|
||||
00023 <span class="comment">// If subtree is not set (by randomnodeselector for instance, find it now</span>
|
||||
00024 Sym NodeSelector::NodeSelection::subtree() {
|
||||
00025 <span class="keywordflow">if</span> (subtree_.empty()) {
|
||||
00026 subtree_ = get_subtree(root_, subtree_index_);
|
||||
00027 }
|
||||
00028 <span class="keywordflow">return</span> subtree_;
|
||||
00029 }
|
||||
00030
|
||||
00031 NodeSelector::NodeSelection RandomNodeSelector::select_node(Sym sym)<span class="keyword"> const </span>{
|
||||
00032 <span class="keywordtype">unsigned</span> idx = rng.<a class="code" href="classeo_rng.html#a5">random</a>(sym.size());
|
||||
00033 <span class="keywordflow">return</span> NodeSelection(sym, idx, Sym() ); <span class="comment">// empty subtree, find it when needed</span>
|
||||
00034 }
|
||||
00035
|
||||
00036 NodeSelector::NodeSelection BiasedNodeSelector::select_node(Sym sym)<span class="keyword"> const </span>{
|
||||
00037
|
||||
00038 <span class="keywordtype">unsigned</span> p = rng.<a class="code" href="classeo_rng.html#a5">random</a>(sym.size());
|
||||
00039 Sym res;
|
||||
00040 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < nRounds; ++i) {
|
||||
00041 res = get_subtree(sym, p);
|
||||
00042
|
||||
00043 <span class="keywordflow">if</span> (res.args().size() > 0) <span class="keywordflow">break</span>;
|
||||
00044
|
||||
00045 p = rng.<a class="code" href="classeo_rng.html#a5">random</a>(sym.size());
|
||||
00046 }
|
||||
00047
|
||||
00048 <span class="keywordflow">return</span> NodeSelection(sym, p, res);
|
||||
00049 }
|
||||
00050
|
||||
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:41 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>
|
||||
77
trunk/paradiseo-eo/doc/html/_node_selector_8h-source.html
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
<!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: NodeSelector.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_000008.html">mathsym</a> / <a class="el" href="dir_000024.html">gen</a></div>
|
||||
<h1>NodeSelector.h</h1><div class="fragment"><pre class="fragment">00001 <span class="comment">/* </span>
|
||||
00002 <span class="comment"> * Copyright (C) 2005 Maarten Keijzer</span>
|
||||
00003 <span class="comment"> *</span>
|
||||
00004 <span class="comment"> * This program is free software; you can redistribute it and/or modify</span>
|
||||
00005 <span class="comment"> * it under the terms of version 2 of the GNU General Public License as </span>
|
||||
00006 <span class="comment"> * published by the Free Software Foundation. </span>
|
||||
00007 <span class="comment"> *</span>
|
||||
00008 <span class="comment"> * This program is distributed in the hope that it will be useful,</span>
|
||||
00009 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
|
||||
00010 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
|
||||
00011 <span class="comment"> * GNU General Public License for more details.</span>
|
||||
00012 <span class="comment"> *</span>
|
||||
00013 <span class="comment"> * You should have received a copy of the GNU General Public License</span>
|
||||
00014 <span class="comment"> * along with this program; if not, write to the Free Software</span>
|
||||
00015 <span class="comment"> * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>
|
||||
00016 <span class="comment"> */</span>
|
||||
00017
|
||||
00018 <span class="preprocessor">#ifndef NODESELECTOR_H</span>
|
||||
00019 <span class="preprocessor"></span><span class="preprocessor">#define NODESELECTOR_H</span>
|
||||
00020 <span class="preprocessor"></span>
|
||||
00021 <span class="preprocessor">#include <Sym.h></span>
|
||||
00022
|
||||
<a name="l00024"></a><a class="code" href="class_node_selector.html">00024</a> <span class="keyword">class </span><a class="code" href="class_node_selector.html">NodeSelector</a> {
|
||||
00025 <span class="keyword">public</span>:
|
||||
00026
|
||||
00027 <span class="keyword">class </span>NodeSelection {
|
||||
00028 Sym root_;
|
||||
00029 <span class="keywordtype">unsigned</span> subtree_index_;
|
||||
00030 Sym subtree_;
|
||||
00031
|
||||
00032 <span class="keyword">public</span> :
|
||||
00033 NodeSelection(Sym r, <span class="keywordtype">unsigned</span> idx, Sym s)
|
||||
00034 : root_(r), subtree_index_(idx), subtree_(s) {}
|
||||
00035
|
||||
00036 Sym root()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> root_; }
|
||||
00037 <span class="keywordtype">unsigned</span> idx()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> subtree_index_; }
|
||||
00038 Sym subtree();
|
||||
00039
|
||||
00040 };
|
||||
00041
|
||||
00042 <span class="keyword">virtual</span> ~<a class="code" href="class_node_selector.html">NodeSelector</a>() {}
|
||||
00043
|
||||
00044 <span class="keyword">virtual</span> NodeSelection select_node(Sym sym) <span class="keyword">const </span>= 0;
|
||||
00045 };
|
||||
00046
|
||||
00047
|
||||
<a name="l00049"></a><a class="code" href="class_random_node_selector.html">00049</a> <span class="keyword">class </span><a class="code" href="class_random_node_selector.html">RandomNodeSelector</a> : <span class="keyword">public</span> <a class="code" href="class_node_selector.html">NodeSelector</a> {
|
||||
00050 <span class="keyword">public</span>:
|
||||
00051 NodeSelection select_node(Sym sym) <span class="keyword">const</span>;
|
||||
00052 };
|
||||
00053
|
||||
<a name="l00055"></a><a class="code" href="class_biased_node_selector.html">00055</a> <span class="keyword">class </span><a class="code" href="class_biased_node_selector.html">BiasedNodeSelector</a> : <span class="keyword">public</span> <a class="code" href="class_node_selector.html">NodeSelector</a> {
|
||||
00056 <span class="keyword">public</span>:
|
||||
00057 <span class="keywordtype">unsigned</span> nRounds;
|
||||
00058
|
||||
00059 <a class="code" href="class_biased_node_selector.html">BiasedNodeSelector</a>() : nRounds(3) {} <span class="comment">// 3: for binary trees 87.5% chance of selecting an internal node</span>
|
||||
00060 <a class="code" href="class_biased_node_selector.html">BiasedNodeSelector</a>(<span class="keywordtype">unsigned</span> n) : nRounds(n) {}
|
||||
00061
|
||||
00062 NodeSelection select_node(Sym sym) <span class="keyword">const</span>;
|
||||
00063 };
|
||||
00064
|
||||
00065 <span class="preprocessor">#endif</span>
|
||||
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:41 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>
|
||||
181
trunk/paradiseo-eo/doc/html/_one_max_e_a_8cpp-source.html
Normal file
|
|
@ -0,0 +1,181 @@
|
|||
<!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: OneMaxEA.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_000003.html">tutorial</a> / <a class="el" href="dir_000016.html">Lesson5</a></div>
|
||||
<h1>OneMaxEA.cpp</h1><div class="fragment"><pre class="fragment">00001
|
||||
00006 <span class="comment">/*</span>
|
||||
00007 <span class="comment">Template for creating a new representation in EO</span>
|
||||
00008 <span class="comment">================================================</span>
|
||||
00009 <span class="comment"></span>
|
||||
00010 <span class="comment">This is the template main file.</span>
|
||||
00011 <span class="comment">It includes all other files that have been generated by the script create.sh</span>
|
||||
00012 <span class="comment">so it is the only file to compile.</span>
|
||||
00013 <span class="comment"></span>
|
||||
00014 <span class="comment">In case you want to build up a separate library for your new Evolving Object,</span>
|
||||
00015 <span class="comment">you'll need some work - follow what's done in the src/ga dir, used in the</span>
|
||||
00016 <span class="comment">main file BitEA in tutorial/Lesson4 dir.</span>
|
||||
00017 <span class="comment">Or you can wait until we do it :-)</span>
|
||||
00018 <span class="comment">*/</span>
|
||||
00019
|
||||
00020 <span class="comment">// Miscilaneous include and declaration </span>
|
||||
00021 <span class="preprocessor">#include <iostream></span>
|
||||
00022 <span class="keyword">using</span> <span class="keyword">namespace </span>std;
|
||||
00023
|
||||
00024 <span class="comment">// eo general include</span>
|
||||
00025 <span class="preprocessor">#include "eo"</span>
|
||||
00026 <span class="comment">// the real bounds (not yet in general eo include)</span>
|
||||
00027 <span class="preprocessor">#include "utils/eoRealVectorBounds.h"</span>
|
||||
00028
|
||||
00029 <span class="comment">// include here whatever specific files for your representation</span>
|
||||
00030 <span class="comment">// Basically, this should include at least the following</span>
|
||||
00031
|
||||
00035 <span class="preprocessor">#include "eoOneMax.h"</span>
|
||||
00036
|
||||
00040 <span class="preprocessor">#include "eoOneMaxInit.h"</span>
|
||||
00041
|
||||
00047 <span class="preprocessor">#include "eoOneMaxEvalFunc.h"</span>
|
||||
00048
|
||||
00049 <span class="comment">// GENOTYPE eoOneMax ***MUST*** be templatized over the fitness</span>
|
||||
00050
|
||||
00051 <span class="comment">//*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*</span>
|
||||
00052 <span class="comment">// START fitness type: double or eoMaximizingFitness if you are maximizing</span>
|
||||
00053 <span class="comment">// eoMinimizingFitness if you are minimizing</span>
|
||||
00054 <span class="keyword">typedef</span> <a class="code" href="classeo_scalar_fitness.html">eoMaximizingFitness</a> <a class="code" href="classeo_scalar_fitness.html">MyFitT</a> ; <span class="comment">// type of fitness </span>
|
||||
00055 <span class="comment">// END fitness type</span>
|
||||
00056 <span class="comment">//*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*</span>
|
||||
00057
|
||||
00058 <span class="comment">// Then define your EO objects using that fitness type</span>
|
||||
00059 <span class="keyword">typedef</span> <a class="code" href="classeo_one_max.html">eoOneMax<MyFitT></a> <a class="code" href="classeo_real.html">Indi</a>; <span class="comment">// ***MUST*** derive from EO </span>
|
||||
00060
|
||||
00061 <span class="comment">// create an initializer</span>
|
||||
00062 <span class="preprocessor">#include "make_genotype_OneMax.h"</span>
|
||||
00063 <a class="code" href="classeo_init.html">eoInit<Indi></a> & make_genotype(eoParser& _parser, <a class="code" href="classeo_state.html">eoState</a>&_state, Indi _eo)
|
||||
00064 {
|
||||
00065 <span class="keywordflow">return</span> do_make_genotype(_parser, _state, _eo);
|
||||
00066 }
|
||||
00067
|
||||
00068 <span class="comment">// and the variation operaotrs</span>
|
||||
00069 <span class="preprocessor">#include "make_op_OneMax.h"</span>
|
||||
00070 <a class="code" href="classeo_gen_op.html">eoGenOp<Indi></a>& make_op(eoParser& _parser, <a class="code" href="classeo_state.html">eoState</a>& _state, <a class="code" href="classeo_init.html">eoInit<Indi></a>& _init)
|
||||
00071 {
|
||||
00072 <span class="keywordflow">return</span> do_make_op(_parser, _state, _init);
|
||||
00073 }
|
||||
00074
|
||||
00075 <span class="comment">// Use existing modules to define representation independent routines</span>
|
||||
00076 <span class="comment">// These are parser-based definitions of objects</span>
|
||||
00077
|
||||
00078 <span class="comment">// how to initialize the population </span>
|
||||
00079 <span class="comment">// it IS representation independent if an eoInit is given</span>
|
||||
00080 <span class="preprocessor">#include <do/make_pop.h></span>
|
||||
00081 <a class="code" href="classeo_pop.html">eoPop<Indi ></a>& make_pop(eoParser& _parser, <a class="code" href="classeo_state.html">eoState</a>& _state, <a class="code" href="classeo_init.html">eoInit<Indi></a> & _init)
|
||||
00082 {
|
||||
00083 <span class="keywordflow">return</span> do_make_pop(_parser, _state, _init);
|
||||
00084 }
|
||||
00085
|
||||
00086 <span class="comment">// the stopping criterion</span>
|
||||
00087 <span class="preprocessor">#include <do/make_continue.h></span>
|
||||
00088 <a class="code" href="classeo_continue.html">eoContinue<Indi></a>& make_continue(eoParser& _parser, <a class="code" href="classeo_state.html">eoState</a>& _state, <a class="code" href="classeo_eval_func_counter.html">eoEvalFuncCounter<Indi></a> & _eval)
|
||||
00089 {
|
||||
00090 <span class="keywordflow">return</span> do_make_continue(_parser, _state, _eval);
|
||||
00091 }
|
||||
00092
|
||||
00093 <span class="comment">// outputs (stats, population dumps, ...)</span>
|
||||
00094 <span class="preprocessor">#include <do/make_checkpoint.h></span>
|
||||
00095 <a class="code" href="classeo_check_point.html">eoCheckPoint<Indi></a>& make_checkpoint(eoParser& _parser, <a class="code" href="classeo_state.html">eoState</a>& _state, <a class="code" href="classeo_eval_func_counter.html">eoEvalFuncCounter<Indi></a>& _eval, <a class="code" href="classeo_continue.html">eoContinue<Indi></a>& _continue)
|
||||
00096 {
|
||||
00097 <span class="keywordflow">return</span> do_make_checkpoint(_parser, _state, _eval, _continue);
|
||||
00098 }
|
||||
00099
|
||||
00100 <span class="comment">// evolution engine (selection and replacement)</span>
|
||||
00101 <span class="preprocessor">#include <do/make_algo_scalar.h></span>
|
||||
00102 <a class="code" href="classeo_algo.html">eoAlgo<Indi></a>& make_algo_scalar(eoParser& _parser, <a class="code" href="classeo_state.html">eoState</a>& _state, <a class="code" href="classeo_eval_func.html">eoEvalFunc<Indi></a>& _eval, <a class="code" href="classeo_continue.html">eoContinue<Indi></a>& _continue, <a class="code" href="classeo_gen_op.html">eoGenOp<Indi></a>& _op)
|
||||
00103 {
|
||||
00104 <span class="keywordflow">return</span> do_make_algo_scalar(_parser, _state, _eval, _continue, _op);
|
||||
00105 }
|
||||
00106
|
||||
00107 <span class="comment">// simple call to the algo. stays there for consistency reasons </span>
|
||||
00108 <span class="comment">// no template for that one</span>
|
||||
00109 <span class="preprocessor">#include <do/make_run.h></span>
|
||||
00110 <span class="comment">// the instanciating fitnesses</span>
|
||||
00111 <span class="preprocessor">#include <eoScalarFitness.h></span>
|
||||
00112 <span class="keywordtype">void</span> run_ea(<a class="code" href="classeo_algo.html">eoAlgo<Indi></a>& _ga, <a class="code" href="classeo_pop.html">eoPop<Indi></a>& _pop)
|
||||
00113 {
|
||||
00114 do_run(_ga, _pop);
|
||||
00115 }
|
||||
00116
|
||||
00117 <span class="comment">// checks for help demand, and writes the status file</span>
|
||||
00118 <span class="comment">// and make_help; in libutils</span>
|
||||
00119 <span class="keywordtype">void</span> make_help(eoParser & _parser);
|
||||
00120
|
||||
00121 <span class="comment">// now use all of the above, + representation dependent things</span>
|
||||
00122 <span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span>* argv[])
|
||||
00123 {
|
||||
00124
|
||||
00125 <span class="keywordflow">try</span>
|
||||
00126 {
|
||||
00127 eoParser parser(argc, argv); <span class="comment">// for user-parameter reading</span>
|
||||
00128
|
||||
00129 <a class="code" href="classeo_state.html">eoState</a> state; <span class="comment">// keeps all things allocated</span>
|
||||
00130
|
||||
00131 <span class="comment">// The fitness</span>
|
||||
00133 <span class="comment"></span> <a class="code" href="classeo_one_max_eval_func.html">eoOneMaxEvalFunc<Indi></a> plainEval<span class="comment">/* (varType _anyVariable) */</span>;
|
||||
00134 <span class="comment">// turn that object into an evaluation counter</span>
|
||||
00135 <a class="code" href="classeo_eval_func_counter.html">eoEvalFuncCounter<Indi></a> eval(plainEval);
|
||||
00136
|
||||
00137 <span class="comment">// the genotype - through a genotype initializer</span>
|
||||
00138 <a class="code" href="classeo_init.html">eoInit<Indi></a>& init = make_genotype(parser, state, Indi());
|
||||
00139
|
||||
00140 <span class="comment">// Build the variation operator (any seq/prop construct)</span>
|
||||
00141 <a class="code" href="classeo_gen_op.html">eoGenOp<Indi></a>& op = make_op(parser, state, init);
|
||||
00142
|
||||
00143
|
||||
00145 <span class="comment">//</span>
|
||||
00146 <span class="comment">// YOU SHOULD NOT NEED TO MODIFY ANYTHING BEYOND THIS POINT</span>
|
||||
00147 <span class="comment">// unless you want to add specific statistics to the checkpoint</span>
|
||||
00149 <span class="comment"></span>
|
||||
00150 <span class="comment">// initialize the population</span>
|
||||
00151 <span class="comment">// yes, this is representation indepedent once you have an eoInit</span>
|
||||
00152 <a class="code" href="classeo_pop.html">eoPop<Indi></a>& pop = make_pop(parser, state, init);
|
||||
00153
|
||||
00154 <span class="comment">// stopping criteria</span>
|
||||
00155 <a class="code" href="classeo_continue.html">eoContinue<Indi></a> & term = make_continue(parser, state, eval);
|
||||
00156 <span class="comment">// output</span>
|
||||
00157 <a class="code" href="classeo_check_point.html">eoCheckPoint<Indi></a> & checkpoint = make_checkpoint(parser, state, eval, term);
|
||||
00158 <span class="comment">// algorithm (need the operator!)</span>
|
||||
00159 <a class="code" href="classeo_algo.html">eoAlgo<Indi></a>& ga = make_algo_scalar(parser, state, eval, checkpoint, op);
|
||||
00160
|
||||
00162
|
||||
00164 <span class="comment">// to be called AFTER all parameters have been read!!!</span>
|
||||
00165 make_help(parser);
|
||||
00166
|
||||
00169 <span class="comment">// evaluate intial population AFTER help and status in case it takes time</span>
|
||||
00170 apply<Indi>(eval, pop);
|
||||
00171 <span class="comment">// if you want to print it out</span>
|
||||
00172 cout << <span class="stringliteral">"Initial Population\n"</span>;
|
||||
00173 pop.<a class="code" href="classeo_pop.html#a17">sortedPrintOn</a>(cout);
|
||||
00174 cout << endl;
|
||||
00175
|
||||
00176 run_ea(ga, pop); <span class="comment">// run the ga</span>
|
||||
00177
|
||||
00178 cout << <span class="stringliteral">"Final Population\n"</span>;
|
||||
00179 pop.<a class="code" href="classeo_pop.html#a17">sortedPrintOn</a>(cout);
|
||||
00180 cout << endl;
|
||||
00181
|
||||
00182 }
|
||||
00183 <span class="keywordflow">catch</span>(exception& e)
|
||||
00184 {
|
||||
00185 cout << e.what() << endl;
|
||||
00186 }
|
||||
00187 <span class="keywordflow">return</span> 0;
|
||||
00188 }
|
||||
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:41 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>
|
||||
155
trunk/paradiseo-eo/doc/html/_one_max_lib_e_a_8cpp-source.html
Normal file
|
|
@ -0,0 +1,155 @@
|
|||
<!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: OneMaxLibEA.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_000003.html">tutorial</a> / <a class="el" href="dir_000016.html">Lesson5</a></div>
|
||||
<h1>OneMaxLibEA.cpp</h1><div class="fragment"><pre class="fragment">00001
|
||||
00006 <span class="comment">/*</span>
|
||||
00007 <span class="comment">Template for creating a new representation in EO</span>
|
||||
00008 <span class="comment">================================================</span>
|
||||
00009 <span class="comment"></span>
|
||||
00010 <span class="comment">This is the template main file for compiling after creating a</span>
|
||||
00011 <span class="comment">library. </span>
|
||||
00012 <span class="comment">See make_OneMax.cpp file.</span>
|
||||
00013 <span class="comment">*/</span>
|
||||
00014
|
||||
00015 <span class="comment">// Miscilaneous include and declaration </span>
|
||||
00016 <span class="preprocessor">#include <iostream></span>
|
||||
00017 <span class="keyword">using</span> <span class="keyword">namespace </span>std;
|
||||
00018
|
||||
00019 <span class="comment">// eo general include</span>
|
||||
00020 <span class="preprocessor">#include "eo"</span>
|
||||
00021 <span class="comment">// the real bounds (not yet in general eo include)</span>
|
||||
00022 <span class="preprocessor">#include "utils/eoRealVectorBounds.h"</span>
|
||||
00023
|
||||
00024 <span class="comment">// include here whatever specific files for your representation</span>
|
||||
00025 <span class="comment">// Basically, this should include at least the following</span>
|
||||
00026
|
||||
00030 <span class="preprocessor">#include "eoOneMax.h"</span>
|
||||
00031
|
||||
00035 <span class="preprocessor">#include "eoOneMaxInit.h"</span>
|
||||
00036
|
||||
00042 <span class="preprocessor">#include "eoOneMaxEvalFunc.h"</span>
|
||||
00043
|
||||
00044 <span class="comment">// GENOTYPE eoOneMax ***MUST*** be templatized over the fitness</span>
|
||||
00045
|
||||
00046 <span class="comment">//</span>
|
||||
00047 <span class="comment">// START fitness type: double or eoMaximizingFitness if you are maximizing</span>
|
||||
00048 <span class="comment">// eoMinimizingFitness if you are minimizing</span>
|
||||
00049 <span class="keyword">typedef</span> <a class="code" href="classeo_scalar_fitness.html">eoMinimizingFitness</a> <a class="code" href="classeo_scalar_fitness.html">MyFitT</a> ; <span class="comment">// type of fitness </span>
|
||||
00050 <span class="comment">// END fitness type</span>
|
||||
00051 <span class="comment">//</span>
|
||||
00052
|
||||
00053 <span class="comment">// Then define your EO objects using that fitness type</span>
|
||||
00054 <span class="keyword">typedef</span> <a class="code" href="classeo_one_max.html">eoOneMax<MyFitT></a> <a class="code" href="classeo_real.html">Indi</a>; <span class="comment">// ***MUST*** derive from EO </span>
|
||||
00055
|
||||
00056 <span class="comment">// create an initializer - done here and NOT in make_OneMax.cpp</span>
|
||||
00057 <span class="comment">// because it is NOT representation independent</span>
|
||||
00058 <span class="preprocessor">#include "make_genotype_OneMax.h"</span>
|
||||
00059 <a class="code" href="classeo_init.html">eoInit<Indi></a> & make_genotype(eoParser& _parser, <a class="code" href="classeo_state.html">eoState</a>&_state, Indi _eo)
|
||||
00060 {
|
||||
00061 <span class="keywordflow">return</span> do_make_genotype(_parser, _state, _eo);
|
||||
00062 }
|
||||
00063
|
||||
00064 <span class="comment">// same thing for the variation operaotrs</span>
|
||||
00065 <span class="preprocessor">#include "make_op_OneMax.h"</span>
|
||||
00066 <a class="code" href="classeo_gen_op.html">eoGenOp<Indi></a>& make_op(eoParser& _parser, <a class="code" href="classeo_state.html">eoState</a>& _state, <a class="code" href="classeo_init.html">eoInit<Indi></a>& _init)
|
||||
00067 {
|
||||
00068 <span class="keywordflow">return</span> do_make_op(_parser, _state, _init);
|
||||
00069 }
|
||||
00070
|
||||
00071 <span class="comment">// The representation independent routines are simply declared here</span>
|
||||
00072
|
||||
00073 <span class="comment">// how to initialize the population </span>
|
||||
00074 <span class="comment">// it IS representation independent if an eoInit is given</span>
|
||||
00075 <a class="code" href="classeo_pop.html">eoPop<Indi ></a>& make_pop(eoParser& _parser, <a class="code" href="classeo_state.html">eoState</a>& _state, <a class="code" href="classeo_init.html">eoInit<Indi></a> & _init);
|
||||
00076
|
||||
00077 <span class="comment">// the stopping criterion</span>
|
||||
00078 <a class="code" href="classeo_continue.html">eoContinue<Indi></a>& make_continue(eoParser& _parser, <a class="code" href="classeo_state.html">eoState</a>& _state, <a class="code" href="classeo_eval_func_counter.html">eoEvalFuncCounter<Indi></a> & _eval);
|
||||
00079
|
||||
00080 <span class="comment">// outputs (stats, population dumps, ...)</span>
|
||||
00081 <a class="code" href="classeo_check_point.html">eoCheckPoint<Indi></a>& make_checkpoint(eoParser& _parser, <a class="code" href="classeo_state.html">eoState</a>& _state, <a class="code" href="classeo_eval_func_counter.html">eoEvalFuncCounter<Indi></a>& _eval, <a class="code" href="classeo_continue.html">eoContinue<Indi></a>& _continue);
|
||||
00082
|
||||
00083 <span class="comment">// evolution engine (selection and replacement)</span>
|
||||
00084 <a class="code" href="classeo_algo.html">eoAlgo<Indi></a>& make_algo_scalar(eoParser& _parser, <a class="code" href="classeo_state.html">eoState</a>& _state, <a class="code" href="classeo_eval_func.html">eoEvalFunc<Indi></a>& _eval, <a class="code" href="classeo_continue.html">eoContinue<Indi></a>& _continue, <a class="code" href="classeo_gen_op.html">eoGenOp<Indi></a>& _op);
|
||||
00085
|
||||
00086 <span class="comment">// simple call to the algo. stays there for consistency reasons </span>
|
||||
00087 <span class="comment">// no template for that one</span>
|
||||
00088 <span class="keywordtype">void</span> run_ea(<a class="code" href="classeo_algo.html">eoAlgo<Indi></a>& _ga, <a class="code" href="classeo_pop.html">eoPop<Indi></a>& _pop);
|
||||
00089
|
||||
00090 <span class="comment">// checks for help demand, and writes the status file</span>
|
||||
00091 <span class="comment">// and make_help; in libutils - just a declaration, code in libeoutils.a</span>
|
||||
00092 <span class="keywordtype">void</span> make_help(eoParser & _parser);
|
||||
00093
|
||||
00094 <span class="comment">// now use all of the above, + representation dependent things</span>
|
||||
00095 <span class="comment">// from here on, no difference with eoOneMax.cpp</span>
|
||||
00096 <span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span>* argv[])
|
||||
00097 {
|
||||
00098
|
||||
00099 <span class="keywordflow">try</span>
|
||||
00100 {
|
||||
00101 eoParser parser(argc, argv); <span class="comment">// for user-parameter reading</span>
|
||||
00102
|
||||
00103 <a class="code" href="classeo_state.html">eoState</a> state; <span class="comment">// keeps all things allocated</span>
|
||||
00104
|
||||
00105 <span class="comment">// The fitness</span>
|
||||
00107 <span class="comment"></span> <a class="code" href="classeo_one_max_eval_func.html">eoOneMaxEvalFunc<Indi></a> plainEval<span class="comment">/* (varType _anyVariable) */</span>;
|
||||
00108 <span class="comment">// turn that object into an evaluation counter</span>
|
||||
00109 <a class="code" href="classeo_eval_func_counter.html">eoEvalFuncCounter<Indi></a> eval(plainEval);
|
||||
00110
|
||||
00111 <span class="comment">// the genotype - through a genotype initializer</span>
|
||||
00112 <a class="code" href="classeo_init.html">eoInit<Indi></a>& init = make_genotype(parser, state, Indi());
|
||||
00113
|
||||
00114 <span class="comment">// Build the variation operator (any seq/prop construct)</span>
|
||||
00115 <a class="code" href="classeo_gen_op.html">eoGenOp<Indi></a>& op = make_op(parser, state, init);
|
||||
00116
|
||||
00117
|
||||
00119 <span class="comment">//</span>
|
||||
00120 <span class="comment">// YOU SHOULD NOT NEED TO MODIFY ANYTHING BEYOND THIS POINT</span>
|
||||
00121 <span class="comment">// unless you want to add specific statistics to the checkpoint</span>
|
||||
00123 <span class="comment"></span>
|
||||
00124 <span class="comment">// initialize the population</span>
|
||||
00125 <span class="comment">// yes, this is representation indepedent once you have an eoInit</span>
|
||||
00126 <a class="code" href="classeo_pop.html">eoPop<Indi></a>& pop = make_pop(parser, state, init);
|
||||
00127
|
||||
00128 <span class="comment">// stopping criteria</span>
|
||||
00129 <a class="code" href="classeo_continue.html">eoContinue<Indi></a> & term = make_continue(parser, state, eval);
|
||||
00130 <span class="comment">// output</span>
|
||||
00131 <a class="code" href="classeo_check_point.html">eoCheckPoint<Indi></a> & checkpoint = make_checkpoint(parser, state, eval, term);
|
||||
00132 <span class="comment">// algorithm (need the operator!)</span>
|
||||
00133 <a class="code" href="classeo_algo.html">eoAlgo<Indi></a>& ga = make_algo_scalar(parser, state, eval, checkpoint, op);
|
||||
00134
|
||||
00136
|
||||
00138 <span class="comment">// to be called AFTER all parameters have been read!!!</span>
|
||||
00139 make_help(parser);
|
||||
00140
|
||||
00143 <span class="comment">// evaluate intial population AFTER help and status in case it takes time</span>
|
||||
00144 apply<Indi>(eval, pop);
|
||||
00145 <span class="comment">// if you want to print it out</span>
|
||||
00146 cout << <span class="stringliteral">"Initial Population\n"</span>;
|
||||
00147 pop.<a class="code" href="classeo_pop.html#a17">sortedPrintOn</a>(cout);
|
||||
00148 cout << endl;
|
||||
00149
|
||||
00150 run_ea(ga, pop); <span class="comment">// run the ga</span>
|
||||
00151
|
||||
00152 cout << <span class="stringliteral">"Final Population\n"</span>;
|
||||
00153 pop.<a class="code" href="classeo_pop.html#a17">sortedPrintOn</a>(cout);
|
||||
00154 cout << endl;
|
||||
00155
|
||||
00156 }
|
||||
00157 <span class="keywordflow">catch</span>(exception& e)
|
||||
00158 {
|
||||
00159 cout << e.what() << endl;
|
||||
00160 }
|
||||
00161 <span class="keywordflow">return</span> 0;
|
||||
00162 }
|
||||
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:41 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>
|
||||
245
trunk/paradiseo-eo/doc/html/_py_e_o_8cpp-source.html
Normal file
|
|
@ -0,0 +1,245 @@
|
|||
<!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: PyEO.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_000000.html">src</a> / <a class="el" href="dir_000001.html">pyeo</a></div>
|
||||
<h1>PyEO.cpp</h1><div class="fragment"><pre class="fragment">00001 <span class="comment">/*</span>
|
||||
00002 <span class="comment"> PyEO</span>
|
||||
00003 <span class="comment"></span>
|
||||
00004 <span class="comment"> Copyright (C) 2003 Maarten Keijzer</span>
|
||||
00005 <span class="comment"></span>
|
||||
00006 <span class="comment"> This program is free software; you can redistribute it and/or modify</span>
|
||||
00007 <span class="comment"> it under the terms of the GNU General Public License as published by</span>
|
||||
00008 <span class="comment"> the Free Software Foundation; either version 2 of the License, or</span>
|
||||
00009 <span class="comment"> (at your option) any later version.</span>
|
||||
00010 <span class="comment"></span>
|
||||
00011 <span class="comment"> This program is distributed in the hope that it will be useful,</span>
|
||||
00012 <span class="comment"> but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
|
||||
00013 <span class="comment"> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
|
||||
00014 <span class="comment"> GNU General Public License for more details.</span>
|
||||
00015 <span class="comment"></span>
|
||||
00016 <span class="comment"> You should have received a copy of the GNU General Public License</span>
|
||||
00017 <span class="comment"> along with this program; if not, write to the Free Software</span>
|
||||
00018 <span class="comment"> Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>
|
||||
00019 <span class="comment">*/</span>
|
||||
00020
|
||||
00021 <span class="preprocessor">#include <sstream></span>
|
||||
00022
|
||||
00023 <span class="preprocessor">#include "PyEO.h"</span>
|
||||
00024 <span class="preprocessor">#include <eoPop.h></span>
|
||||
00025
|
||||
00026
|
||||
00027 <span class="keyword">using</span> <span class="keyword">namespace </span>std;
|
||||
00028 <span class="comment">//using namespace boost::python;</span>
|
||||
00029
|
||||
00030 <span class="comment">// static member, needs to be instantiated somewhere</span>
|
||||
00031 std::vector<int> PyFitness::objective_info;
|
||||
00032
|
||||
00033 <span class="keywordtype">bool</span> PyFitness::dominates(<span class="keyword">const</span> PyFitness& oth)<span class="keyword"> const</span>
|
||||
00034 <span class="keyword"></span>{
|
||||
00035 <span class="keywordtype">bool</span> dom = <span class="keyword">false</span>;
|
||||
00036
|
||||
00037 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < nObjectives(); ++i)
|
||||
00038 {
|
||||
00039 <span class="keywordtype">int</span> objective = objective_info[i];
|
||||
00040
|
||||
00041 <span class="keywordflow">if</span> (objective == 0) <span class="comment">// ignore</span>
|
||||
00042 <span class="keywordflow">continue</span>;
|
||||
00043
|
||||
00044 <span class="keywordtype">bool</span> maxim = objective > 0;
|
||||
00045
|
||||
00046 <span class="keywordtype">double</span> aval = maxim? (*this)[i] : -(*this)[i];
|
||||
00047 <span class="keywordtype">double</span> bval = maxim? oth[i] : -oth[i];
|
||||
00048
|
||||
00049 <span class="keywordflow">if</span> (fabs(aval - bval) > tol())
|
||||
00050 {
|
||||
00051 <span class="keywordflow">if</span> (aval < bval)
|
||||
00052 {
|
||||
00053 <span class="keywordflow">return</span> <span class="keyword">false</span>; <span class="comment">// cannot dominate</span>
|
||||
00054 }
|
||||
00055 <span class="comment">// else aval < bval</span>
|
||||
00056 dom = <span class="keyword">true</span>; <span class="comment">// for the moment: goto next objective</span>
|
||||
00057 }
|
||||
00058 <span class="comment">//else they're equal in this objective, goto next</span>
|
||||
00059 }
|
||||
00060
|
||||
00061 <span class="keywordflow">return</span> dom;
|
||||
00062 }
|
||||
00063
|
||||
00064 <span class="keywordtype">bool</span> dominates(<span class="keyword">const</span> PyEO& a, <span class="keyword">const</span> PyEO& b)
|
||||
00065 {
|
||||
00066 <span class="keywordflow">return</span> PyFitness(a.fitness()).dominates(b.fitness());
|
||||
00067 }
|
||||
00068
|
||||
00069 ostream& operator<<(ostream& os, <span class="keyword">const</span> PyEO& _eo)
|
||||
00070 {
|
||||
00071 os << _eo.to_string();
|
||||
00072 <span class="keywordflow">return</span> os;
|
||||
00073 }
|
||||
00074
|
||||
00075 <span class="keyword">struct </span>pyPop_pickle_suite : boost::python::pickle_suite
|
||||
00076 {
|
||||
00077 <span class="keyword">static</span> boost::python::tuple getstate(<span class="keyword">const</span> <a class="code" href="classeo_pop.html">eoPop<PyEO></a>& _pop)
|
||||
00078 {
|
||||
00079 boost::python::list entries;
|
||||
00080 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i != _pop.size(); ++i)
|
||||
00081 entries.append( PyEO_pickle_suite::getstate(_pop[i]) );
|
||||
00082
|
||||
00083 <span class="keywordflow">return</span> boost::python::make_tuple(boost::python::object(_pop.size()), entries);
|
||||
00084 }
|
||||
00085
|
||||
00086 <span class="keyword">static</span> <span class="keywordtype">void</span> setstate( <a class="code" href="classeo_pop.html">eoPop<PyEO></a>& _pop, boost::python::tuple pickled)
|
||||
00087 {
|
||||
00088 <span class="keywordtype">int</span> sz = boost::python::extract<int>(pickled[0]);
|
||||
00089 boost::python::list entries = boost::python::list(pickled[1]);
|
||||
00090 _pop.resize(sz);
|
||||
00091 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i != _pop.size(); ++i)
|
||||
00092 {
|
||||
00093 PyEO_pickle_suite::setstate(_pop[i], boost::python::tuple(entries[i]) );
|
||||
00094 }
|
||||
00095 }
|
||||
00096 };
|
||||
00097
|
||||
00098
|
||||
00099 <span class="keyword">template</span> <<span class="keyword">class</span> T>
|
||||
00100 boost::python::str to_string(T& _p)
|
||||
00101 {
|
||||
00102 std::ostringstream os;
|
||||
00103 _p.<a class="code" href="classeo_pop.html#a18">printOn</a>(os);
|
||||
00104 <span class="keywordflow">return</span> boost::python::str(os.str().c_str());
|
||||
00105 }
|
||||
00106
|
||||
00107 <span class="keywordtype">void</span> pop_sort(<a class="code" href="classeo_pop.html">eoPop<PyEO></a>& pop) { pop.<a class="code" href="classeo_pop.html#a5">sort</a>(); }
|
||||
00108 <span class="keywordtype">void</span> pop_shuffle(<a class="code" href="classeo_pop.html">eoPop<PyEO></a>& pop) { pop.<a class="code" href="classeo_pop.html#a7">shuffle</a>(); }
|
||||
00109
|
||||
00110 <span class="keywordtype">void</span> translate_index_error(index_error <span class="keyword">const</span>& e)
|
||||
00111 {
|
||||
00112 PyErr_SetString(PyExc_IndexError, e.what.c_str());
|
||||
00113 }
|
||||
00114
|
||||
00115 PyEO& pop_getitem(<a class="code" href="classeo_pop.html">eoPop<PyEO></a>& pop, boost::python::object key)
|
||||
00116 {
|
||||
00117 boost::python::extract<int> x(key);
|
||||
00118 <span class="keywordflow">if</span> (!x.check())
|
||||
00119 <span class="keywordflow">throw</span> index_error(<span class="stringliteral">"Slicing not allowed"</span>);
|
||||
00120
|
||||
00121 <span class="keywordtype">int</span> i = x();
|
||||
00122
|
||||
00123 <span class="keywordflow">if</span> (static_cast<unsigned>(i) >= pop.size())
|
||||
00124 {
|
||||
00125 <span class="keywordflow">throw</span> index_error(<span class="stringliteral">"Index out of bounds"</span>);
|
||||
00126 }
|
||||
00127 <span class="keywordflow">return</span> pop[i];
|
||||
00128 }
|
||||
00129
|
||||
00130 <span class="keywordtype">void</span> pop_setitem(<a class="code" href="classeo_pop.html">eoPop<PyEO></a>& pop, boost::python::object key, PyEO& value)
|
||||
00131 {
|
||||
00132 boost::python::extract<int> x(key);
|
||||
00133 <span class="keywordflow">if</span> (!x.check())
|
||||
00134 <span class="keywordflow">throw</span> index_error(<span class="stringliteral">"Slicing not allowed"</span>);
|
||||
00135
|
||||
00136 <span class="keywordtype">int</span> i = x();
|
||||
00137
|
||||
00138 <span class="keywordflow">if</span> (static_cast<unsigned>(i) >= pop.size())
|
||||
00139 {
|
||||
00140 <span class="keywordflow">throw</span> index_error(<span class="stringliteral">"Index out of bounds"</span>);
|
||||
00141 }
|
||||
00142
|
||||
00143 pop[i] = value;
|
||||
00144 }
|
||||
00145
|
||||
00146 <span class="keywordtype">void</span> pop_push_back(<a class="code" href="classeo_pop.html">eoPop<PyEO></a>& pop, PyEO& p) { pop.push_back(p); }
|
||||
00147 <span class="keywordtype">void</span> pop_resize( <a class="code" href="classeo_pop.html">eoPop<PyEO></a>& pop, <span class="keywordtype">unsigned</span> i) { pop.resize(i); }
|
||||
00148
|
||||
00149 <span class="keyword">extern</span> <span class="keywordtype">void</span> abstract1();
|
||||
00150 <span class="keyword">extern</span> <span class="keywordtype">void</span> algos();
|
||||
00151 <span class="keyword">extern</span> <span class="keywordtype">void</span> random_numbers();
|
||||
00152 <span class="keyword">extern</span> <span class="keywordtype">void</span> geneticOps();
|
||||
00153 <span class="keyword">extern</span> <span class="keywordtype">void</span> selectOne();
|
||||
00154 <span class="keyword">extern</span> <span class="keywordtype">void</span> continuators();
|
||||
00155 <span class="keyword">extern</span> <span class="keywordtype">void</span> reduce();
|
||||
00156 <span class="keyword">extern</span> <span class="keywordtype">void</span> replacement();
|
||||
00157 <span class="keyword">extern</span> <span class="keywordtype">void</span> selectors();
|
||||
00158 <span class="keyword">extern</span> <span class="keywordtype">void</span> breeders();
|
||||
00159 <span class="keyword">extern</span> <span class="keywordtype">void</span> mergers();
|
||||
00160 <span class="keyword">extern</span> <span class="keywordtype">void</span> valueParam();
|
||||
00161 <span class="keyword">extern</span> <span class="keywordtype">void</span> perf2worth();
|
||||
00162 <span class="keyword">extern</span> <span class="keywordtype">void</span> monitors();
|
||||
00163 <span class="keyword">extern</span> <span class="keywordtype">void</span> statistics();
|
||||
00164
|
||||
00165 BOOST_PYTHON_MODULE(PyEO)
|
||||
00166 {
|
||||
00167 <span class="keyword">using</span> <span class="keyword">namespace </span>boost::python;
|
||||
00168
|
||||
00169 boost::python::register_exception_translator<index_error>(&translate_index_error);
|
||||
00170
|
||||
00171 boost::python::class_<PyEO>(<span class="stringliteral">"EO"</span>)
|
||||
00172 .add_property(<span class="stringliteral">"fitness"</span>, &PyEO::getFitness, &PyEO::setFitness)
|
||||
00173 .add_property(<span class="stringliteral">"genome"</span>, &PyEO::getGenome, &PyEO::setGenome)
|
||||
00174 .def_pickle(PyEO_pickle_suite())
|
||||
00175 .def(<span class="stringliteral">"invalidate"</span>, &PyEO::invalidate)
|
||||
00176 .def(<span class="stringliteral">"invalid"</span>, &PyEO::invalid)
|
||||
00177 .def(<span class="stringliteral">"__str__"</span>, &PyEO::to_string)
|
||||
00178 ;
|
||||
00179
|
||||
00180 boost::python::class_<eoPop<PyEO> >(<span class="stringliteral">"eoPop"</span>, init<>() )
|
||||
00181 .def( init< <span class="keywordtype">unsigned</span>, <a class="code" href="classeo_init.html">eoInit<PyEO></a>& >()[with_custodian_and_ward<1,3>()] )
|
||||
00182 .def(<span class="stringliteral">"append"</span>, &<a class="code" href="classeo_pop.html">eoPop<PyEO></a>::append)
|
||||
00183 .def(<span class="stringliteral">"__str__"</span>, to_string<<a class="code" href="classeo_pop.html">eoPop<PyEO></a> >)
|
||||
00184 .def(<span class="stringliteral">"__len__"</span>, &<a class="code" href="classeo_pop.html">eoPop<PyEO></a>::size)
|
||||
00185 .def(<span class="stringliteral">"sort"</span>, pop_sort )
|
||||
00186 .def(<span class="stringliteral">"shuffle"</span>, pop_shuffle)
|
||||
00187 .def(<span class="stringliteral">"__getitem__"</span>, pop_getitem, return_internal_reference<>() )
|
||||
00188 .def(<span class="stringliteral">"__setitem__"</span>, pop_setitem)
|
||||
00189 .def(<span class="stringliteral">"best"</span>, &<a class="code" href="classeo_pop.html">eoPop<PyEO></a>::best_element, return_internal_reference<>() )
|
||||
00190 .def(<span class="stringliteral">"push_back"</span>, pop_push_back)
|
||||
00191 .def(<span class="stringliteral">"resize"</span>, pop_resize)
|
||||
00192 .def_pickle(pyPop_pickle_suite())
|
||||
00193 ;
|
||||
00194
|
||||
00195
|
||||
00196 <span class="comment">// Other definitions in different compilation units,</span>
|
||||
00197 <span class="comment">// this to avoid having g++ to choke on the load</span>
|
||||
00198 random_numbers();
|
||||
00199 valueParam();
|
||||
00200 abstract1();
|
||||
00201 geneticOps();
|
||||
00202 selectOne();
|
||||
00203 selectors();
|
||||
00204 perf2worth();
|
||||
00205 monitors();
|
||||
00206 statistics();
|
||||
00207 continuators();
|
||||
00208 reduce();
|
||||
00209 replacement();
|
||||
00210 breeders();
|
||||
00211 mergers();
|
||||
00212 algos();
|
||||
00213
|
||||
00214 <span class="comment">// The traits class</span>
|
||||
00215 class_<PyFitness>(<span class="stringliteral">"PyFitness"</span>);
|
||||
00216
|
||||
00217 def(<span class="stringliteral">"nObjectives"</span>, &PyFitness::nObjectives);
|
||||
00218 def(<span class="stringliteral">"tol"</span>, &PyFitness::tol);
|
||||
00219 def(<span class="stringliteral">"maximizing"</span>, &PyFitness::maximizing);
|
||||
00220 def(<span class="stringliteral">"setObjectivesSize"</span>, &PyFitness::setObjectivesSize);
|
||||
00221 def(<span class="stringliteral">"setObjectivesValue"</span>, &PyFitness::setObjectivesValue);
|
||||
00222 def(<span class="stringliteral">"dominates"</span>, dominates);
|
||||
00223 }
|
||||
00224
|
||||
00225
|
||||
00226 <span class="comment">// to avoid having to build with libeo.a</span>
|
||||
00227 ostream & operator << ( ostream& _os, <span class="keyword">const</span> <a class="code" href="classeo_printable.html">eoPrintable</a>& _o ) {
|
||||
00228 _o.<a class="code" href="classeo_printable.html#a1">printOn</a>(_os);
|
||||
00229 <span class="keywordflow">return</span> _os;
|
||||
00230 };
|
||||
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:41 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>
|
||||
171
trunk/paradiseo-eo/doc/html/_py_e_o_8h-source.html
Normal file
|
|
@ -0,0 +1,171 @@
|
|||
<!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: PyEO.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> / <a class="el" href="dir_000001.html">pyeo</a></div>
|
||||
<h1>PyEO.h</h1><div class="fragment"><pre class="fragment">00001 <span class="comment">/*</span>
|
||||
00002 <span class="comment"> PyEO</span>
|
||||
00003 <span class="comment"> </span>
|
||||
00004 <span class="comment"> Copyright (C) 2003 Maarten Keijzer</span>
|
||||
00005 <span class="comment"></span>
|
||||
00006 <span class="comment"> This program is free software; you can redistribute it and/or modify</span>
|
||||
00007 <span class="comment"> it under the terms of the GNU General Public License as published by</span>
|
||||
00008 <span class="comment"> the Free Software Foundation; either version 2 of the License, or</span>
|
||||
00009 <span class="comment"> (at your option) any later version.</span>
|
||||
00010 <span class="comment"></span>
|
||||
00011 <span class="comment"> This program is distributed in the hope that it will be useful,</span>
|
||||
00012 <span class="comment"> but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
|
||||
00013 <span class="comment"> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
|
||||
00014 <span class="comment"> GNU General Public License for more details.</span>
|
||||
00015 <span class="comment"></span>
|
||||
00016 <span class="comment"> You should have received a copy of the GNU General Public License</span>
|
||||
00017 <span class="comment"> along with this program; if not, write to the Free Software</span>
|
||||
00018 <span class="comment"> Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>
|
||||
00019 <span class="comment">*/</span>
|
||||
00020
|
||||
00021 <span class="preprocessor">#ifndef PYEO_H</span>
|
||||
00022 <span class="preprocessor"></span><span class="preprocessor">#define PYEO_H</span>
|
||||
00023 <span class="preprocessor"></span>
|
||||
00024
|
||||
00025 <span class="preprocessor">#include <string></span>
|
||||
00026 <span class="preprocessor">#include <vector></span>
|
||||
00027 <span class="preprocessor">#include <exception></span>
|
||||
00028 <span class="preprocessor">#include <boost/python.hpp></span>
|
||||
00029
|
||||
00030 <span class="preprocessor">#include <EO.h></span>
|
||||
00031 <span class="keyword">struct </span>index_error : <span class="keyword">public</span> std::exception {
|
||||
00032 index_error(std::string w) : what(w) {};
|
||||
00033 <span class="keyword">virtual</span> ~index_error() throw() {}
|
||||
00034 std::string what;
|
||||
00035 };
|
||||
00036
|
||||
00037 <span class="keyword">class </span>PyFitness : <span class="keyword">public</span> boost::python::object
|
||||
00038 {
|
||||
00039 <span class="keyword">public</span> :
|
||||
00040
|
||||
00041 <span class="keyword">typedef</span> PyFitness fitness_traits; <span class="comment">// it's its own traits class :-)</span>
|
||||
00042
|
||||
00043 PyFitness() : boost::python::object() {}
|
||||
00044
|
||||
00045 <span class="keyword">template</span> <<span class="keyword">class</span> T>
|
||||
00046 PyFitness(<span class="keyword">const</span> T& o) : boost::python::object(o) {}
|
||||
00047
|
||||
00048 <span class="keyword">static</span> <span class="keywordtype">unsigned</span> nObjectives() { <span class="keywordflow">return</span> objective_info.size(); }
|
||||
00049 <span class="keyword">static</span> <span class="keywordtype">double</span> tol() { <span class="keywordflow">return</span> 1e-6; }
|
||||
00050 <span class="keyword">static</span> <span class="keywordtype">bool</span> maximizing(<span class="keywordtype">int</span> which) { <span class="keywordflow">return</span> objective_info[which] > 0; }
|
||||
00051
|
||||
00052 <span class="keyword">static</span> <span class="keywordtype">void</span> setObjectivesSize(<span class="keywordtype">int</span> sz) { objective_info.resize(sz, 0); }
|
||||
00053 <span class="keyword">static</span> <span class="keywordtype">void</span> setObjectivesValue(<span class="keywordtype">unsigned</span> which, <span class="keywordtype">int</span> value)
|
||||
00054 {
|
||||
00055 <span class="keywordflow">if</span> (which >= objective_info.size())
|
||||
00056 {
|
||||
00057 <span class="keywordflow">throw</span> index_error(<span class="stringliteral">"Too few elements allocated, resize objectives first"</span>);
|
||||
00058 }
|
||||
00059
|
||||
00060 objective_info[which] = value;
|
||||
00061 }
|
||||
00062
|
||||
00063 <span class="keyword">static</span> std::vector<int> objective_info;
|
||||
00064
|
||||
00065 <span class="keywordtype">bool</span> dominates(<span class="keyword">const</span> PyFitness& oth) <span class="keyword">const</span>;
|
||||
00066
|
||||
00067 <span class="keywordtype">double</span> operator[](<span class="keywordtype">int</span> i)<span class="keyword"> const </span>
|
||||
00068 <span class="keyword"> </span>{
|
||||
00069 boost::python::extract<double> x(object::operator[](i));
|
||||
00070
|
||||
00071 <span class="keywordflow">if</span> (!x.check())
|
||||
00072 <span class="keywordflow">throw</span> std::runtime_error(<span class="stringliteral">"PyFitness: does not contain doubles"</span>);
|
||||
00073 <span class="keywordflow">return</span> x();
|
||||
00074 }
|
||||
00075
|
||||
00076 <span class="keywordtype">bool</span> operator<(<span class="keyword">const</span> PyFitness& other)<span class="keyword"> const </span>
|
||||
00077 <span class="keyword"> </span>{
|
||||
00078 <span class="keywordflow">if</span> (objective_info.size() == 0)
|
||||
00079 {
|
||||
00080 <span class="keyword">const</span> object& <span class="keyword">self</span> = *<span class="keyword">this</span>;
|
||||
00081 <span class="keyword">const</span> object& oth = other;
|
||||
00082 <span class="keywordflow">return</span> <span class="keyword">self</span> < oth;
|
||||
00083 }
|
||||
00084 <span class="comment">// otherwise use objective_info</span>
|
||||
00085
|
||||
00086 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < objective_info.size(); ++i)
|
||||
00087 {
|
||||
00088 <span class="keywordtype">double</span> a = objective_info[i] * operator[](i);
|
||||
00089 <span class="keywordtype">double</span> b = objective_info[i] * other[i];
|
||||
00090
|
||||
00091 <span class="keywordflow">if</span> ( fabs(a - b) > tol())
|
||||
00092 {
|
||||
00093 <span class="keywordflow">if</span> (a < b)
|
||||
00094 <span class="keywordflow">return</span> <span class="keyword">true</span>;
|
||||
00095 <span class="keywordflow">return</span> <span class="keyword">false</span>;
|
||||
00096 }
|
||||
00097 }
|
||||
00098
|
||||
00099 <span class="keywordflow">return</span> <span class="keyword">false</span>;
|
||||
00100 }
|
||||
00101
|
||||
00102 <span class="keywordtype">bool</span> operator>(<span class="keyword">const</span> PyFitness& other)<span class="keyword"> const </span>
|
||||
00103 <span class="keyword"> </span>{
|
||||
00104 <span class="keywordflow">return</span> other.operator<(*this);
|
||||
00105 }
|
||||
00106
|
||||
00107 <span class="keywordtype">void</span> printOn(std::ostream& os)<span class="keyword"> const </span>{ <span class="keyword">const</span> boost::python::object& o = *<span class="keyword">this</span>; boost::python::api::operator<<(os,o); }
|
||||
00108 <span class="keyword">friend</span> std::ostream& operator<<(std::ostream& os, <span class="keyword">const</span> PyFitness& p) { p.printOn(os); <span class="keywordflow">return</span> os; }
|
||||
00109 <span class="keyword">friend</span> std::istream& operator>>(std::istream& is, PyFitness& p) { boost::python::object o; is >> o; p = o; <span class="keywordflow">return</span> is; }
|
||||
00110 };
|
||||
00111
|
||||
00112 <span class="keyword">struct </span>PyEO : <span class="keyword">public</span> <a class="code" href="class_e_o.html">EO</a>< PyFitness >
|
||||
00113 {
|
||||
00114 <span class="keyword">typedef</span> PyFitness Fitness;
|
||||
00115
|
||||
00116 boost::python::object getFitness()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="class_e_o.html#a5">invalid</a>()? Fitness(): <a class="code" href="class_e_o.html#a2">fitness</a>(); }
|
||||
00117 <span class="keywordtype">void</span> setFitness(boost::python::object f) { <span class="keywordflow">if</span> (f == Fitness()) invalidate(); <span class="keywordflow">else</span> <a class="code" href="class_e_o.html#a2">fitness</a>(f); }
|
||||
00118
|
||||
00119 boost::python::object getGenome()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> genome; }
|
||||
00120 <span class="keywordtype">void</span> setGenome(boost::python::object g) { genome = g; }
|
||||
00121 boost::python::object genome;
|
||||
00122
|
||||
00123 std::string to_string()<span class="keyword"> const</span>
|
||||
00124 <span class="keyword"> </span>{
|
||||
00125 std::string result;
|
||||
00126 result += boost::python::extract<const char*>(boost::python::str(getFitness()));
|
||||
00127 result += <span class="charliteral">' '</span>;
|
||||
00128 result += boost::python::extract<const char*>(boost::python::str(genome));
|
||||
00129 <span class="keywordflow">return</span> result;
|
||||
00130 }
|
||||
00131
|
||||
00132 <span class="keywordtype">bool</span> <a class="code" href="class_e_o.html#a6">operator<</a>(<span class="keyword">const</span> PyEO& other)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="class_e_o.html#a6">EO<Fitness>::operator<</a>(other); }
|
||||
00133 <span class="keywordtype">bool</span> operator>(<span class="keyword">const</span> PyEO& other)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="class_e_o.html">EO<Fitness>::operator></a>(other); }
|
||||
00134
|
||||
00135 };
|
||||
00136
|
||||
00137 std::ostream& operator<<(std::ostream& os, <span class="keyword">const</span> PyEO& _eo);
|
||||
00138
|
||||
00139 <span class="keyword">struct </span>PyEO_pickle_suite : boost::python::pickle_suite
|
||||
00140 {
|
||||
00141 <span class="keyword">typedef</span> PyEO::Fitness Fitness;
|
||||
00142
|
||||
00143 <span class="keyword">static</span>
|
||||
00144 boost::python::tuple getstate(<span class="keyword">const</span> PyEO& _eo)
|
||||
00145 {
|
||||
00146 <span class="keywordflow">return</span> boost::python::make_tuple(_eo.getFitness(), _eo.genome);
|
||||
00147 }
|
||||
00148 <span class="keyword">static</span>
|
||||
00149 <span class="keywordtype">void</span> setstate(PyEO& _eo, boost::python::tuple pickled)
|
||||
00150 {
|
||||
00151 _eo.setFitness( Fitness(pickled[0]) );
|
||||
00152 _eo.genome = pickled[1];
|
||||
00153 }
|
||||
00154 };
|
||||
00155
|
||||
00156 <span class="preprocessor">#endif</span>
|
||||
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:42 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>
|
||||
115
trunk/paradiseo-eo/doc/html/_r_e_a_d_m_e-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: README 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>
|
||||
<h1>README</h1><div class="fragment"><pre class="fragment">00001 <a class="code" href="class_e_o.html">EO</a> README FILE
|
||||
00002 =======================================================================
|
||||
00003 check latest news at http:<span class="comment">//eodev.sourceforge.net/</span>
|
||||
00004 =======================================================================
|
||||
00005
|
||||
00006 Welcome to <a class="code" href="class_e_o.html">EO</a>, the Evolving Objects library.
|
||||
00007
|
||||
00008 The latest news about EO can be found on the sourceforge repository at
|
||||
00009
|
||||
00010 http:<span class="comment">//eodev.sourceforge.net/</span>
|
||||
00011
|
||||
00012 In <span class="keywordflow">case</span> of any problem, please e-mail us at
|
||||
00013
|
||||
00014 eodev@egroups.com, eodev-main@lists.sourceforge.net
|
||||
00015
|
||||
00016
|
||||
00017 ==================================================================
|
||||
00018 BUILDING EO
|
||||
00019 ==================================================================
|
||||
00020 The basic installation procedure goes the following:
|
||||
00021
|
||||
00022 Go to your build-directory and run
|
||||
00023 $(SRCDIR)/configure
|
||||
00024 make
|
||||
00025 make check
|
||||
00026 make install
|
||||
00027 where $(SRCDIR) is the top-level source directory of EO, i.e. where
|
||||
00028 the sources where unpacked.
|
||||
00029
|
||||
00030 See $(SRCDIR)/configure <span class="keywordflow">for</span> possible options. You can specify to not
|
||||
00031 build example applications, the tutorial, or to build the ParadisEO
|
||||
00032 tutorial. You may also change the installation directory that way.
|
||||
00033
|
||||
00034 Now you should probably go to the tutorial and start learning about EO
|
||||
00035 features and programming.
|
||||
00036
|
||||
00037
|
||||
00038 In <span class="keywordflow">case</span> of problems, you can read the INSTALL file - but remember <span class="keyword">this</span>
|
||||
00039 is a standard installation file from GNU and that it contains nothing
|
||||
00040 specific about EO.
|
||||
00041
|
||||
00042
|
||||
00043 ===================================================================
|
||||
00044 DIRECTORY STRUCTURE
|
||||
00045 ===================================================================
|
||||
00046 After unpacking the archive file, you should end up with the following
|
||||
00047 structure:
|
||||
00048
|
||||
00049 .../ the MAIN EO dir, created when unpacking
|
||||
00050 |
|
||||
00051 +-- src SOURCE dir. Contains most EO .h files
|
||||
00052 | |
|
||||
00053 | +- utils general utilities (e.g. RNG-related source files)
|
||||
00054 | |
|
||||
00055 | +- ga bistring-genotypes source files
|
||||
00056 | |
|
||||
00057 | +- es real-valued-genotypes source files
|
||||
00058 | |
|
||||
00059 | +- gp Genetic Programming source files
|
||||
00060 | |
|
||||
00061 | +- obsolete files from old versions - <span class="keywordflow">for</span> upward compatibility
|
||||
00062 |
|
||||
00063 |
|
||||
00064 |
|
||||
00065 +-- tutorial TUTORIAL dir (indeed :-)
|
||||
00066 | |
|
||||
00067 | +- html all html files - start by browsing index.html
|
||||
00068 | |
|
||||
00069 | +- LessonX <span class="keywordflow">for</span> X=1, 2, 3, ... : example of increasing complexity
|
||||
00070 |
|
||||
00071 |
|
||||
00072 |
|
||||
00073 +-- doc DOCUMENTATION dir (generated by Doxygen)
|
||||
00074 | |
|
||||
00075 | +- html HTML files - start at index.html (see also tutorial)
|
||||
00076 | |
|
||||
00077 | +- latex latex files - use to generate Poatscript doc.
|
||||
00078 | |
|
||||
00079 | +- man Unix man format documentation
|
||||
00080 |
|
||||
00081 |
|
||||
00082 +-- test TEST files - <span class="keywordflow">for</span> debugging purposes only
|
||||
00083 |
|
||||
00084 |
|
||||
00085 +-- app APPLICATIONS - one dir per separate application
|
||||
00086 | |
|
||||
00087 | +- gprop GA/backpropagation <span class="keywordflow">for</span> neural nets
|
||||
00088 | |
|
||||
00089 | +- mastermind the wellknown MasterMind game
|
||||
00090 |
|
||||
00091 |
|
||||
00092 +-- win WINDOWS dir: project files <span class="keywordflow">for</span> MS/VC5+
|
||||
00093
|
||||
00094
|
||||
00095
|
||||
00096 ===================================================================
|
||||
00097 NOTES
|
||||
00098 ===================================================================
|
||||
00099 If you extracted a fresh snapshot from the cvs-repository, remember
|
||||
00100 to run
|
||||
00101 ./autogen.sh
|
||||
00102 in the source-directory before building the libraries.
|
||||
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:42 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>
|
||||
379
trunk/paradiseo-eo/doc/html/_r_e_a_d_m_e_8cpp-source.html
Normal file
|
|
@ -0,0 +1,379 @@
|
|||
<!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: README.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_000007.html">contrib</a> / <a class="el" href="dir_000008.html">mathsym</a> / <a class="el" href="dir_000028.html">sym</a></div>
|
||||
<h1>README.cpp</h1><div class="fragment"><pre class="fragment">00001
|
||||
00002 <span class="comment">/* </span>
|
||||
00003 <span class="comment"> DESCRIPTION:</span>
|
||||
00004 <span class="comment"></span>
|
||||
00005 <span class="comment"></span>
|
||||
00006 <span class="comment">The class 'Sym' in this package provides a reference counted, hashed tree structure that can be used in genetic programming.</span>
|
||||
00007 <span class="comment">The hash table behind the scenes makes sure that every subtree in the application is stored only once.</span>
|
||||
00008 <span class="comment">This has a couple of advantages:</span>
|
||||
00009 <span class="comment"></span>
|
||||
00010 <span class="comment">o Memory: all subtrees are stored only once</span>
|
||||
00011 <span class="comment">o Comparison: comparison for equality for two subtrees boils down to a pointer comparison </span>
|
||||
00012 <span class="comment">o Overview: by accessing the hashtable, you get an instant overview of the state of the population</span>
|
||||
00013 <span class="comment"></span>
|
||||
00014 <span class="comment"></span>
|
||||
00015 <span class="comment">The disadvantage of this method is the constant time overhead for computing hashes. In practice,</span>
|
||||
00016 <span class="comment">it seems to be fast enough.</span>
|
||||
00017 <span class="comment"></span>
|
||||
00018 <span class="comment"></span>
|
||||
00019 <span class="comment">===== How to Use this =========</span>
|
||||
00020 <span class="comment"></span>
|
||||
00021 <span class="comment">In essence, the Sym data structure contains two important pieces of data,</span>
|
||||
00022 <span class="comment">the 'token' (of type token_t = int) and the children, a vector of Sym (called SymVec).</span>
|
||||
00023 <span class="comment">The token should contain all information to be able to figure out which </span>
|
||||
00024 <span class="comment">function/terminal is represented by the node in the tree. By retrieving this token value</span>
|
||||
00025 <span class="comment">and the SymVec it is possible to write recursive traversal routines for evaluation, printing,</span>
|
||||
00026 <span class="comment">etc.</span>
|
||||
00027 <span class="comment"></span>
|
||||
00028 <span class="comment">*/</span>
|
||||
00029
|
||||
00030 <span class="preprocessor">#include <iostream></span>
|
||||
00031 <span class="preprocessor">#include "Sym.h"</span>
|
||||
00032
|
||||
00033 <span class="keyword">using</span> <span class="keyword">namespace </span>std;
|
||||
00034
|
||||
00035
|
||||
00036 <span class="comment">/* </span>
|
||||
00037 <span class="comment"> * Suppose token value '0' designates our terminal, and token value '1' designates a binary function.</span>
|
||||
00038 <span class="comment"> * Later on a ternary function will be used as well, designated with token value '2'</span>
|
||||
00039 <span class="comment"> * The function below will create a tree of size three</span>
|
||||
00040 <span class="comment">*/</span>
|
||||
00041 Sym test1() {
|
||||
00042
|
||||
00043 SymVec children;
|
||||
00044 children.push_back( Sym(0) ); <span class="comment">// push_back is a member from std::vector, SymVec is derived from std::vector</span>
|
||||
00045 children.push_back( Sym(0) );
|
||||
00046
|
||||
00047 Sym tree = Sym(token_t(1), children); <span class="comment">// creates the tree</span>
|
||||
00048
|
||||
00049 <span class="comment">/* Done, now print some information about the node */</span>
|
||||
00050
|
||||
00051 cout << <span class="stringliteral">"Size = "</span> << tree.size() << endl; <span class="comment">// prints 3</span>
|
||||
00052 cout << <span class="stringliteral">"Depth = "</span> << tree.depth() << endl; <span class="comment">// prints 2</span>
|
||||
00053 cout << <span class="stringliteral">"Refcount = "</span> << tree.refcount() << endl; <span class="comment">// prints 1</span>
|
||||
00054
|
||||
00055 Sym tree2 = tree; <span class="comment">// make a copy (this only changes refcount)</span>
|
||||
00056
|
||||
00057 cout << <span class="stringliteral">"Refcount now = "</span> << tree.refcount() << endl; <span class="comment">// print 2</span>
|
||||
00058
|
||||
00059 <span class="keywordflow">return</span> tree; <span class="comment">// tree2 will be deleted and reference count returns to 1</span>
|
||||
00060 }
|
||||
00061
|
||||
00062 <span class="comment">/* To actually use the tree, evaluate it, the following simple recursive function</span>
|
||||
00063 <span class="comment"> * can be used</span>
|
||||
00064 <span class="comment">*/</span>
|
||||
00065
|
||||
00066 <span class="keywordtype">int</span> eval(<span class="keyword">const</span> Sym& sym) {
|
||||
00067 <span class="keywordflow">if</span> (sym.token() == 0) { <span class="comment">// it's a terminal in this example</span>
|
||||
00068 <span class="keywordflow">return</span> 1;
|
||||
00069 }
|
||||
00070 <span class="comment">// else it's the function</span>
|
||||
00071 <span class="keyword">const</span> SymVec& children = sym.args(); <span class="comment">// get the children out, children.size() is the arity</span>
|
||||
00072
|
||||
00073 <span class="comment">// let's assume that we've also got a ternary function designated by token '2'</span>
|
||||
00074
|
||||
00075 <span class="keywordflow">if</span> (sym.token() == token_t(1))
|
||||
00076 <span class="keywordflow">return</span> eval(children[0]) + eval(children[1]); <span class="comment">// evaluate</span>
|
||||
00077
|
||||
00078 <span class="keywordflow">return</span> eval(children[0]) + eval(children[1]) * eval(children[2]); <span class="comment">// a ternary function</span>
|
||||
00079 }
|
||||
00080
|
||||
00081 <span class="comment">/* Note that you simply use the stored token that was defined above. Simply checking the size of SymVec in</span>
|
||||
00082 <span class="comment"> * this particular example could have sufficed, but it's instructive to use the tokens.</span>
|
||||
00083 <span class="comment"> * </span>
|
||||
00084 <span class="comment"> * And to test this: </span>
|
||||
00085 <span class="comment">*/</span>
|
||||
00086
|
||||
00087 <span class="keywordtype">void</span> test_eval() {
|
||||
00088
|
||||
00089 Sym tree = test1();
|
||||
00090
|
||||
00091 cout << <span class="stringliteral">"Evaluating tree1 returns "</span> << eval(tree) << endl;
|
||||
00092 }
|
||||
00093
|
||||
00094 <span class="comment">/* Writing initialization functions.</span>
|
||||
00095 <span class="comment"> *</span>
|
||||
00096 <span class="comment"> * As the Sym class is recursive in nature, initialization can simply be done using </span>
|
||||
00097 <span class="comment"> * recursive routines as above. As an example, the following code does 'full' initialization.</span>
|
||||
00098 <span class="comment"> */</span>
|
||||
00099
|
||||
00100 Sym init_full(<span class="keywordtype">int</span> depth_left) {
|
||||
00101 <span class="keywordflow">if</span> (depth_left == 0) <span class="keywordflow">return</span> Sym(0); <span class="comment">// create terminal</span>
|
||||
00102 <span class="comment">// else create either a binary or a ternary function</span>
|
||||
00103
|
||||
00104 depth_left--;
|
||||
00105
|
||||
00106 <span class="keywordflow">if</span> (rand() % 2 == 0) { <span class="comment">// create binary</span>
|
||||
00107 SymVec vec(2);
|
||||
00108 vec[0] = init_full(depth_left);
|
||||
00109 vec[1] = init_full(depth_left);
|
||||
00110
|
||||
00111 <span class="keywordflow">return</span> Sym(token_t(1), vec);
|
||||
00112
|
||||
00113 } <span class="keywordflow">else</span> { <span class="comment">// create ternary tree</span>
|
||||
00114 SymVec vec(3);
|
||||
00115 vec[0] = init_full(depth_left);
|
||||
00116 vec[1] = init_full(depth_left);
|
||||
00117 vec[2] = init_full(depth_left);
|
||||
00118
|
||||
00119 <span class="keywordflow">return</span> Sym(token_t(2), vec); <span class="comment">// token value 2 designates a ternary now, even though the arity can simply be read from the size of the 'SymVec'</span>
|
||||
00120 }
|
||||
00121
|
||||
00122 }
|
||||
00123
|
||||
00124
|
||||
00125 <span class="comment">/* Examining the hash table.</span>
|
||||
00126 <span class="comment"> *</span>
|
||||
00127 <span class="comment"> * The hash table is a static member of the Sym class, but can be obtained and inspected</span>
|
||||
00128 <span class="comment"> * at any point during the run. The hash table follows the SGI implementation of hashmap (and effectively</span>
|
||||
00129 <span class="comment"> * uses it in gcc). An example:</span>
|
||||
00130 <span class="comment"> */</span>
|
||||
00131
|
||||
00132 <span class="keywordtype">void</span> inspect_hashtable() {
|
||||
00133 SymMap& dag = Sym::get_dag(); <span class="comment">// get the hashmap</span>
|
||||
00134 <span class="keywordtype">unsigned</span> i = 0;
|
||||
00135 <span class="keywordflow">for</span> (SymMap::iterator it = dag.begin(); it != dag.end(); ++it) {
|
||||
00136 Sym node(it); <span class="comment">// initialize a 'sym' with the iterator </span>
|
||||
00137
|
||||
00138 cout << <span class="stringliteral">"Node "</span> << i++ << <span class="stringliteral">" size "</span> << node.size();
|
||||
00139 cout << <span class="stringliteral">" refcount "</span> << node.refcount()-1; <span class="comment">// -1: note that by creating the Sym above the refcount is increased</span>
|
||||
00140 cout << <span class="stringliteral">" depth "</span> << node.depth();
|
||||
00141 cout << <span class="charliteral">'\n'</span>;
|
||||
00142 }
|
||||
00143
|
||||
00144 }
|
||||
00145
|
||||
00146 <span class="comment">/* The above code effectively examines all distinct subtrees in use in the application and prints some stats for the node */</span>
|
||||
00147
|
||||
00148 <span class="comment">/* Manipulating trees </span>
|
||||
00149 <span class="comment"> *</span>
|
||||
00150 <span class="comment"> * The Sym class is set up in such a way that you cannot change a Sym, so how do you perform crossover and mutation?</span>
|
||||
00151 <span class="comment"> *</span>
|
||||
00152 <span class="comment"> * Simple, you create new syms. The Sym class supports two functions to make this easier: 'get_subtree' and 'insert_subtree'.</span>
|
||||
00153 <span class="comment"> * These traverse the tree by index, where 0 designates the root and other values are indexed depth first.</span>
|
||||
00154 <span class="comment"> */</span>
|
||||
00155
|
||||
00156 Sym subtree_xover(Sym a, Sym b) {
|
||||
00157
|
||||
00158 Sym to_insert = get_subtree(a, rand() % a.size() ); <span class="comment">// select random subtree, will crash if too high a value is given</span>
|
||||
00159
|
||||
00160 <span class="comment">/* 'insert' it into b. This will not really insert, it will however create a new sym,</span>
|
||||
00161 <span class="comment"> * equal to 'b' but with a's subtree inserted at the designated spot. */</span>
|
||||
00162 <span class="keywordflow">return</span> insert_subtree(b, rand() % b.size(), to_insert);
|
||||
00163
|
||||
00164 }
|
||||
00165
|
||||
00166 <span class="comment">/* Tying it together, we can create a simple genetic programming system. Mutation is not implemented here,</span>
|
||||
00167 <span class="comment"> * but would be easy enough to add by using recursion and/or 'set'. */</span>
|
||||
00168
|
||||
00169 <span class="keywordtype">void</span> run_gp() {
|
||||
00170
|
||||
00171 <span class="keywordtype">int</span> ngens = 50;
|
||||
00172 <span class="keywordtype">int</span> popsize = 1000;
|
||||
00173
|
||||
00174 cout << <span class="stringliteral">"Starting running "</span> << popsize << <span class="stringliteral">" individuals for "</span> << ngens << <span class="stringliteral">" generations."</span> << endl;
|
||||
00175
|
||||
00176 vector<Sym> pop(popsize);
|
||||
00177
|
||||
00178 <span class="comment">// init population</span>
|
||||
00179 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < pop.size(); ++i) {
|
||||
00180 pop[i] = init_full(5);
|
||||
00181 }
|
||||
00182
|
||||
00183 <span class="keywordtype">double</span> best = 0.0;
|
||||
00184
|
||||
00185 <span class="comment">// do a very simple steady state tournament </span>
|
||||
00186 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> gen = 0; gen < ngens * pop.size(); ++gen) {
|
||||
00187 <span class="keywordtype">int</span> sel1 = rand()% pop.size();
|
||||
00188 <span class="keywordtype">int</span> sel2 = rand() % pop.size();
|
||||
00189 <span class="keywordtype">int</span> sel3 = rand() % pop.size();
|
||||
00190
|
||||
00191 <span class="keywordtype">double</span> ev1 = eval(pop[sel1]);
|
||||
00192 <span class="keywordtype">double</span> ev3 = eval(pop[sel3]);
|
||||
00193
|
||||
00194 <span class="keywordtype">double</span> bst = max(ev1,ev3);
|
||||
00195 <span class="keywordflow">if</span> (bst > best) {
|
||||
00196 best = bst;
|
||||
00197 }
|
||||
00198
|
||||
00199 <span class="keywordflow">if</span> (ev3 > ev1) {
|
||||
00200 sel1 = sel3; <span class="comment">// selection pressure</span>
|
||||
00201 }
|
||||
00202
|
||||
00203 Sym child = subtree_xover(pop[sel1], pop[sel2]);
|
||||
00204
|
||||
00205 <span class="comment">// Check for uniqueness</span>
|
||||
00206 <span class="keywordflow">if</span> (child.refcount() == 1) pop[ rand() % pop.size() ] = child;
|
||||
00207 }
|
||||
00208
|
||||
00209 <span class="comment">// and at the end:</span>
|
||||
00210
|
||||
00211 inspect_hashtable();
|
||||
00212
|
||||
00213 <span class="comment">// and also count number of nodes in the population</span>
|
||||
00214 <span class="keywordtype">int</span> sz = 0;
|
||||
00215 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < pop.size(); ++i) { sz += pop[i].size(); }
|
||||
00216 cout << <span class="stringliteral">"Number of distinct nodes "</span> << Sym::get_dag().size() << endl;
|
||||
00217 cout << <span class="stringliteral">"Nodes in population "</span> << sz << endl;
|
||||
00218 cout << <span class="stringliteral">"ratio "</span> << double(Sym::get_dag().size())/sz << endl;
|
||||
00219 cout << <span class="stringliteral">"Best fitness "</span> << best << endl;
|
||||
00220
|
||||
00221 }
|
||||
00222
|
||||
00223 <span class="comment">/* One extra mechanism is supported to add annotations to nodes. Something derived from</span>
|
||||
00224 <span class="comment"> * 'UniqueNodeStats' can be used to attach new information to nodes. For this to function,</span>
|
||||
00225 <span class="comment"> * we need to supply a 'factory' function that creates these node-stats; attach this function to the </span>
|
||||
00226 <span class="comment"> * Sym class, so that it gets called whenever a new node is created. The constructors of the Sym class</span>
|
||||
00227 <span class="comment"> * take care of this.</span>
|
||||
00228 <span class="comment"> *</span>
|
||||
00229 <span class="comment"> * IMPORTANT: </span>
|
||||
00230 <span class="comment"> * in a realistic application, the factory function needs to be set BEFORE any Syms are created</span>
|
||||
00231 <span class="comment"> * Mixing Syms creating with and without the factory can lead to unexpected results </span>
|
||||
00232 <span class="comment"> *</span>
|
||||
00233 <span class="comment"> * First we derive some structure from UniqueNodeStats: */</span>
|
||||
00234
|
||||
00235 <span class="keyword">struct </span>MyNodeStats : <span class="keyword">public</span> UniqueNodeStats {
|
||||
00236
|
||||
00237 <span class="keywordtype">int</span> sumsize;
|
||||
00238
|
||||
00239 ~MyNodeStats() { cout << <span class="stringliteral">"MyNodeStats::~MyNodeStats, sumsize = "</span> << sumsize << endl; }
|
||||
00240 };
|
||||
00241
|
||||
00242 <span class="comment">/* then define the factory function. It will get a Sym, which is just created. */</span>
|
||||
00243 UniqueNodeStats* create_stats(<span class="keyword">const</span> Sym& sym) {
|
||||
00244 MyNodeStats* stats = <span class="keyword">new</span> MyNodeStats; <span class="comment">// Sym will take care of memory management</span>
|
||||
00245
|
||||
00246 <span class="keywordtype">int</span> sumsize = sym.size();
|
||||
00247 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < sym.args().size(); ++i) {
|
||||
00248 <span class="comment">// retrieve the extra node stats of the child</span>
|
||||
00249 UniqueNodeStats* unique_stats = sym.args()[i].extra_stats(); <span class="comment">// extra_stats retrieves the stats</span>
|
||||
00250 MyNodeStats* child_stats = static_cast<MyNodeStats*>(unique_stats); <span class="comment">// cast it to the right struct</span>
|
||||
00251 sumsize += child_stats->sumsize;
|
||||
00252 }
|
||||
00253
|
||||
00254 stats->sumsize = sumsize;
|
||||
00255 <span class="keywordflow">return</span> stats; <span class="comment">// now it will get attached to the node and deleted when its reference count goes to zero</span>
|
||||
00256 }
|
||||
00257
|
||||
00258 <span class="keywordtype">void</span> test_node_stats() {
|
||||
00259
|
||||
00260 <span class="keywordflow">if</span> (Sym::get_dag().size() != 0) {
|
||||
00261 cerr << <span class="stringliteral">"Cannot mix nodes with and without factory functions"</span> << endl;
|
||||
00262 exit(1);
|
||||
00263 }
|
||||
00264
|
||||
00265 <span class="comment">/* Very Important: attach the factory function to the Sym class */</span>
|
||||
00266 Sym::set_factory_function(create_stats);
|
||||
00267
|
||||
00268 Sym tree = init_full(5); <span class="comment">// create a tree</span>
|
||||
00269
|
||||
00270 <span class="comment">// get extra node stats out</span>
|
||||
00271 MyNodeStats* stats = static_cast<MyNodeStats*>( tree.extra_stats() );
|
||||
00272
|
||||
00273 cout << <span class="stringliteral">"Size = "</span> << tree.size() << <span class="stringliteral">" SumSize = "</span> << stats->sumsize << endl;
|
||||
00274
|
||||
00275 Sym::clear_factory_function(); <span class="comment">// reset</span>
|
||||
00276 }
|
||||
00277
|
||||
00278
|
||||
00279 <span class="comment">/* And run the code above */</span>
|
||||
00280
|
||||
00281 <span class="keywordtype">int</span> main() {
|
||||
00282 srand(time(0));
|
||||
00283 cout << <span class="stringliteral">"********** TEST EVALUATION **************\n"</span>;
|
||||
00284 test_eval();
|
||||
00285 cout << <span class="stringliteral">"********** TEST ALGORITHM ***************\n"</span>;
|
||||
00286 run_gp();
|
||||
00287
|
||||
00288 cout << <span class="stringliteral">"********** TEST FACTORY ****************\n"</span>;
|
||||
00289 test_node_stats(); <span class="comment">// can work because there are no live nodes</span>
|
||||
00290
|
||||
00291 }
|
||||
00292
|
||||
00293 <span class="comment">/* ********** Member function reference: ********************</span>
|
||||
00294 <span class="comment"> *</span>
|
||||
00295 <span class="comment"> * Sym() The default constructor will create an undefined node (no token and no children), check for empty() to see if a node is undefined</span>
|
||||
00296 <span class="comment"> * </span>
|
||||
00297 <span class="comment"> * Sym(token_t) Create a terminal</span>
|
||||
00298 <span class="comment"> *</span>
|
||||
00299 <span class="comment"> * Sym(token_t, const SymVec&)</span>
|
||||
00300 <span class="comment"> * Create a node with token and SymVec as the children</span>
|
||||
00301 <span class="comment"> * </span>
|
||||
00302 <span class="comment"> * Sym(SymIterator it)</span>
|
||||
00303 <span class="comment"> * Create a sym from an iterator (taken from the hashtable directly, or from Sym::iterator)</span>
|
||||
00304 <span class="comment"> *</span>
|
||||
00305 <span class="comment"> * dtor, copy-ctor and assignment</span>
|
||||
00306 <span class="comment"> *</span>
|
||||
00307 <span class="comment"> * UniqueNodeStats* extra_stats() </span>
|
||||
00308 <span class="comment"> * Returns an UniqueNodeStats pointer (= 0 if no factory is defined)</span>
|
||||
00309 <span class="comment"> * </span>
|
||||
00310 <span class="comment"> * </span>
|
||||
00311 <span class="comment"> * int hashcode() returns the hashcode for the node</span>
|
||||
00312 <span class="comment"> * </span>
|
||||
00313 <span class="comment"> * int refcount() returns the reference count for the node</span>
|
||||
00314 <span class="comment"> * </span>
|
||||
00315 <span class="comment"> * bool operator== checks for equality (note that this is a pointer compare, really really fast)</span>
|
||||
00316 <span class="comment"> * </span>
|
||||
00317 <span class="comment"> * bool empty() returns whether the node is undefined, i.e. created through the default ctor </span>
|
||||
00318 <span class="comment"> * </span>
|
||||
00319 <span class="comment"> * int arity() shorthand for sym.args().size()</span>
|
||||
00320 <span class="comment"> * </span>
|
||||
00321 <span class="comment"> * token_t token() return identifying token for the node</span>
|
||||
00322 <span class="comment"> * </span>
|
||||
00323 <span class="comment"> * const SymVec& args()</span>
|
||||
00324 <span class="comment"> * returns the children of the node (in a vector<Sym>)</span>
|
||||
00325 <span class="comment"> * </span>
|
||||
00326 <span class="comment"> * unsigned size() returns the size, i.e., number of nodes</span>
|
||||
00327 <span class="comment"> * </span>
|
||||
00328 <span class="comment"> * unsigned depth() returns the depth</span>
|
||||
00329 <span class="comment"> * </span>
|
||||
00330 <span class="comment"> * iterator() returns the pointer to the node in the hashtable</span>
|
||||
00331 <span class="comment"> *</span>
|
||||
00332 <span class="comment"> * </span>
|
||||
00333 <span class="comment"> ********** Static functions: ********************</span>
|
||||
00334 <span class="comment"> *</span>
|
||||
00335 <span class="comment"> *</span>
|
||||
00336 <span class="comment"> * </span>
|
||||
00337 <span class="comment"> * SymMap& get_dag() returns the hash table containing all nodes. This should only be used for inspection,</span>
|
||||
00338 <span class="comment"> * even though the dag itself is not const. This to enable the use of the ctor Sym(SymIterator) to inspect</span>
|
||||
00339 <span class="comment"> * using the Sym interface (rather than the hash table interface). This does allow you to make destructive</span>
|
||||
00340 <span class="comment"> * changes to the class, so use with care</span>
|
||||
00341 <span class="comment"> *</span>
|
||||
00342 <span class="comment"> * set_factory_function( UniqueNodeStats (*)(const Sym&) )</span>
|
||||
00343 <span class="comment"> * Set the factory function</span>
|
||||
00344 <span class="comment"> *</span>
|
||||
00345 <span class="comment"> * clear_factory_function() </span>
|
||||
00346 <span class="comment"> * Clears the factory function, allocated UniqueNodeStats will still be deleted, but no new ones will be created.</span>
|
||||
00347 <span class="comment"> *</span>
|
||||
00348 <span class="comment"> ********** Utility Functions ******************** </span>
|
||||
00349 <span class="comment"> * </span>
|
||||
00350 <span class="comment"> * Sym get_subtree(const Sym& org, int i)</span>
|
||||
00351 <span class="comment"> * Retreive the i-th subtree from the Sym. Standard depth first ordering, where root has index 0 and the</span>
|
||||
00352 <span class="comment"> * rightmost terminal has index sym.size()-1</span>
|
||||
00353 <span class="comment"> *</span>
|
||||
00354 <span class="comment"> * Sym insert_subtree(const Sym& org, int i, const Sym& subtree)</span>
|
||||
00355 <span class="comment"> * Returns a Sym that is equal to 'org', for which the i-th subtree (same ordering as get_subtree) is replaced</span>
|
||||
00356 <span class="comment"> * by the third argument subtree.</span>
|
||||
00357 <span class="comment"> * </span>
|
||||
00358 <span class="comment"> * Sym next(const Sym&)</span>
|
||||
00359 <span class="comment"> * Returns the successor of the argument sym from the hashtable with wrap around. This is implemented just because</span>
|
||||
00360 <span class="comment"> * it can be done. It may be an interesting way to mutate...</span>
|
||||
00361 <span class="comment"> * </span>
|
||||
00362 <span class="comment"> * */</span>
|
||||
00363
|
||||
00364
|
||||
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:42 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>
|
||||
79
trunk/paradiseo-eo/doc/html/_real_e_a_8cpp-source.html
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
<!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: RealEA.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_000003.html">tutorial</a> / <a class="el" href="dir_000006.html">Lesson4</a></div>
|
||||
<h1>RealEA.cpp</h1><div class="fragment"><pre class="fragment">00001 <span class="preprocessor">#include <iostream></span>
|
||||
00002
|
||||
00003 <span class="preprocessor">#include <es/make_real.h></span>
|
||||
00004 <span class="preprocessor">#include "real_value.h"</span>
|
||||
00005 <span class="preprocessor">#include <apply.h></span>
|
||||
00006
|
||||
00007 <span class="keyword">using</span> <span class="keyword">namespace </span>std;
|
||||
00008
|
||||
00009 <span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span>* argv[])
|
||||
00010 {
|
||||
00011
|
||||
00012 <span class="keywordflow">try</span>
|
||||
00013 {
|
||||
00014 <span class="keyword">typedef</span> <a class="code" href="classeo_real.html">eoReal<eoMinimizingFitness></a> <a class="code" href="struct_dummy.html">EOT</a>;
|
||||
00015
|
||||
00016 eoParser parser(argc, argv); <span class="comment">// for user-parameter reading</span>
|
||||
00017
|
||||
00018 <a class="code" href="classeo_state.html">eoState</a> state; <span class="comment">// keeps all things allocated</span>
|
||||
00019
|
||||
00022
|
||||
00023 <span class="comment">// The evaluation fn - encapsulated into an eval counter for output </span>
|
||||
00024 <a class="code" href="structeo_eval_func_ptr.html">eoEvalFuncPtr<EOT, double, const std::vector<double></a>&>
|
||||
00025 mainEval( real_value );
|
||||
00026 <a class="code" href="classeo_eval_func_counter.html">eoEvalFuncCounter<EOT></a> eval(mainEval);
|
||||
00027
|
||||
00028 <span class="comment">// the genotype - through a genotype initializer</span>
|
||||
00029 <a class="code" href="classeo_real_init_bounded.html">eoRealInitBounded<EOT></a>& init = make_genotype(parser, state, EOT());
|
||||
00030
|
||||
00031 <span class="comment">// Build the variation operator (any seq/prop construct)</span>
|
||||
00032 <a class="code" href="classeo_gen_op.html">eoGenOp<EOT></a>& op = make_op(parser, state, init);
|
||||
00033
|
||||
00036
|
||||
00037 <span class="comment">// initialize the population - and evaluate</span>
|
||||
00038 <span class="comment">// yes, this is representation indepedent once you have an eoInit</span>
|
||||
00039 <a class="code" href="classeo_pop.html">eoPop<EOT></a>& pop = make_pop(parser, state, init);
|
||||
00040
|
||||
00041 <span class="comment">// stopping criteria</span>
|
||||
00042 <a class="code" href="classeo_continue.html">eoContinue<EOT></a> & term = make_continue(parser, state, eval);
|
||||
00043 <span class="comment">// output</span>
|
||||
00044 <a class="code" href="classeo_check_point.html">eoCheckPoint<EOT></a> & checkpoint = make_checkpoint(parser, state, eval, term);
|
||||
00045 <span class="comment">// algorithm (need the operator!)</span>
|
||||
00046 <a class="code" href="classeo_algo.html">eoAlgo<EOT></a>& ea = make_algo_scalar(parser, state, eval, checkpoint, op);
|
||||
00047
|
||||
00050 <span class="comment">// to be called AFTER all parameters have been read!!!</span>
|
||||
00051 make_help(parser);
|
||||
00052
|
||||
00055 <span class="comment">// evaluate intial population AFTER help and status in case it takes time</span>
|
||||
00056 apply<EOT>(eval, pop);
|
||||
00057 <span class="comment">// print it out</span>
|
||||
00058 cout << <span class="stringliteral">"Initial Population\n"</span>;
|
||||
00059 pop.<a class="code" href="classeo_pop.html#a17">sortedPrintOn</a>(cout);
|
||||
00060 cout << endl;
|
||||
00061
|
||||
00062 run_ea(ea, pop); <span class="comment">// run the ea</span>
|
||||
00063
|
||||
00064 cout << <span class="stringliteral">"Final Population\n"</span>;
|
||||
00065 pop.<a class="code" href="classeo_pop.html#a17">sortedPrintOn</a>(cout);
|
||||
00066 cout << endl;
|
||||
00067 }
|
||||
00068 <span class="keywordflow">catch</span>(exception& e)
|
||||
00069 {
|
||||
00070 cout << e.what() << endl;
|
||||
00071 }
|
||||
00072 }
|
||||
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:42 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>
|
||||
74
trunk/paradiseo-eo/doc/html/_royal_road_8h-source.html
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
<!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: RoyalRoad.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_000002.html">test</a></div>
|
||||
<h1>RoyalRoad.h</h1><div class="fragment"><pre class="fragment">00001 <span class="comment">/*</span>
|
||||
00002 <span class="comment"> RoyalRoad.h</span>
|
||||
00003 <span class="comment"> -- Implementation of the Royal Road function for any length and block size</span>
|
||||
00004 <span class="comment"> (c) GeNeura Team 2001, Marc Schoenauer 2000</span>
|
||||
00005 <span class="comment"></span>
|
||||
00006 <span class="comment"> This library is free software; you can redistribute it and/or</span>
|
||||
00007 <span class="comment"> modify it under the terms of the GNU Lesser General Public</span>
|
||||
00008 <span class="comment"> License as published by the Free Software Foundation; either</span>
|
||||
00009 <span class="comment"> version 2 of the License, or (at your option) any later version.</span>
|
||||
00010 <span class="comment"></span>
|
||||
00011 <span class="comment"> This library is distributed in the hope that it will be useful,</span>
|
||||
00012 <span class="comment"> but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
|
||||
00013 <span class="comment"> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</span>
|
||||
00014 <span class="comment"> Lesser General Public License for more details.</span>
|
||||
00015 <span class="comment"></span>
|
||||
00016 <span class="comment"> You should have received a copy of the GNU Lesser General Public</span>
|
||||
00017 <span class="comment"> License along with this library; if not, write to the Free Software</span>
|
||||
00018 <span class="comment"> Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>
|
||||
00019 <span class="comment"></span>
|
||||
00020 <span class="comment"> Contact: todos@geneura.ugr.es, http://geneura.ugr.es</span>
|
||||
00021 <span class="comment"> Marc.Schoenauer@polytechnique.fr</span>
|
||||
00022 <span class="comment">CVS Info: $Date: 2001/06/21 12:03:17 $ $Header: /cvsroot/eodev/eo/test/RoyalRoad.h,v 1.3 2001/06/21 12:03:17 jmerelo Exp $ $Author: jmerelo $</span>
|
||||
00023 <span class="comment">*/</span>
|
||||
00024
|
||||
00025 <span class="preprocessor">#ifndef RoyalRoad_h</span>
|
||||
00026 <span class="preprocessor"></span><span class="preprocessor">#define RoyalRoad_h</span>
|
||||
00027 <span class="preprocessor"></span>
|
||||
00028 <span class="keyword">template</span><<span class="keyword">class</span> EOT>
|
||||
00029 <span class="keyword">class </span>RoyalRoad: <span class="keyword">public</span> <a class="code" href="classeo_eval_func.html">eoEvalFunc</a><EOT> {
|
||||
00030
|
||||
00031 <span class="keyword">public</span>:
|
||||
00032
|
||||
00033 <span class="keyword">typedef</span> <span class="keyword">typename</span> EOT::Fitness <a class="code" href="classeo_scalar_fitness.html">FitT</a>;
|
||||
00034
|
||||
00036 RoyalRoad( <span class="keywordtype">unsigned</span> _div ): <a class="code" href="classeo_eval_func.html">eoEvalFunc</a><<a class="code" href="struct_dummy.html">EOT</a> >(), div( _div ) {};
|
||||
00037
|
||||
00038 <span class="comment">// Applies the function</span>
|
||||
00039 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classeo_u_f.html#a1">operator() </a>( <a class="code" href="struct_dummy.html">EOT</a> & _eo ) {
|
||||
00040 <a class="code" href="classeo_scalar_fitness.html">FitT</a> fitness = 0;
|
||||
00041 <span class="keywordflow">if</span> (_eo.<a class="code" href="class_e_o.html#a5">invalid</a>()) {
|
||||
00042 <span class="keywordflow">for</span> ( <span class="keywordtype">unsigned</span> i = 0; i < _eo.size()/div; i ++ ) {
|
||||
00043 <span class="keywordtype">bool</span> block = <span class="keyword">true</span>;
|
||||
00044 <span class="keywordflow">for</span> ( <span class="keywordtype">unsigned</span> j = 0; j < div; j ++ ) {
|
||||
00045 block &= _eo[i*div+j];
|
||||
00046 }
|
||||
00047 <span class="keywordflow">if</span> (block) {
|
||||
00048 fitness += div;
|
||||
00049 }
|
||||
00050 }
|
||||
00051 _eo.<a class="code" href="class_e_o.html#a2">fitness</a>( fitness );
|
||||
00052 }
|
||||
00053 };
|
||||
00054
|
||||
00055 <span class="keyword">private</span>:
|
||||
00056 <span class="keywordtype">unsigned</span> div;
|
||||
00057
|
||||
00058 };
|
||||
00059
|
||||
00060 <span class="preprocessor">#endif</span>
|
||||
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:42 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>
|
||||
432
trunk/paradiseo-eo/doc/html/_scaling_8cpp-source.html
Normal file
|
|
@ -0,0 +1,432 @@
|
|||
<!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: Scaling.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_000007.html">contrib</a> / <a class="el" href="dir_000008.html">mathsym</a> / <a class="el" href="dir_000012.html">regression</a></div>
|
||||
<h1>Scaling.cpp</h1><div class="fragment"><pre class="fragment">00001 <span class="comment">/* </span>
|
||||
00002 <span class="comment"> * Copyright (C) 2005 Maarten Keijzer</span>
|
||||
00003 <span class="comment"> *</span>
|
||||
00004 <span class="comment"> * This program is free software; you can redistribute it and/or modify</span>
|
||||
00005 <span class="comment"> * it under the terms of version 2 of the GNU General Public License as </span>
|
||||
00006 <span class="comment"> * published by the Free Software Foundation. </span>
|
||||
00007 <span class="comment"> *</span>
|
||||
00008 <span class="comment"> * This program is distributed in the hope that it will be useful,</span>
|
||||
00009 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
|
||||
00010 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
|
||||
00011 <span class="comment"> * GNU General Public License for more details.</span>
|
||||
00012 <span class="comment"> *</span>
|
||||
00013 <span class="comment"> * You should have received a copy of the GNU General Public License</span>
|
||||
00014 <span class="comment"> * along with this program; if not, write to the Free Software</span>
|
||||
00015 <span class="comment"> * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>
|
||||
00016 <span class="comment"> */</span>
|
||||
00017
|
||||
00018 <span class="preprocessor">#include "Scaling.h"</span>
|
||||
00019 <span class="preprocessor">#include "TargetInfo.h"</span>
|
||||
00020
|
||||
00021 <span class="keyword">using</span> <span class="keyword">namespace </span>std;
|
||||
00022
|
||||
00023 Scaling slope(<span class="keyword">const</span> std::valarray<double>& x, <span class="keyword">const</span> TargetInfo& targets) {
|
||||
00024
|
||||
00025 <span class="keywordtype">double</span> xx = 0.0;
|
||||
00026 <span class="keywordtype">double</span> xy = 0.0;
|
||||
00027
|
||||
00028 <span class="keyword">const</span> valarray<double>& y = targets.targets();
|
||||
00029
|
||||
00030 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < x.size(); ++i) {
|
||||
00031 xx += x[i] * x[i];
|
||||
00032 xy += x[i] * y[i];
|
||||
00033 }
|
||||
00034
|
||||
00035 <span class="keywordflow">if</span> (xx < 1e-7) <span class="keywordflow">return</span> Scaling(<span class="keyword">new</span> LinearScaling(0.0,0.0));
|
||||
00036
|
||||
00037 <span class="keywordtype">double</span> b = xy / xx;
|
||||
00038
|
||||
00039 <span class="keywordflow">return</span> Scaling(<span class="keyword">new</span> LinearScaling(0.0, b));
|
||||
00040
|
||||
00041 }
|
||||
00042
|
||||
00043 <span class="comment">// Still needs proper testing with non-trivial lambda</span>
|
||||
00044 Scaling regularized_least_squares(<span class="keyword">const</span> std::valarray<double>& inputs, <span class="keyword">const</span> TargetInfo& targets, <span class="keywordtype">double</span> lambda) {
|
||||
00045
|
||||
00046 <span class="keywordtype">double</span> n = inputs.size();
|
||||
00047
|
||||
00048 valarray<double> x = inputs;
|
||||
00049
|
||||
00050 <span class="keywordtype">double</span> a,b,d;
|
||||
00051 a=b=d=0;
|
||||
00052
|
||||
00053 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < n; ++i) {
|
||||
00054 a += 1 + lambda;
|
||||
00055 b += x[i];
|
||||
00056 d += x[i] * x[i] + lambda;
|
||||
00057 }
|
||||
00058
|
||||
00059 <span class="comment">//invert</span>
|
||||
00060
|
||||
00061 <span class="keywordtype">double</span> ad_bc = a*d - b * b;
|
||||
00062 <span class="comment">// if ad_bc equals zero there's a problem</span>
|
||||
00063
|
||||
00064 <span class="keywordflow">if</span> (ad_bc < 1e-17) <span class="keywordflow">return</span> Scaling(<span class="keyword">new</span> LinearScaling);
|
||||
00065
|
||||
00066 <span class="keywordtype">double</span> ai = d/ad_bc;
|
||||
00067 <span class="keywordtype">double</span> bi = -b/ad_bc;
|
||||
00068 <span class="keywordtype">double</span> di = a/ad_bc;
|
||||
00069 <span class="keywordtype">double</span> ci = bi;
|
||||
00070
|
||||
00071 <span class="comment">// Now multiply this inverted covariance matrix (C^-1) with x' * t</span>
|
||||
00072
|
||||
00073 std::valarray<double> ones = x;
|
||||
00074
|
||||
00075 <span class="comment">// calculate C^-1 * x' )</span>
|
||||
00076 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < n; ++i)
|
||||
00077 {
|
||||
00078 ones[i] = (ai + bi * x[i]);
|
||||
00079 x[i] = (ci + di * x[i]);
|
||||
00080 }
|
||||
00081
|
||||
00082 <span class="comment">// results are in [ones, x], now multiply with y</span>
|
||||
00083
|
||||
00084 a = 0.0; <span class="comment">// intercept</span>
|
||||
00085 b = 0.0; <span class="comment">// slope</span>
|
||||
00086
|
||||
00087 <span class="keyword">const</span> valarray<double>& t = targets.targets();
|
||||
00088
|
||||
00089 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < n; ++i)
|
||||
00090 {
|
||||
00091 a += ones[i] * t[i];
|
||||
00092 b += x[i] * t[i];
|
||||
00093 }
|
||||
00094
|
||||
00095 <span class="keywordflow">return</span> Scaling(<span class="keyword">new</span> LinearScaling(a,b));
|
||||
00096 }
|
||||
00097
|
||||
00098 Scaling ols(<span class="keyword">const</span> std::valarray<double>& y, <span class="keyword">const</span> std::valarray<double>& t) {
|
||||
00099 <span class="keywordtype">double</span> n = y.size();
|
||||
00100
|
||||
00101 <span class="keywordtype">double</span> y_mean = y.sum() / n;
|
||||
00102 <span class="keywordtype">double</span> t_mean = t.sum() / n;
|
||||
00103
|
||||
00104 std::valarray<double> y_var = (y - y_mean);
|
||||
00105 std::valarray<double> t_var = (t - t_mean);
|
||||
00106 std::valarray<double> cov = t_var * y_var;
|
||||
00107
|
||||
00108 y_var *= y_var;
|
||||
00109 t_var *= t_var;
|
||||
00110
|
||||
00111 <span class="keywordtype">double</span> sumvar = y_var.sum();
|
||||
00112
|
||||
00113 <span class="keywordflow">if</span> (sumvar == 0. || sumvar/n < 1e-7 || sumvar/n > 1e+7) <span class="comment">// breakout when numerical problems are likely</span>
|
||||
00114 <span class="keywordflow">return</span> Scaling(<span class="keyword">new</span> LinearScaling(t_mean,0.));
|
||||
00115
|
||||
00116
|
||||
00117 <span class="keywordtype">double</span> b = cov.sum() / sumvar;
|
||||
00118 <span class="keywordtype">double</span> a = t_mean - b * y_mean;
|
||||
00119
|
||||
00120 Scaling s = Scaling(<span class="keyword">new</span> LinearScaling(a,b));
|
||||
00121
|
||||
00122 <span class="keywordflow">return</span> s;
|
||||
00123 }
|
||||
00124
|
||||
00125 Scaling ols(<span class="keyword">const</span> std::valarray<double>& y, <span class="keyword">const</span> TargetInfo& targets) {
|
||||
00126 <span class="keywordtype">double</span> n = y.size();
|
||||
00127
|
||||
00128 <span class="keywordtype">double</span> y_mean = y.sum() / n;
|
||||
00129
|
||||
00130 std::valarray<double> y_var = (y - y_mean);
|
||||
00131 std::valarray<double> cov = targets.tcov_part() * y_var;
|
||||
00132
|
||||
00133 y_var *= y_var;
|
||||
00134
|
||||
00135 <span class="keywordtype">double</span> sumvar = y_var.sum();
|
||||
00136
|
||||
00137 <span class="keywordflow">if</span> (sumvar == 0. || sumvar/n < 1e-7 || sumvar/n > 1e+7) <span class="comment">// breakout when numerical problems are likely</span>
|
||||
00138 <span class="keywordflow">return</span> Scaling(<span class="keyword">new</span> LinearScaling(targets.tmean(),0.));
|
||||
00139
|
||||
00140
|
||||
00141 <span class="keywordtype">double</span> b = cov.sum() / sumvar;
|
||||
00142 <span class="keywordtype">double</span> a = targets.tmean() - b * y_mean;
|
||||
00143
|
||||
00144 <span class="keywordflow">if</span> (!finite(b)) {
|
||||
00145
|
||||
00146 cout << a << <span class="charliteral">' '</span> << b << endl;
|
||||
00147 cout << sumvar << endl;
|
||||
00148 cout << y_mean << endl;
|
||||
00149 cout << cov.sum() << endl;
|
||||
00150 exit(1);
|
||||
00151 }
|
||||
00152
|
||||
00153 Scaling s = Scaling(<span class="keyword">new</span> LinearScaling(a,b));
|
||||
00154
|
||||
00155 <span class="keywordflow">return</span> s;
|
||||
00156 }
|
||||
00157
|
||||
00158
|
||||
00159 Scaling wls(<span class="keyword">const</span> std::valarray<double>& inputs, <span class="keyword">const</span> TargetInfo& targets) {
|
||||
00160
|
||||
00161 std::valarray<double> x = inputs;
|
||||
00162 <span class="keyword">const</span> std::valarray<double>& w = targets.weights();
|
||||
00163
|
||||
00164 <span class="keywordtype">unsigned</span> n = x.size();
|
||||
00165 <span class="comment">// First calculate x'*W (as W is a diagonal matrix it's simply elementwise multiplication</span>
|
||||
00166 std::valarray<double> wx = targets.weights() * x;
|
||||
00167
|
||||
00168 <span class="comment">// Now x'*W is contained in [w,wx], calculate x' * W * x (the covariance)</span>
|
||||
00169 <span class="keywordtype">double</span> a,b,d;
|
||||
00170 a=b=d=0.0;
|
||||
00171
|
||||
00172 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < n; ++i)
|
||||
00173 {
|
||||
00174 a += w[i];
|
||||
00175 b += wx[i];
|
||||
00176 d += x[i] * wx[i];
|
||||
00177 }
|
||||
00178
|
||||
00179 <span class="comment">//invert</span>
|
||||
00180
|
||||
00181 <span class="keywordtype">double</span> ad_bc = a*d - b * b;
|
||||
00182 <span class="comment">// if ad_bc equals zero there's a problem</span>
|
||||
00183
|
||||
00184 <span class="keywordflow">if</span> (ad_bc < 1e-17) <span class="keywordflow">return</span> Scaling(<span class="keyword">new</span> LinearScaling);
|
||||
00185
|
||||
00186 <span class="keywordtype">double</span> ai = d/ad_bc;
|
||||
00187 <span class="keywordtype">double</span> bi = -b/ad_bc;
|
||||
00188 <span class="keywordtype">double</span> di = a/ad_bc;
|
||||
00189 <span class="keywordtype">double</span> ci = bi;
|
||||
00190
|
||||
00191 <span class="comment">// Now multiply this inverted covariance matrix (C^-1) with x' * W * y</span>
|
||||
00192
|
||||
00193 <span class="comment">// create alias to reuse the wx we do not need anymore</span>
|
||||
00194 std::valarray<double>& ones = wx;
|
||||
00195
|
||||
00196 <span class="comment">// calculate C^-1 * x' * W (using the fact that W is diagonal)</span>
|
||||
00197 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < n; ++i)
|
||||
00198 {
|
||||
00199 ones[i] = w[i]*(ai + bi * x[i]);
|
||||
00200 x[i] = w[i]*(ci + di * x[i]);
|
||||
00201 }
|
||||
00202
|
||||
00203 <span class="comment">// results are in [ones, x], now multiply with y</span>
|
||||
00204
|
||||
00205 a = 0.0; <span class="comment">// intercept</span>
|
||||
00206 b = 0.0; <span class="comment">// slope</span>
|
||||
00207
|
||||
00208 <span class="keyword">const</span> valarray<double>& t = targets.targets();
|
||||
00209
|
||||
00210 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < n; ++i)
|
||||
00211 {
|
||||
00212 a += ones[i] * t[i];
|
||||
00213 b += x[i] * t[i];
|
||||
00214 }
|
||||
00215
|
||||
00216 <span class="keywordflow">return</span> Scaling(<span class="keyword">new</span> LinearScaling(a,b));
|
||||
00217 }
|
||||
00218
|
||||
00219
|
||||
00220 <span class="comment">//Scaling med(const std::valarray<double>& inputs, const TargetInfo& targets);</span>
|
||||
00221
|
||||
00222 <span class="keywordtype">double</span> mse(<span class="keyword">const</span> std::valarray<double>& y, <span class="keyword">const</span> TargetInfo& t) {
|
||||
00223
|
||||
00224 valarray<double> residuals = t.targets()-y;
|
||||
00225 residuals *= residuals;
|
||||
00226 <span class="keywordtype">double</span> sz = residuals.size();
|
||||
00227 <span class="keywordflow">if</span> (t.has_weights()) {
|
||||
00228 residuals *= t.weights();
|
||||
00229 sz = 1.0;
|
||||
00230 }
|
||||
00231
|
||||
00232 <span class="keywordflow">return</span> residuals.sum() / sz;
|
||||
00233 }
|
||||
00234
|
||||
00235 <span class="keywordtype">double</span> rms(<span class="keyword">const</span> std::valarray<double>& y, <span class="keyword">const</span> TargetInfo& t) {
|
||||
00236 <span class="keywordflow">return</span> sqrt(mse(y,t));
|
||||
00237 }
|
||||
00238
|
||||
00239 <span class="keywordtype">double</span> mae(<span class="keyword">const</span> std::valarray<double>& y, <span class="keyword">const</span> TargetInfo& t) {
|
||||
00240 valarray<double> residuals = abs(t.targets()-y);
|
||||
00241 <span class="keywordflow">if</span> (t.has_weights()) residuals *= t.weights();
|
||||
00242 <span class="keywordflow">return</span> residuals.sum() / residuals.size();
|
||||
00243 }
|
||||
00244
|
||||
00245
|
||||
00246 <span class="comment">/*</span>
|
||||
00247 <span class="comment"> double standard_error(const std::valarray<double>& y, const std::pair<double,double>& scaling) {</span>
|
||||
00248 <span class="comment"> double a = scaling.first;</span>
|
||||
00249 <span class="comment"> double b = scaling.second;</span>
|
||||
00250 <span class="comment"> double n = y.size();</span>
|
||||
00251 <span class="comment"> double se = sqrt( pow(a+b*y-current_set->targets,2.0).sum() / (n-2));</span>
|
||||
00252 <span class="comment"> </span>
|
||||
00253 <span class="comment"> double mean_y = y.sum() / n;</span>
|
||||
00254 <span class="comment"> double sxx = pow( y - mean_y, 2.0).sum();</span>
|
||||
00255 <span class="comment"></span>
|
||||
00256 <span class="comment"> return se / sqrt(sxx);</span>
|
||||
00257 <span class="comment"> }</span>
|
||||
00258 <span class="comment"> </span>
|
||||
00259 <span class="comment"> double scaled_mse(const std::valarray<double>& y){</span>
|
||||
00260 <span class="comment"> std::pair<double,double> scaling;</span>
|
||||
00261 <span class="comment"> return scaled_mse(y,scaling);</span>
|
||||
00262 <span class="comment"> }</span>
|
||||
00263 <span class="comment"> </span>
|
||||
00264 <span class="comment"> double scaled_mse(const std::valarray<double>& y, std::pair<double, double>& scaling)</span>
|
||||
00265 <span class="comment"> {</span>
|
||||
00266 <span class="comment"> scaling = scale(y);</span>
|
||||
00267 <span class="comment"> </span>
|
||||
00268 <span class="comment"> double a = scaling.first;</span>
|
||||
00269 <span class="comment"> double b = scaling.second;</span>
|
||||
00270 <span class="comment"> </span>
|
||||
00271 <span class="comment"> std::valarray<double> tmp = current_set->targets - a - b * y;</span>
|
||||
00272 <span class="comment"> tmp *= tmp;</span>
|
||||
00273 <span class="comment"> </span>
|
||||
00274 <span class="comment"> if (weights.size())</span>
|
||||
00275 <span class="comment"> return (weights * tmp).sum();</span>
|
||||
00276 <span class="comment"></span>
|
||||
00277 <span class="comment"> return tmp.sum() / tmp.size();</span>
|
||||
00278 <span class="comment"> }</span>
|
||||
00279 <span class="comment"> </span>
|
||||
00280 <span class="comment"> double robust_mse(const std::valarray<double>& ny, std::pair<double, double>& scaling) {</span>
|
||||
00281 <span class="comment"> </span>
|
||||
00282 <span class="comment"> double smse = scaled_mse(ny,scaling);</span>
|
||||
00283 <span class="comment"></span>
|
||||
00284 <span class="comment"> std::valarray<double> y = ny;</span>
|
||||
00285 <span class="comment"> // find maximum covariance case </span>
|
||||
00286 <span class="comment"> double n = y.size();</span>
|
||||
00287 <span class="comment"></span>
|
||||
00288 <span class="comment"> int largest = 0;</span>
|
||||
00289 <span class="comment"> </span>
|
||||
00290 <span class="comment"> {</span>
|
||||
00291 <span class="comment"> double y_mean = y.sum() / n;</span>
|
||||
00292 <span class="comment"> </span>
|
||||
00293 <span class="comment"> std::valarray<double> y_var = (y - y_mean);</span>
|
||||
00294 <span class="comment"> std::valarray<double> cov = tcov * y_var;</span>
|
||||
00295 <span class="comment"> </span>
|
||||
00296 <span class="comment"> std::valarray<bool> maxcov = cov == cov.max();</span>
|
||||
00297 <span class="comment"> </span>
|
||||
00298 <span class="comment"> for (unsigned i = 0; i < maxcov.size(); ++i) {</span>
|
||||
00299 <span class="comment"> if (maxcov[i]) {</span>
|
||||
00300 <span class="comment"> largest = i;</span>
|
||||
00301 <span class="comment"> break;</span>
|
||||
00302 <span class="comment"> }</span>
|
||||
00303 <span class="comment"> }</span>
|
||||
00304 <span class="comment"> }</span>
|
||||
00305 <span class="comment"> </span>
|
||||
00306 <span class="comment"> double y_mean = (y.sum() - y[largest]) / (n-1);</span>
|
||||
00307 <span class="comment"> y[largest] = y_mean; // dissappears from covariance calculation</span>
|
||||
00308 <span class="comment"> </span>
|
||||
00309 <span class="comment"> std::valarray<double> y_var = (y - y_mean);</span>
|
||||
00310 <span class="comment"> std::valarray<double> cov = tcov * y_var;</span>
|
||||
00311 <span class="comment"> y_var *= y_var;</span>
|
||||
00312 <span class="comment"></span>
|
||||
00313 <span class="comment"> double sumvar = y_var.sum();</span>
|
||||
00314 <span class="comment"> </span>
|
||||
00315 <span class="comment"> if (sumvar == 0. || sumvar/n < 1e-7 || sumvar/n > 1e+7) // breakout when numerical problems are likely</span>
|
||||
00316 <span class="comment"> return worst_performance();</span>
|
||||
00317 <span class="comment"> </span>
|
||||
00318 <span class="comment"> double b = cov.sum() / sumvar;</span>
|
||||
00319 <span class="comment"> double a = tmean - b * y_mean;</span>
|
||||
00320 <span class="comment"> </span>
|
||||
00321 <span class="comment"> std::valarray<double> tmp = current_set->targets - a - b * y;</span>
|
||||
00322 <span class="comment"> tmp[largest] = 0.0;</span>
|
||||
00323 <span class="comment"> tmp *= tmp;</span>
|
||||
00324 <span class="comment"> </span>
|
||||
00325 <span class="comment"> double smse2 = tmp.sum() / (tmp.size()-1);</span>
|
||||
00326 <span class="comment"> </span>
|
||||
00327 <span class="comment"> static std::ofstream os("smse.txt");</span>
|
||||
00328 <span class="comment"> os << smse << ' ' << smse2 << '\n';</span>
|
||||
00329 <span class="comment"> </span>
|
||||
00330 <span class="comment"> if (smse2 > smse) {</span>
|
||||
00331 <span class="comment"> return worst_performance();</span>
|
||||
00332 <span class="comment"> //std::cerr << "overfit? " << smse << ' ' << smse2 << '\n';</span>
|
||||
00333 <span class="comment"> }</span>
|
||||
00334 <span class="comment"> </span>
|
||||
00335 <span class="comment"> scaling.first = a;</span>
|
||||
00336 <span class="comment"> scaling.second = b;</span>
|
||||
00337 <span class="comment"> </span>
|
||||
00338 <span class="comment"> return smse2;</span>
|
||||
00339 <span class="comment"> }</span>
|
||||
00340 <span class="comment"> </span>
|
||||
00341 <span class="comment"> class Sorter {</span>
|
||||
00342 <span class="comment"> const std::valarray<double>& scores;</span>
|
||||
00343 <span class="comment"> public:</span>
|
||||
00344 <span class="comment"> Sorter(const std::valarray<double>& _scores) : scores(_scores) {}</span>
|
||||
00345 <span class="comment"> </span>
|
||||
00346 <span class="comment"> bool operator()(unsigned i, unsigned j) const {</span>
|
||||
00347 <span class="comment"> return scores[i] < scores[j];</span>
|
||||
00348 <span class="comment"> }</span>
|
||||
00349 <span class="comment"> };</span>
|
||||
00350 <span class="comment"> </span>
|
||||
00351 <span class="comment"> double coc(const std::valarray<double>& y) {</span>
|
||||
00352 <span class="comment"> std::vector<unsigned> indices(y.size());</span>
|
||||
00353 <span class="comment"> for (unsigned i = 0; i < y.size(); ++i) indices[i] = i;</span>
|
||||
00354 <span class="comment"> std::sort(indices.begin(), indices.end(), Sorter(y));</span>
|
||||
00355 <span class="comment"> </span>
|
||||
00356 <span class="comment"> const std::valarray<double>& targets = current_set->targets;</span>
|
||||
00357 <span class="comment"> </span>
|
||||
00358 <span class="comment"> double neg = 1.0 - targets[indices[0]];</span>
|
||||
00359 <span class="comment"> double pos = targets[indices[0]];</span>
|
||||
00360 <span class="comment"> </span>
|
||||
00361 <span class="comment"> double cumpos = 0;</span>
|
||||
00362 <span class="comment"> double cumneg = 0;</span>
|
||||
00363 <span class="comment"> double sum=0;</span>
|
||||
00364 <span class="comment"> </span>
|
||||
00365 <span class="comment"> double last_score = y[indices[0]];</span>
|
||||
00366 <span class="comment"> </span>
|
||||
00367 <span class="comment"> for(unsigned i = 1; i < targets.size(); ++i) {</span>
|
||||
00368 <span class="comment"> </span>
|
||||
00369 <span class="comment"> if (fabs(y[indices[i]] - last_score) < 1e-9) { // we call it tied</span>
|
||||
00370 <span class="comment"> pos += targets[indices[i]];</span>
|
||||
00371 <span class="comment"> neg += 1.0 - targets[indices[i]];</span>
|
||||
00372 <span class="comment"> </span>
|
||||
00373 <span class="comment"> if (i < targets.size()-1)</span>
|
||||
00374 <span class="comment"> continue;</span>
|
||||
00375 <span class="comment"> }</span>
|
||||
00376 <span class="comment"> sum += pos * cumneg + (pos * neg) * 0.5;</span>
|
||||
00377 <span class="comment"> cumneg += neg;</span>
|
||||
00378 <span class="comment"> cumpos += pos;</span>
|
||||
00379 <span class="comment"> pos = targets[indices[i]];</span>
|
||||
00380 <span class="comment"> neg = 1.0 - targets[indices[i]];</span>
|
||||
00381 <span class="comment"> last_score = y[indices[i]];</span>
|
||||
00382 <span class="comment"> }</span>
|
||||
00383 <span class="comment"> </span>
|
||||
00384 <span class="comment"> return sum / (cumneg * cumpos);</span>
|
||||
00385 <span class="comment"> }</span>
|
||||
00386 <span class="comment"> </span>
|
||||
00387 <span class="comment"> // iterative re-weighted least squares (for parameters.classification)</span>
|
||||
00388 <span class="comment"> double irls(const std::valarray<double>& scores, std::pair<double,double>& scaling) {</span>
|
||||
00389 <span class="comment"> const std::valarray<double>& t = current_set->targets;</span>
|
||||
00390 <span class="comment"> </span>
|
||||
00391 <span class="comment"> std::valarray<double> e(scores.size());</span>
|
||||
00392 <span class="comment"> std::valarray<double> u(scores.size()); </span>
|
||||
00393 <span class="comment"> std::valarray<double> w(scores.size());</span>
|
||||
00394 <span class="comment"> std::valarray<double> z(scores.size());</span>
|
||||
00395 <span class="comment"> </span>
|
||||
00396 <span class="comment"> parameters.use_irls = false; parameters.classification=false;</span>
|
||||
00397 <span class="comment"> scaling = scale(scores);</span>
|
||||
00398 <span class="comment"> parameters.use_irls=true;parameters.classification=true;</span>
|
||||
00399 <span class="comment"> </span>
|
||||
00400 <span class="comment"> if (scaling.second == 0.0) return worst_performance(); </span>
|
||||
00401 <span class="comment"> </span>
|
||||
00402 <span class="comment"> for (unsigned i = 0; i < 10; ++i) {</span>
|
||||
00403 <span class="comment"> e = exp(scaling.first + scaling.second*scores);</span>
|
||||
00404 <span class="comment"> u = e / (e + exp(-(scaling.first + scaling.second * scores)));</span>
|
||||
00405 <span class="comment"> w = u*(1.-u);</span>
|
||||
00406 <span class="comment"> z = (t-u)/w;</span>
|
||||
00407 <span class="comment"> scaling = wls(scores, u, w);</span>
|
||||
00408 <span class="comment"> //double ll = (log(u)*t + (1.-log(u))*(1.-t)).sum();</span>
|
||||
00409 <span class="comment"> //std::cout << "Scale " << i << ' ' << scaling.first << " " << scaling.second << " LL " << 2*ll << std::endl;</span>
|
||||
00410 <span class="comment"> }</span>
|
||||
00411 <span class="comment"></span>
|
||||
00412 <span class="comment"> // log-likelihood</span>
|
||||
00413 <span class="comment"> u = exp(scaling.first + scaling.second*scores) / (1 + exp(scaling.first + scaling.second*scores));</span>
|
||||
00414 <span class="comment"> double ll = (log(u)*t + (1.-log(u))*(1.-t)).sum();</span>
|
||||
00415 <span class="comment"> return 2*ll;</span>
|
||||
00416 <span class="comment"> }</span>
|
||||
00417 <span class="comment">*/</span>
|
||||
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:42 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>
|
||||
110
trunk/paradiseo-eo/doc/html/_scaling_8h-source.html
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
<!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: Scaling.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_000008.html">mathsym</a> / <a class="el" href="dir_000012.html">regression</a></div>
|
||||
<h1>Scaling.h</h1><div class="fragment"><pre class="fragment">00001 <span class="comment">/* </span>
|
||||
00002 <span class="comment"> * Copyright (C) 2005 Maarten Keijzer</span>
|
||||
00003 <span class="comment"> *</span>
|
||||
00004 <span class="comment"> * This program is free software; you can redistribute it and/or modify</span>
|
||||
00005 <span class="comment"> * it under the terms of version 2 of the GNU General Public License as </span>
|
||||
00006 <span class="comment"> * published by the Free Software Foundation. </span>
|
||||
00007 <span class="comment"> *</span>
|
||||
00008 <span class="comment"> * This program is distributed in the hope that it will be useful,</span>
|
||||
00009 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
|
||||
00010 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
|
||||
00011 <span class="comment"> * GNU General Public License for more details.</span>
|
||||
00012 <span class="comment"> *</span>
|
||||
00013 <span class="comment"> * You should have received a copy of the GNU General Public License</span>
|
||||
00014 <span class="comment"> * along with this program; if not, write to the Free Software</span>
|
||||
00015 <span class="comment"> * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>
|
||||
00016 <span class="comment"> */</span>
|
||||
00017
|
||||
00018 <span class="preprocessor">#ifndef SCALING_H_</span>
|
||||
00019 <span class="preprocessor"></span><span class="preprocessor">#define SCALING_H_</span>
|
||||
00020 <span class="preprocessor"></span>
|
||||
00021 <span class="preprocessor">#include "shared_ptr.h"</span>
|
||||
00022
|
||||
00023 <span class="preprocessor">#include <valarray></span>
|
||||
00024 <span class="preprocessor">#include <iostream></span>
|
||||
00025 <span class="preprocessor">#include <string></span>
|
||||
00026
|
||||
00027 <span class="keyword">class </span>TargetInfo;
|
||||
00028
|
||||
00029 <span class="keyword">class </span>ScalingBase {
|
||||
00030 <span class="keyword">public</span>:
|
||||
00031
|
||||
00032 <span class="keyword">virtual</span> ~ScalingBase() {}
|
||||
00033
|
||||
00034 std::valarray<double> apply(<span class="keyword">const</span> std::valarray<double>& x) {
|
||||
00035 std::valarray<double> xtmp = x;
|
||||
00036 transform(xtmp);
|
||||
00037 <span class="keywordflow">return</span> xtmp;
|
||||
00038 }
|
||||
00039
|
||||
00040 <span class="keyword">virtual</span> <span class="keywordtype">double</span> transform(<span class="keywordtype">double</span> input) <span class="keyword">const </span>= 0;
|
||||
00041 <span class="keyword">virtual</span> <span class="keywordtype">void</span> transform(std::valarray<double>& inputs) <span class="keyword">const </span>= 0;
|
||||
00042 <span class="keyword">virtual</span> std::ostream& print(std::ostream& os, std::string str) <span class="keyword">const </span>= 0;
|
||||
00043 <span class="keyword">virtual</span> std::valarray<double> transform(<span class="keyword">const</span> std::valarray<double>& inputs) <span class="keyword">const </span>= 0;
|
||||
00044 };
|
||||
00045
|
||||
00046 <span class="keyword">typedef</span> shared_ptr<ScalingBase> Scaling;
|
||||
00047
|
||||
00048 <span class="keyword">class </span>LinearScaling : <span class="keyword">public</span> ScalingBase {
|
||||
00049
|
||||
00050 <span class="keywordtype">double</span> a,b;
|
||||
00051
|
||||
00052 <span class="keyword">public</span>:
|
||||
00053 LinearScaling() : a(0.0), b(1.0) {}
|
||||
00054 LinearScaling(<span class="keywordtype">double</span> _a, <span class="keywordtype">double</span> _b) : a(_a), b(_b) {}
|
||||
00055
|
||||
00056 <span class="keywordtype">double</span> transform(<span class="keywordtype">double</span> input)<span class="keyword"> const </span>{ input *=b; input += a; <span class="keywordflow">return</span> input; }
|
||||
00057 <span class="keywordtype">void</span> transform(std::valarray<double>& inputs)<span class="keyword"> const </span>{ inputs *= b; inputs += a; }
|
||||
00058 std::valarray<double> transform(<span class="keyword">const</span> std::valarray<double>& inputs)<span class="keyword"> const </span>{
|
||||
00059 std::valarray<double> y = a + b * inputs;
|
||||
00060 <span class="keywordflow">return</span> y;
|
||||
00061 }
|
||||
00062
|
||||
00063 <span class="keywordtype">double</span> intercept()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> a; }
|
||||
00064 <span class="keywordtype">double</span> slope()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> b; }
|
||||
00065
|
||||
00066 std::ostream& print(std::ostream& os, std::string str)<span class="keyword"> const </span>{
|
||||
00067 os.precision(16);
|
||||
00068 os << a << <span class="stringliteral">" + "</span> << b << <span class="stringliteral">" * "</span> << str;
|
||||
00069 <span class="keywordflow">return</span> os;
|
||||
00070 }
|
||||
00071 };
|
||||
00072
|
||||
00073 <span class="keyword">class </span>NoScaling : <span class="keyword">public</span> ScalingBase{
|
||||
00074 <span class="keywordtype">void</span> transform(std::valarray<double>&)<span class="keyword"> const </span>{}
|
||||
00075 <span class="keywordtype">double</span> transform(<span class="keywordtype">double</span> input)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> input; }
|
||||
00076 std::valarray<double> transform(<span class="keyword">const</span> std::valarray<double>& inputs)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> inputs; }
|
||||
00077 std::ostream& print(std::ostream& os, std::string str)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> os << str; }
|
||||
00078 };
|
||||
00079
|
||||
00080 <span class="keyword">extern</span> Scaling slope(<span class="keyword">const</span> std::valarray<double>& inputs, <span class="keyword">const</span> TargetInfo& targets); <span class="comment">// slope only</span>
|
||||
00081 <span class="keyword">extern</span> Scaling ols(<span class="keyword">const</span> std::valarray<double>& inputs, <span class="keyword">const</span> TargetInfo& targets);
|
||||
00082 <span class="keyword">extern</span> Scaling wls(<span class="keyword">const</span> std::valarray<double>& inputs, <span class="keyword">const</span> TargetInfo& targets);
|
||||
00083 <span class="keyword">extern</span> Scaling med(<span class="keyword">const</span> std::valarray<double>& inputs, <span class="keyword">const</span> TargetInfo& targets);
|
||||
00084
|
||||
00085 <span class="keyword">extern</span> Scaling ols(<span class="keyword">const</span> std::valarray<double>& inputs, <span class="keyword">const</span> std::valarray<double>& outputs);
|
||||
00086
|
||||
00087 <span class="keyword">extern</span> <span class="keywordtype">double</span> mse(<span class="keyword">const</span> std::valarray<double>& y, <span class="keyword">const</span> TargetInfo& t);
|
||||
00088 <span class="keyword">extern</span> <span class="keywordtype">double</span> rms(<span class="keyword">const</span> std::valarray<double>& y, <span class="keyword">const</span> TargetInfo& t);
|
||||
00089 <span class="keyword">extern</span> <span class="keywordtype">double</span> mae(<span class="keyword">const</span> std::valarray<double>& y, <span class="keyword">const</span> TargetInfo& t);
|
||||
00090
|
||||
00091 <span class="comment">// Todo Logistic Scaling</span>
|
||||
00092
|
||||
00093 <span class="preprocessor">#endif</span>
|
||||
00094 <span class="preprocessor"></span>
|
||||
00095
|
||||
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:42 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>
|
||||
351
trunk/paradiseo-eo/doc/html/_second_bit_e_a_8cpp-source.html
Normal file
|
|
@ -0,0 +1,351 @@
|
|||
<!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: SecondBitEA.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_000003.html">tutorial</a> / <a class="el" href="dir_000005.html">Lesson3</a></div>
|
||||
<h1>SecondBitEA.cpp</h1><div class="fragment"><pre class="fragment">00001 <span class="comment">//-----------------------------------------------------------------------------</span>
|
||||
00002 <span class="comment">// SecondGA.cpp</span>
|
||||
00003 <span class="comment">//-----------------------------------------------------------------------------</span>
|
||||
00004 <span class="comment">//*</span>
|
||||
00005 <span class="comment">// Same code than FirstBitEA as far as Evolutionary Computation is concerned</span>
|
||||
00006 <span class="comment">// but now you learn to enter the parameters in a more flexible way</span>
|
||||
00007 <span class="comment">// and to twidle the output to your preferences!</span>
|
||||
00008 <span class="comment">//-----------------------------------------------------------------------------</span>
|
||||
00009 <span class="preprocessor">#ifdef HAVE_CONFIG_H</span>
|
||||
00010 <span class="preprocessor"></span><span class="preprocessor">#include <config.h></span>
|
||||
00011 <span class="preprocessor">#endif</span>
|
||||
00012 <span class="preprocessor"></span>
|
||||
00013 <span class="comment">// standard includes</span>
|
||||
00014 <span class="preprocessor">#include <fstream></span>
|
||||
00015 <span class="preprocessor">#include <iostream></span> <span class="comment">// cout</span>
|
||||
00016 <span class="preprocessor">#include <stdexcept></span> <span class="comment">// runtime_error</span>
|
||||
00017
|
||||
00018 <span class="comment">// the general include for eo</span>
|
||||
00019 <span class="preprocessor">#include <eo></span>
|
||||
00020 <span class="preprocessor">#include <ga.h></span>
|
||||
00021
|
||||
00022 <span class="comment">// Use functions from namespace std</span>
|
||||
00023 <span class="keyword">using</span> <span class="keyword">namespace </span>std;
|
||||
00024
|
||||
00025 <span class="comment">// EVAL</span>
|
||||
00026 <span class="preprocessor">#include "binary_value.h"</span>
|
||||
00027
|
||||
00028 <span class="comment">// REPRESENTATION</span>
|
||||
00029 <span class="comment">//-----------------------------------------------------------------------------</span>
|
||||
00030 <span class="comment">// define your genotype and fitness types</span>
|
||||
00031 <span class="keyword">typedef</span> <a class="code" href="classeo_bit.html">eoBit<double></a> <a class="code" href="classeo_real.html">Indi</a>;
|
||||
00032
|
||||
00033 <span class="comment">// the main_function: nothing changed(!), except variable initialization</span>
|
||||
00034 <span class="keywordtype">void</span> main_function(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> **argv)
|
||||
00035 {
|
||||
00036 <span class="comment">// PARAMETRES</span>
|
||||
00037 <span class="comment">//-----------------------------------------------------------------------------</span>
|
||||
00038 <span class="comment">// instead of having all values of useful parameters as constants, read them:</span>
|
||||
00039 <span class="comment">// either on the command line (--option=value or -o=value)</span>
|
||||
00040 <span class="comment">// or in a parameter file (same syntax, order independent,</span>
|
||||
00041 <span class="comment">// # = usual comment character</span>
|
||||
00042 <span class="comment">// or in the environment (TODO)</span>
|
||||
00043
|
||||
00044 <span class="comment">// First define a parser from the command-line arguments</span>
|
||||
00045 eoParser parser(argc, argv);
|
||||
00046
|
||||
00047 <span class="comment">// For each parameter, define Parameter, read it through the parser,</span>
|
||||
00048 <span class="comment">// and assign the value to the variable</span>
|
||||
00049
|
||||
00050 <a class="code" href="classeo_value_param.html">eoValueParam<uint32_t></a> seedParam(time(0), <span class="stringliteral">"seed"</span>, <span class="stringliteral">"Random number seed"</span>, <span class="charliteral">'S'</span>);
|
||||
00051 parser.processParam( seedParam );
|
||||
00052 <span class="keywordtype">unsigned</span> seed = seedParam.value();
|
||||
00053
|
||||
00054 <span class="comment">// description of genotype</span>
|
||||
00055 <a class="code" href="classeo_value_param.html">eoValueParam<unsigned int></a> vecSizeParam(8, <span class="stringliteral">"vecSize"</span>, <span class="stringliteral">"Genotype size"</span>,<span class="charliteral">'V'</span>);
|
||||
00056 parser.processParam( vecSizeParam, <span class="stringliteral">"Representation"</span> );
|
||||
00057 <span class="keywordtype">unsigned</span> vecSize = vecSizeParam.value();
|
||||
00058
|
||||
00059 <span class="comment">// parameters for evolution engine</span>
|
||||
00060 <a class="code" href="classeo_value_param.html">eoValueParam<unsigned int></a> popSizeParam(10, <span class="stringliteral">"popSize"</span>, <span class="stringliteral">"Population size"</span>,<span class="charliteral">'P'</span>);
|
||||
00061 parser.processParam( popSizeParam, <span class="stringliteral">"Evolution engine"</span> );
|
||||
00062 <span class="keywordtype">unsigned</span> popSize = popSizeParam.value();
|
||||
00063
|
||||
00064 <a class="code" href="classeo_value_param.html">eoValueParam<unsigned int></a> tSizeParam(10, <span class="stringliteral">"tSize"</span>, <span class="stringliteral">"Tournament size"</span>,<span class="charliteral">'T'</span>);
|
||||
00065 parser.processParam( tSizeParam, <span class="stringliteral">"Evolution Engine"</span> );
|
||||
00066 <span class="keywordtype">unsigned</span> tSize = tSizeParam.value();
|
||||
00067
|
||||
00068 <span class="comment">// init and stop</span>
|
||||
00069 <a class="code" href="classeo_value_param.html">eoValueParam<string></a> loadNameParam(<span class="stringliteral">""</span>, <span class="stringliteral">"Load"</span>,<span class="stringliteral">"A save file to restart from"</span>,<span class="charliteral">'L'</span>);
|
||||
00070 parser.processParam( loadNameParam, <span class="stringliteral">"Persistence"</span> );
|
||||
00071 string loadName = loadNameParam.value();
|
||||
00072
|
||||
00073 <a class="code" href="classeo_value_param.html">eoValueParam<unsigned int></a> maxGenParam(100, <span class="stringliteral">"maxGen"</span>, <span class="stringliteral">"Maximum number of generations"</span>,<span class="charliteral">'G'</span>);
|
||||
00074 parser.processParam( maxGenParam, <span class="stringliteral">"Stopping criterion"</span> );
|
||||
00075 <span class="keywordtype">unsigned</span> maxGen = maxGenParam.value();
|
||||
00076
|
||||
00077 <a class="code" href="classeo_value_param.html">eoValueParam<unsigned int></a> minGenParam(100, <span class="stringliteral">"minGen"</span>, <span class="stringliteral">"Minimum number of generations"</span>,<span class="charliteral">'g'</span>);
|
||||
00078 parser.processParam( minGenParam, <span class="stringliteral">"Stopping criterion"</span> );
|
||||
00079 <span class="keywordtype">unsigned</span> minGen = minGenParam.value();
|
||||
00080
|
||||
00081 <a class="code" href="classeo_value_param.html">eoValueParam<unsigned int></a> steadyGenParam(100, <span class="stringliteral">"steadyGen"</span>, <span class="stringliteral">"Number of generations with no improvement"</span>,<span class="charliteral">'s'</span>);
|
||||
00082 parser.processParam( steadyGenParam, <span class="stringliteral">"Stopping criterion"</span> );
|
||||
00083 <span class="keywordtype">unsigned</span> steadyGen = steadyGenParam.value();
|
||||
00084
|
||||
00085 <span class="comment">// operators probabilities at the algorithm level</span>
|
||||
00086 <a class="code" href="classeo_value_param.html">eoValueParam<double></a> pCrossParam(0.6, <span class="stringliteral">"pCross"</span>, <span class="stringliteral">"Probability of Crossover"</span>, <span class="charliteral">'C'</span>);
|
||||
00087 parser.processParam( pCrossParam, <span class="stringliteral">"Genetic Operators"</span> );
|
||||
00088 <span class="keywordtype">double</span> pCross = pCrossParam.value();
|
||||
00089
|
||||
00090 <a class="code" href="classeo_value_param.html">eoValueParam<double></a> pMutParam(0.1, <span class="stringliteral">"pMut"</span>, <span class="stringliteral">"Probability of Mutation"</span>, <span class="charliteral">'M'</span>);
|
||||
00091 parser.processParam( pMutParam, <span class="stringliteral">"Genetic Operators"</span> );
|
||||
00092 <span class="keywordtype">double</span> pMut = pMutParam.value();
|
||||
00093
|
||||
00094 <span class="comment">// relative rates for crossovers</span>
|
||||
00095 <a class="code" href="classeo_value_param.html">eoValueParam<double></a> onePointRateParam(1, <span class="stringliteral">"onePointRate"</span>, <span class="stringliteral">"Relative rate for one point crossover"</span>, <span class="charliteral">'1'</span>);
|
||||
00096 parser.processParam( onePointRateParam, <span class="stringliteral">"Genetic Operators"</span> );
|
||||
00097 <span class="keywordtype">double</span> onePointRate = onePointRateParam.value();
|
||||
00098
|
||||
00099 <a class="code" href="classeo_value_param.html">eoValueParam<double></a> twoPointsRateParam(1, <span class="stringliteral">"twoPointRate"</span>, <span class="stringliteral">"Relative rate for two point crossover"</span>, <span class="charliteral">'2'</span>);
|
||||
00100 parser.processParam( twoPointsRateParam, <span class="stringliteral">"Genetic Operators"</span> );
|
||||
00101 <span class="keywordtype">double</span> twoPointsRate = twoPointsRateParam.value();
|
||||
00102
|
||||
00103 <a class="code" href="classeo_value_param.html">eoValueParam<double></a> uRateParam(2, <span class="stringliteral">"uRate"</span>, <span class="stringliteral">"Relative rate for uniform crossover"</span>, <span class="charliteral">'U'</span>);
|
||||
00104 parser.processParam( uRateParam, <span class="stringliteral">"Genetic Operators"</span> );
|
||||
00105 <span class="keywordtype">double</span> URate = uRateParam.value();
|
||||
00106
|
||||
00107 <span class="comment">// relative rates and private parameters for mutations;</span>
|
||||
00108 <a class="code" href="classeo_value_param.html">eoValueParam<double></a> pMutPerBitParam(0.01, <span class="stringliteral">"pMutPerBit"</span>, <span class="stringliteral">"Probability of flipping 1 bit in bit-flip mutation"</span>, <span class="charliteral">'b'</span>);
|
||||
00109 parser.processParam( pMutPerBitParam, <span class="stringliteral">"Genetic Operators"</span> );
|
||||
00110 <span class="keywordtype">double</span> pMutPerBit = pMutPerBitParam.value();
|
||||
00111
|
||||
00112 <a class="code" href="classeo_value_param.html">eoValueParam<double></a> bitFlipRateParam(0.01, <span class="stringliteral">"bitFlipRate"</span>, <span class="stringliteral">"Relative rate for bit-flip mutation"</span>, <span class="charliteral">'B'</span>);
|
||||
00113 parser.processParam( bitFlipRateParam, <span class="stringliteral">"Genetic Operators"</span> );
|
||||
00114 <span class="keywordtype">double</span> bitFlipRate = bitFlipRateParam.value();
|
||||
00115
|
||||
00116 <a class="code" href="classeo_value_param.html">eoValueParam<double></a> oneBitRateParam(0.01, <span class="stringliteral">"oneBitRate"</span>, <span class="stringliteral">"Relative rate for deterministic bit-flip mutation"</span>, <span class="charliteral">'D'</span>);
|
||||
00117 parser.processParam( oneBitRateParam, <span class="stringliteral">"Genetic Operators"</span> );
|
||||
00118 <span class="keywordtype">double</span> oneBitRate = oneBitRateParam.value();
|
||||
00119
|
||||
00120 <span class="comment">// the name of the "status" file where all actual parameter values will be saved</span>
|
||||
00121 string str_status = parser.ProgramName() + <span class="stringliteral">".status"</span>; <span class="comment">// default value</span>
|
||||
00122 <a class="code" href="classeo_value_param.html">eoValueParam<string></a> statusParam(str_status.c_str(), <span class="stringliteral">"status"</span>,<span class="stringliteral">"Status file"</span>,<span class="charliteral">'S'</span>);
|
||||
00123 parser.processParam( statusParam, <span class="stringliteral">"Persistence"</span> );
|
||||
00124
|
||||
00125 <span class="comment">// do the following AFTER ALL PARAMETERS HAVE BEEN PROCESSED</span>
|
||||
00126 <span class="comment">// i.e. in case you need parameters somewhere else, postpone these</span>
|
||||
00127 <span class="keywordflow">if</span> (parser.userNeedsHelp())
|
||||
00128 {
|
||||
00129 parser.printHelp(cout);
|
||||
00130 exit(1);
|
||||
00131 }
|
||||
00132 <span class="keywordflow">if</span> (statusParam.value() != <span class="stringliteral">""</span>)
|
||||
00133 {
|
||||
00134 ofstream os(statusParam.value().c_str());
|
||||
00135 os << parser; <span class="comment">// and you can use that file as parameter file</span>
|
||||
00136 }
|
||||
00137
|
||||
00138 <span class="comment">// EVAL</span>
|
||||
00140 <span class="comment"></span> <span class="comment">// Fitness function</span>
|
||||
00142 <span class="comment"></span> <span class="comment">// Evaluation: from a plain C++ fn to an EvalFunc Object ...</span>
|
||||
00143 <a class="code" href="structeo_eval_func_ptr.html">eoEvalFuncPtr<Indi, double, const vector<bool></a>& > plainEval( binary_value );
|
||||
00144 <span class="comment">// ... to an object that counts the nb of actual evaluations</span>
|
||||
00145 <a class="code" href="classeo_eval_func_counter.html">eoEvalFuncCounter<Indi></a> eval(plainEval);
|
||||
00146
|
||||
00147 <span class="comment">// INIT</span>
|
||||
00149 <span class="comment"></span> <span class="comment">// Initilisation of population</span>
|
||||
00151 <span class="comment"></span> <span class="comment">// Either load or initialize</span>
|
||||
00152 <span class="comment">// create an empty pop</span>
|
||||
00153 <a class="code" href="classeo_pop.html">eoPop<Indi></a> pop;
|
||||
00154 <span class="comment">// create a state for reading</span>
|
||||
00155 <a class="code" href="classeo_state.html">eoState</a> inState; <span class="comment">// a state for loading - WITHOUT the parser</span>
|
||||
00156 <span class="comment">// register the rng and the pop in the state, so they can be loaded,</span>
|
||||
00157 <span class="comment">// and the present run will be the exact conitnuation of the saved run</span>
|
||||
00158 <span class="comment">// eventually with different parameters</span>
|
||||
00159 inState.<a class="code" href="classeo_state.html#a2">registerObject</a>(rng);
|
||||
00160 inState.<a class="code" href="classeo_state.html#a2">registerObject</a>(pop);
|
||||
00161
|
||||
00162 <span class="keywordflow">if</span> (loadName != <span class="stringliteral">""</span>)
|
||||
00163 {
|
||||
00164 inState.<a class="code" href="classeo_state.html#a5">load</a>(loadName); <span class="comment">// load the pop and the rng</span>
|
||||
00165 <span class="comment">// the fitness is read in the file:</span>
|
||||
00166 <span class="comment">// do only evaluate the pop if the fitness has changed</span>
|
||||
00167 }
|
||||
00168 <span class="keywordflow">else</span>
|
||||
00169 {
|
||||
00170 rng.<a class="code" href="classeo_rng.html#a2">reseed</a>(seed);
|
||||
00171 <span class="comment">// a Indi random initializer</span>
|
||||
00172 <span class="comment">// based on boolean_generator class (see utils/rnd_generator.h)</span>
|
||||
00173 <a class="code" href="classeo_uniform_generator.html">eoUniformGenerator<bool></a> uGen;
|
||||
00174 <a class="code" href="classeo_init_fixed_length.html">eoInitFixedLength<Indi></a> random(vecSize, uGen);
|
||||
00175
|
||||
00176 <span class="comment">// Init pop from the randomizer: need to use the append function</span>
|
||||
00177 pop.<a class="code" href="classeo_pop.html#a2">append</a>(popSize, random);
|
||||
00178 <span class="comment">// and evaluate pop (STL syntax)</span>
|
||||
00179 apply<Indi>(eval, pop);
|
||||
00180 } <span class="comment">// end of initializatio of the population</span>
|
||||
00181
|
||||
00182 <span class="comment">// OUTPUT</span>
|
||||
00183 <span class="comment">// sort pop for pretty printout</span>
|
||||
00184 pop.<a class="code" href="classeo_pop.html#a5">sort</a>();
|
||||
00185 <span class="comment">// Print (sorted) intial population (raw printout)</span>
|
||||
00186 cout << <span class="stringliteral">"Initial Population"</span> << endl << pop << endl;
|
||||
00187
|
||||
00188 <span class="comment">// ENGINE</span>
|
||||
00190 <span class="comment"></span> <span class="comment">// selection and replacement</span>
|
||||
00192 <span class="comment"></span><span class="comment">// SELECT</span>
|
||||
00193 <span class="comment">// The robust tournament selection</span>
|
||||
00194 <a class="code" href="classeo_det_tournament_select.html">eoDetTournamentSelect<Indi></a> selectOne(tSize); <span class="comment">// tSize in [2,POPSIZE]</span>
|
||||
00195 <span class="comment">// is now encapsulated in a eoSelectPerc (stands for Percentage)</span>
|
||||
00196 <a class="code" href="classeo_select_perc.html">eoSelectPerc<Indi></a> select(selectOne);
|
||||
00197
|
||||
00198 <span class="comment">// REPLACE</span>
|
||||
00199 <span class="comment">// And we now have the full slection/replacement - though with</span>
|
||||
00200 <span class="comment">// the same generational replacement at the moment :-)</span>
|
||||
00201 <a class="code" href="classeo_generational_replacement.html">eoGenerationalReplacement<Indi></a> replace;
|
||||
00202
|
||||
00203 <span class="comment">// OPERATORS</span>
|
||||
00205 <span class="comment"></span> <span class="comment">// The variation operators</span>
|
||||
00207 <span class="comment"></span><span class="comment">// CROSSOVER</span>
|
||||
00208 <span class="comment">// 1-point crossover for bitstring</span>
|
||||
00209 eo1PtBitXover<Indi> xover1;
|
||||
00210 <span class="comment">// uniform crossover for bitstring</span>
|
||||
00211 <a class="code" href="classeo_u_bit_xover.html">eoUBitXover<Indi></a> xoverU;
|
||||
00212 <span class="comment">// 2-pots xover</span>
|
||||
00213 <a class="code" href="classeo_n_pts_bit_xover.html">eoNPtsBitXover<Indi></a> xover2(2);
|
||||
00214 <span class="comment">// Combine them with relative rates</span>
|
||||
00215 <a class="code" href="classeo_prop_combined_quad_op.html">eoPropCombinedQuadOp<Indi></a> xover(xover1, onePointRate);
|
||||
00216 xover.add(xoverU, URate);
|
||||
00217 xover.add(xover2, twoPointsRate, <span class="keyword">true</span>);
|
||||
00218
|
||||
00219 <span class="comment">// MUTATION</span>
|
||||
00220 <span class="comment">// standard bit-flip mutation for bitstring</span>
|
||||
00221 <a class="code" href="classeo_bit_mutation.html">eoBitMutation<Indi></a> mutationBitFlip(pMutPerBit);
|
||||
00222 <span class="comment">// mutate exactly 1 bit per individual</span>
|
||||
00223 <a class="code" href="classeo_det_bit_flip.html">eoDetBitFlip<Indi></a> mutationOneBit;
|
||||
00224 <span class="comment">// Combine them with relative rates</span>
|
||||
00225 <a class="code" href="classeo_prop_combined_mon_op.html">eoPropCombinedMonOp<Indi></a> mutation(mutationBitFlip, bitFlipRate);
|
||||
00226 mutation.add(mutationOneBit, oneBitRate, <span class="keyword">true</span>);
|
||||
00227
|
||||
00228 <span class="comment">// The operators are encapsulated into an eoTRansform object</span>
|
||||
00229 <a class="code" href="classeo_s_g_a_transform.html">eoSGATransform<Indi></a> transform(xover, pCross, mutation, pMut);
|
||||
00230
|
||||
00231 <span class="comment">// STOP</span>
|
||||
00233 <span class="comment"></span> <span class="comment">// termination condition see FirstBitEA.cpp</span>
|
||||
00235 <span class="comment"></span> <a class="code" href="classeo_gen_continue.html">eoGenContinue<Indi></a> genCont(maxGen);
|
||||
00236 <a class="code" href="classeo_steady_fit_continue.html">eoSteadyFitContinue<Indi></a> steadyCont(minGen, steadyGen);
|
||||
00237 <a class="code" href="classeo_fit_continue.html">eoFitContinue<Indi></a> fitCont(vecSize);
|
||||
00238 <a class="code" href="classeo_combined_continue.html">eoCombinedContinue<Indi></a> continuator(genCont);
|
||||
00239 continuator.add(steadyCont);
|
||||
00240 continuator.add(fitCont);
|
||||
00241
|
||||
00242
|
||||
00243 <span class="comment">// CHECKPOINT</span>
|
||||
00244 <span class="comment">// but now you want to make many different things every generation</span>
|
||||
00245 <span class="comment">// (e.g. statistics, plots, ...).</span>
|
||||
00246 <span class="comment">// the class eoCheckPoint is dedicated to just that:</span>
|
||||
00247
|
||||
00248 <span class="comment">// Declare a checkpoint (from a continuator: an eoCheckPoint</span>
|
||||
00249 <span class="comment">// IS AN eoContinue and will be called in the loop of all algorithms)</span>
|
||||
00250 <a class="code" href="classeo_check_point.html">eoCheckPoint<Indi></a> checkpoint(continuator);
|
||||
00251
|
||||
00252 <span class="comment">// Create a counter parameter</span>
|
||||
00253 <a class="code" href="classeo_value_param.html">eoValueParam<unsigned></a> generationCounter(0, <span class="stringliteral">"Gen."</span>);
|
||||
00254
|
||||
00255 <span class="comment">// Create an incrementor (sub-class of eoUpdater). Note that the</span>
|
||||
00256 <span class="comment">// parameter's value is passed by reference,</span>
|
||||
00257 <span class="comment">// so every time the incrementer is updated (every generation),</span>
|
||||
00258 <span class="comment">// the data in generationCounter will change.</span>
|
||||
00259 <a class="code" href="classeo_incrementor.html">eoIncrementor<unsigned></a> increment(generationCounter.value());
|
||||
00260
|
||||
00261 <span class="comment">// Add it to the checkpoint,</span>
|
||||
00262 <span class="comment">// so the counter is updated (here, incremented) every generation</span>
|
||||
00263 checkpoint.add(increment);
|
||||
00264
|
||||
00265 <span class="comment">// now some statistics on the population:</span>
|
||||
00266 <span class="comment">// Best fitness in population</span>
|
||||
00267 <a class="code" href="classeo_best_fitness_stat.html">eoBestFitnessStat<Indi></a> bestStat;
|
||||
00268 <span class="comment">// Second moment stats: average and stdev</span>
|
||||
00269 <a class="code" href="classeo_second_moment_stats.html">eoSecondMomentStats<Indi></a> SecondStat;
|
||||
00270
|
||||
00271 <span class="comment">// Add them to the checkpoint to get them called at the appropriate time</span>
|
||||
00272 checkpoint.add(bestStat);
|
||||
00273 checkpoint.add(SecondStat);
|
||||
00274
|
||||
00275 <span class="comment">// The Stdout monitor will print parameters to the screen ...</span>
|
||||
00276 <a class="code" href="classeo_stdout_monitor.html">eoStdoutMonitor</a> monitor(<span class="keyword">false</span>);
|
||||
00277
|
||||
00278 <span class="comment">// when called by the checkpoint (i.e. at every generation)</span>
|
||||
00279 checkpoint.add(monitor);
|
||||
00280
|
||||
00281 <span class="comment">// the monitor will output a series of parameters: add them</span>
|
||||
00282 monitor.add(generationCounter);
|
||||
00283 monitor.add(eval); <span class="comment">// because now eval is an eoEvalFuncCounter!</span>
|
||||
00284 monitor.add(bestStat);
|
||||
00285 monitor.add(SecondStat);
|
||||
00286
|
||||
00287 <span class="comment">// A file monitor: will print parameters to ... a File, yes, you got it!</span>
|
||||
00288 <a class="code" href="classeo_file_monitor.html">eoFileMonitor</a> fileMonitor(<span class="stringliteral">"stats.xg"</span>, <span class="stringliteral">" "</span>);
|
||||
00289
|
||||
00290 <span class="comment">// the checkpoint mechanism can handle multiple monitors</span>
|
||||
00291 checkpoint.add(fileMonitor);
|
||||
00292
|
||||
00293 <span class="comment">// the fileMonitor can monitor parameters, too, but you must tell it!</span>
|
||||
00294 fileMonitor.add(generationCounter);
|
||||
00295 fileMonitor.add(bestStat);
|
||||
00296 fileMonitor.add(SecondStat);
|
||||
00297
|
||||
00298 <span class="comment">// Last type of item the eoCheckpoint can handle: state savers:</span>
|
||||
00299 <a class="code" href="classeo_state.html">eoState</a> outState;
|
||||
00300 <span class="comment">// Register the algorithm into the state (so it has something to save!!)</span>
|
||||
00301 outState.<a class="code" href="classeo_state.html#a2">registerObject</a>(parser);
|
||||
00302 outState.<a class="code" href="classeo_state.html#a2">registerObject</a>(pop);
|
||||
00303 outState.<a class="code" href="classeo_state.html#a2">registerObject</a>(rng);
|
||||
00304
|
||||
00305 <span class="comment">// and feed the state to state savers</span>
|
||||
00306 <span class="comment">// save state every 100th generation</span>
|
||||
00307 <a class="code" href="classeo_counted_state_saver.html">eoCountedStateSaver</a> stateSaver1(20, outState, <span class="stringliteral">"generation"</span>);
|
||||
00308 <span class="comment">// save state every 1 seconds</span>
|
||||
00309 <a class="code" href="classeo_timed_state_saver.html">eoTimedStateSaver</a> stateSaver2(1, outState, <span class="stringliteral">"time"</span>);
|
||||
00310
|
||||
00311 <span class="comment">// Don't forget to add the two savers to the checkpoint</span>
|
||||
00312 checkpoint.add(stateSaver1);
|
||||
00313 checkpoint.add(stateSaver2);
|
||||
00314 <span class="comment">// and that's it for the (control and) output</span>
|
||||
00315
|
||||
00316 <span class="comment">// GENERATION</span>
|
||||
00318 <span class="comment"></span> <span class="comment">// the algorithm</span>
|
||||
00320 <span class="comment"></span>
|
||||
00321 <span class="comment">// Easy EA requires</span>
|
||||
00322 <span class="comment">// stopping criterion, eval, selection, transformation, replacement</span>
|
||||
00323 <a class="code" href="classeo_easy_e_a.html">eoEasyEA<Indi></a> gga(checkpoint, eval, select, transform, replace);
|
||||
00324
|
||||
00325 <span class="comment">// Apply algo to pop - that's it!</span>
|
||||
00326 gga(pop);
|
||||
00327
|
||||
00328 <span class="comment">// OUTPUT</span>
|
||||
00329 <span class="comment">// Print (sorted) intial population</span>
|
||||
00330 pop.<a class="code" href="classeo_pop.html#a5">sort</a>();
|
||||
00331 cout << <span class="stringliteral">"FINAL Population\n"</span> << pop << endl;
|
||||
00332 <span class="comment">// GENERAL</span>
|
||||
00333 }
|
||||
00334
|
||||
00335 <span class="comment">// A main that catches the exceptions</span>
|
||||
00336 <span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> **argv)
|
||||
00337 {
|
||||
00338 <span class="keywordflow">try</span>
|
||||
00339 {
|
||||
00340 main_function(argc, argv);
|
||||
00341 }
|
||||
00342 <span class="keywordflow">catch</span>(exception& e)
|
||||
00343 {
|
||||
00344 cout << <span class="stringliteral">"Exception: "</span> << e.what() << <span class="charliteral">'\n'</span>;
|
||||
00345 }
|
||||
00346
|
||||
00347 <span class="keywordflow">return</span> 1;
|
||||
00348 }
|
||||
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:42 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>
|
||||
332
trunk/paradiseo-eo/doc/html/_second_real_e_a_8cpp-source.html
Normal file
|
|
@ -0,0 +1,332 @@
|
|||
<!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: SecondRealEA.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_000003.html">tutorial</a> / <a class="el" href="dir_000005.html">Lesson3</a></div>
|
||||
<h1>SecondRealEA.cpp</h1><div class="fragment"><pre class="fragment">00001 <span class="comment">//-----------------------------------------------------------------------------</span>
|
||||
00002 <span class="comment">// SecondRealEA.cpp</span>
|
||||
00003 <span class="comment">//-----------------------------------------------------------------------------</span>
|
||||
00004 <span class="comment">//*</span>
|
||||
00005 <span class="comment">// Same code than FirstBitEA as far as Evolutionary Computation is concerned</span>
|
||||
00006 <span class="comment">// but now you learn to enter the parameters in a more flexible way</span>
|
||||
00007 <span class="comment">// (also slightly different than in SecondBitEA.cpp)</span>
|
||||
00008 <span class="comment">// and to twidle the output to your preferences (as in SecondBitEA.cpp)</span>
|
||||
00009 <span class="comment">//</span>
|
||||
00010 <span class="comment">//-----------------------------------------------------------------------------</span>
|
||||
00011 <span class="preprocessor">#ifdef HAVE_CONFIG_H</span>
|
||||
00012 <span class="preprocessor"></span><span class="preprocessor">#include <config.h></span>
|
||||
00013 <span class="preprocessor">#endif</span>
|
||||
00014 <span class="preprocessor"></span>
|
||||
00015 <span class="comment">// standard includes</span>
|
||||
00016 <span class="preprocessor">#include <fstream></span>
|
||||
00017 <span class="preprocessor">#include <iostream></span> <span class="comment">// cout</span>
|
||||
00018 <span class="preprocessor">#include <stdexcept></span> <span class="comment">// runtime_error</span>
|
||||
00019
|
||||
00020 <span class="comment">// the general include for eo</span>
|
||||
00021 <span class="preprocessor">#include <eo></span>
|
||||
00022 <span class="preprocessor">#include <es.h></span>
|
||||
00023
|
||||
00024 <span class="comment">// REPRESENTATION</span>
|
||||
00025 <span class="comment">//-----------------------------------------------------------------------------</span>
|
||||
00026 <span class="comment">// define your individuals</span>
|
||||
00027 <span class="keyword">typedef</span> <a class="code" href="classeo_real.html">eoReal<eoMinimizingFitness></a> <a class="code" href="classeo_real.html">Indi</a>;
|
||||
00028
|
||||
00029 <span class="comment">// Use functions from namespace std</span>
|
||||
00030 <span class="keyword">using</span> <span class="keyword">namespace </span>std;
|
||||
00031
|
||||
00032 <span class="comment">// EVALFUNC</span>
|
||||
00033 <span class="comment">//-----------------------------------------------------------------------------</span>
|
||||
00034 <span class="comment">// a simple fitness function that computes the euclidian norm of a real vector</span>
|
||||
00035 <span class="comment">// Now in a separate file, and declared as binary_value(const vector<bool> &)</span>
|
||||
00036
|
||||
00037 <span class="preprocessor">#include "real_value.h"</span>
|
||||
00038
|
||||
00039 <span class="comment">// GENERAL</span>
|
||||
00040 <span class="comment">//-----------------------------------------------------------------------------</span>
|
||||
00041
|
||||
00042 <span class="keywordtype">void</span> main_function(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> **argv)
|
||||
00043 {
|
||||
00044 <span class="comment">// PARAMETRES</span>
|
||||
00045 <span class="comment">//-----------------------------------------------------------------------------</span>
|
||||
00046 <span class="comment">// instead of having all values of useful parameters as constants, read them:</span>
|
||||
00047 <span class="comment">// either on the command line (--option=value or -o=value)</span>
|
||||
00048 <span class="comment">// or in a parameter file (same syntax, order independent,</span>
|
||||
00049 <span class="comment">// # = usual comment character</span>
|
||||
00050 <span class="comment">// or in the environment (TODO)</span>
|
||||
00051
|
||||
00052 <span class="comment">// First define a parser from the command-line arguments</span>
|
||||
00053 eoParser parser(argc, argv);
|
||||
00054
|
||||
00055 <span class="comment">// For each parameter, you can in on single line</span>
|
||||
00056 <span class="comment">// define the parameter, read it through the parser, and assign it</span>
|
||||
00057
|
||||
00058 <span class="keywordtype">unsigned</span> seed = parser.createParam(<span class="keywordtype">unsigned</span>(time(0)), <span class="stringliteral">"seed"</span>, <span class="stringliteral">"Random number seed"</span>, <span class="charliteral">'S'</span>).value(); <span class="comment">// will be in default section General</span>
|
||||
00059
|
||||
00060 <span class="comment">// description of genotype</span>
|
||||
00061 <span class="keywordtype">unsigned</span> vecSize = parser.createParam(<span class="keywordtype">unsigned</span>(8), <span class="stringliteral">"vecSize"</span>, <span class="stringliteral">"Genotype size"</span>,<span class="charliteral">'V'</span>, <span class="stringliteral">"Representation"</span> ).value();
|
||||
00062
|
||||
00063 <span class="comment">// parameters for evolution engine</span>
|
||||
00064 <span class="keywordtype">unsigned</span> popSize = parser.createParam(<span class="keywordtype">unsigned</span>(10), <span class="stringliteral">"popSize"</span>, <span class="stringliteral">"Population size"</span>,<span class="charliteral">'P'</span>, <span class="stringliteral">"Evolution engine"</span> ).value();
|
||||
00065
|
||||
00066 <span class="keywordtype">unsigned</span> tSize = parser.createParam(<span class="keywordtype">unsigned</span>(2), <span class="stringliteral">"tSize"</span>, <span class="stringliteral">"Tournament size"</span>,<span class="charliteral">'T'</span>, <span class="stringliteral">"Evolution Engine"</span> ).value();
|
||||
00067
|
||||
00068 <span class="comment">// init and stop</span>
|
||||
00069 string loadName = parser.createParam(string(<span class="stringliteral">""</span>), <span class="stringliteral">"Load"</span>,<span class="stringliteral">"A save file to restart from"</span>,<span class="charliteral">'L'</span>, <span class="stringliteral">"Persistence"</span> ).value();
|
||||
00070
|
||||
00071 <span class="keywordtype">unsigned</span> maxGen = parser.createParam(<span class="keywordtype">unsigned</span>(100), <span class="stringliteral">"maxGen"</span>, <span class="stringliteral">"Maximum number of generations"</span>,<span class="charliteral">'G'</span>, <span class="stringliteral">"Stopping criterion"</span> ).value();
|
||||
00072
|
||||
00073 <span class="keywordtype">unsigned</span> minGen = parser.createParam(<span class="keywordtype">unsigned</span>(100), <span class="stringliteral">"minGen"</span>, <span class="stringliteral">"Minimum number of generations"</span>,<span class="charliteral">'g'</span>, <span class="stringliteral">"Stopping criterion"</span> ).value();
|
||||
00074
|
||||
00075 <span class="keywordtype">unsigned</span> steadyGen = parser.createParam(<span class="keywordtype">unsigned</span>(100), <span class="stringliteral">"steadyGen"</span>, <span class="stringliteral">"Number of generations with no improvement"</span>,<span class="charliteral">'s'</span>, <span class="stringliteral">"Stopping criterion"</span> ).value();
|
||||
00076
|
||||
00077 <span class="comment">// operators probabilities at the algorithm level</span>
|
||||
00078 <span class="keywordtype">double</span> pCross = parser.createParam(<span class="keywordtype">double</span>(0.6), <span class="stringliteral">"pCross"</span>, <span class="stringliteral">"Probability of Crossover"</span>, <span class="charliteral">'C'</span>, <span class="stringliteral">"Genetic Operators"</span> ).value();
|
||||
00079
|
||||
00080 <span class="keywordtype">double</span> pMut = parser.createParam(<span class="keywordtype">double</span>(0.1), <span class="stringliteral">"pMut"</span>, <span class="stringliteral">"Probability of Mutation"</span>, <span class="charliteral">'M'</span>, <span class="stringliteral">"Genetic Operators"</span> ).value();
|
||||
00081
|
||||
00082 <span class="comment">// relative rates for crossovers</span>
|
||||
00083 <span class="keywordtype">double</span> hypercubeRate = parser.createParam(<span class="keywordtype">double</span>(1), <span class="stringliteral">"hypercubeRate"</span>, <span class="stringliteral">"Relative rate for hypercube crossover"</span>, <span class="charliteral">'\0'</span>, <span class="stringliteral">"Genetic Operators"</span> ).value();
|
||||
00084
|
||||
00085 <span class="keywordtype">double</span> segmentRate = parser.createParam(<span class="keywordtype">double</span>(1), <span class="stringliteral">"segmentRate"</span>, <span class="stringliteral">"Relative rate for segment crossover"</span>, <span class="charliteral">'\0'</span>, <span class="stringliteral">"Genetic Operators"</span> ).value();
|
||||
00086
|
||||
00087 <span class="comment">// internal parameters for the mutations</span>
|
||||
00088 <span class="keywordtype">double</span> EPSILON = parser.createParam(<span class="keywordtype">double</span>(0.01), <span class="stringliteral">"EPSILON"</span>, <span class="stringliteral">"Width for uniform mutation"</span>, <span class="charliteral">'\0'</span>, <span class="stringliteral">"Genetic Operators"</span> ).value();
|
||||
00089
|
||||
00090 <span class="keywordtype">double</span> SIGMA = parser.createParam(<span class="keywordtype">double</span>(0.3), <span class="stringliteral">"SIGMA"</span>, <span class="stringliteral">"Sigma for normal mutation"</span>, <span class="charliteral">'\0'</span>, <span class="stringliteral">"Genetic Operators"</span> ).value();
|
||||
00091
|
||||
00092 <span class="comment">// relative rates for mutations</span>
|
||||
00093 <span class="keywordtype">double</span> uniformMutRate = parser.createParam(<span class="keywordtype">double</span>(1), <span class="stringliteral">"uniformMutRate"</span>, <span class="stringliteral">"Relative rate for uniform mutation"</span>, <span class="charliteral">'\0'</span>, <span class="stringliteral">"Genetic Operators"</span> ).value();
|
||||
00094
|
||||
00095 <span class="keywordtype">double</span> detMutRate = parser.createParam(<span class="keywordtype">double</span>(1), <span class="stringliteral">"detMutRate"</span>, <span class="stringliteral">"Relative rate for det-uniform mutation"</span>, <span class="charliteral">'\0'</span>, <span class="stringliteral">"Genetic Operators"</span> ).value();
|
||||
00096
|
||||
00097 <span class="keywordtype">double</span> normalMutRate = parser.createParam(<span class="keywordtype">double</span>(1), <span class="stringliteral">"normalMutRate"</span>, <span class="stringliteral">"Relative rate for normal mutation"</span>, <span class="charliteral">'\0'</span>, <span class="stringliteral">"Genetic Operators"</span> ).value();
|
||||
00098
|
||||
00099 <span class="comment">// the name of the "status" file where all actual parameter values will be saved</span>
|
||||
00100 string str_status = parser.ProgramName() + <span class="stringliteral">".status"</span>; <span class="comment">// default value</span>
|
||||
00101 string statusName = parser.createParam(str_status, <span class="stringliteral">"status"</span>,<span class="stringliteral">"Status file"</span>,<span class="charliteral">'S'</span>, <span class="stringliteral">"Persistence"</span> ).value();
|
||||
00102
|
||||
00103 <span class="comment">// do the following AFTER ALL PARAMETERS HAVE BEEN PROCESSED</span>
|
||||
00104 <span class="comment">// i.e. in case you need parameters somewhere else, postpone these</span>
|
||||
00105 <span class="keywordflow">if</span> (parser.userNeedsHelp())
|
||||
00106 {
|
||||
00107 parser.printHelp(cout);
|
||||
00108 exit(1);
|
||||
00109 }
|
||||
00110 <span class="keywordflow">if</span> (statusName != <span class="stringliteral">""</span>)
|
||||
00111 {
|
||||
00112 ofstream os(statusName.c_str());
|
||||
00113 os << parser; <span class="comment">// and you can use that file as parameter file</span>
|
||||
00114 }
|
||||
00115
|
||||
00116 <span class="comment">// EVAL</span>
|
||||
00118 <span class="comment"></span> <span class="comment">// Fitness function</span>
|
||||
00120 <span class="comment"></span> <span class="comment">// Evaluation: from a plain C++ fn to an EvalFunc Object</span>
|
||||
00121 <span class="comment">// you need to give the full description of the function</span>
|
||||
00122 <a class="code" href="structeo_eval_func_ptr.html">eoEvalFuncPtr<Indi, double, const vector<double></a>& > plainEval( real_value );
|
||||
00123 <span class="comment">// ... to an object that counts the nb of actual evaluations</span>
|
||||
00124 <a class="code" href="classeo_eval_func_counter.html">eoEvalFuncCounter<Indi></a> eval(plainEval);
|
||||
00125
|
||||
00126 <span class="comment">// INIT</span>
|
||||
00128 <span class="comment"></span> <span class="comment">// Initilisation of population</span>
|
||||
00130 <span class="comment"></span> <span class="comment">// Either load or initialize</span>
|
||||
00131 <span class="comment">// create an empty pop</span>
|
||||
00132 <a class="code" href="classeo_pop.html">eoPop<Indi></a> pop;
|
||||
00133 <span class="comment">// create a state for reading</span>
|
||||
00134 <a class="code" href="classeo_state.html">eoState</a> inState; <span class="comment">// a state for loading - WITHOUT the parser</span>
|
||||
00135 <span class="comment">// register the rng and the pop in the state, so they can be loaded,</span>
|
||||
00136 <span class="comment">// and the present run will be the exact conitnuation of the saved run</span>
|
||||
00137 <span class="comment">// eventually with different parameters</span>
|
||||
00138 inState.<a class="code" href="classeo_state.html#a2">registerObject</a>(rng);
|
||||
00139 inState.<a class="code" href="classeo_state.html#a2">registerObject</a>(pop);
|
||||
00140
|
||||
00141 <span class="keywordflow">if</span> (loadName != <span class="stringliteral">""</span>)
|
||||
00142 {
|
||||
00143 inState.<a class="code" href="classeo_state.html#a5">load</a>(loadName); <span class="comment">// load the pop and the rng</span>
|
||||
00144 <span class="comment">// the fitness is read in the file:</span>
|
||||
00145 <span class="comment">// do only evaluate the pop if the fitness has changed</span>
|
||||
00146 }
|
||||
00147 <span class="keywordflow">else</span>
|
||||
00148 {
|
||||
00149 rng.<a class="code" href="classeo_rng.html#a2">reseed</a>(seed);
|
||||
00150 <span class="comment">// a Indi random initializer</span>
|
||||
00151 <span class="comment">// based on boolean_generator class (see utils/rnd_generator.h)</span>
|
||||
00152 <a class="code" href="classeo_uniform_generator.html">eoUniformGenerator<double></a> uGen(-1.0, 1.0);
|
||||
00153 <a class="code" href="classeo_init_fixed_length.html">eoInitFixedLength<Indi></a> random(vecSize, uGen);
|
||||
00154
|
||||
00155 <span class="comment">// Init pop from the randomizer: need to use the append function</span>
|
||||
00156 pop.<a class="code" href="classeo_pop.html#a2">append</a>(popSize, random);
|
||||
00157 <span class="comment">// and evaluate pop (STL syntax)</span>
|
||||
00158 apply<Indi>(eval, pop);
|
||||
00159 } <span class="comment">// end of initializatio of the population</span>
|
||||
00160
|
||||
00161 <span class="comment">// OUTPUT</span>
|
||||
00162 <span class="comment">// sort pop before printing it!</span>
|
||||
00163 pop.<a class="code" href="classeo_pop.html#a5">sort</a>();
|
||||
00164 <span class="comment">// Print (sorted) intial population (raw printout)</span>
|
||||
00165 cout << <span class="stringliteral">"Initial Population"</span> << endl;
|
||||
00166 cout << pop;
|
||||
00167
|
||||
00168 <span class="comment">// ENGINE</span>
|
||||
00170 <span class="comment"></span> <span class="comment">// selection and replacement</span>
|
||||
00172 <span class="comment"></span><span class="comment">// SELECT</span>
|
||||
00173 <span class="comment">// The robust tournament selection</span>
|
||||
00174 <a class="code" href="classeo_det_tournament_select.html">eoDetTournamentSelect<Indi></a> selectOne(tSize);
|
||||
00175 <span class="comment">// is now encapsulated in a eoSelectPerc (entage)</span>
|
||||
00176 <a class="code" href="classeo_select_perc.html">eoSelectPerc<Indi></a> select(selectOne);<span class="comment">// by default rate==1</span>
|
||||
00177
|
||||
00178 <span class="comment">// REPLACE</span>
|
||||
00179 <span class="comment">// And we now have the full slection/replacement - though with</span>
|
||||
00180 <span class="comment">// no replacement (== generational replacement) at the moment :-)</span>
|
||||
00181 <a class="code" href="classeo_generational_replacement.html">eoGenerationalReplacement<Indi></a> replace;
|
||||
00182
|
||||
00183 <span class="comment">// OPERATORS</span>
|
||||
00185 <span class="comment"></span> <span class="comment">// The variation operators</span>
|
||||
00187 <span class="comment"></span><span class="comment">// CROSSOVER</span>
|
||||
00188 <span class="comment">// uniform chooce on segment made by the parents</span>
|
||||
00189 <a class="code" href="classeo_segment_crossover.html">eoSegmentCrossover<Indi></a> xoverS;
|
||||
00190 <span class="comment">// uniform choice in hypercube built by the parents</span>
|
||||
00191 eoHypercubeCrossover<Indi> xoverA;
|
||||
00192 <span class="comment">// Combine them with relative weights</span>
|
||||
00193 <a class="code" href="classeo_prop_combined_quad_op.html">eoPropCombinedQuadOp<Indi></a> xover(xoverS, segmentRate);
|
||||
00194 xover.add(xoverA, hypercubeRate, <span class="keyword">true</span>);
|
||||
00195
|
||||
00196 <span class="comment">// MUTATION</span>
|
||||
00197 <span class="comment">// offspring(i) uniformly chosen in [parent(i)-epsilon, parent(i)+epsilon]</span>
|
||||
00198 <a class="code" href="classeo_uniform_mutation.html">eoUniformMutation<Indi></a> mutationU(EPSILON);
|
||||
00199 <span class="comment">// k (=1) coordinates of parents are uniformly modified</span>
|
||||
00200 <a class="code" href="classeo_det_uniform_mutation.html">eoDetUniformMutation<Indi></a> mutationD(EPSILON);
|
||||
00201 <span class="comment">// all coordinates of parents are normally modified (stDev SIGMA)</span>
|
||||
00202 <a class="code" href="classeo_normal_mutation.html">eoNormalMutation<Indi></a> mutationN(SIGMA);
|
||||
00203 <span class="comment">// Combine them with relative weights</span>
|
||||
00204 <a class="code" href="classeo_prop_combined_mon_op.html">eoPropCombinedMonOp<Indi></a> mutation(mutationU, uniformMutRate);
|
||||
00205 mutation.add(mutationD, detMutRate);
|
||||
00206 mutation.add(mutationN, normalMutRate, <span class="keyword">true</span>);
|
||||
00207
|
||||
00208 <span class="comment">// The operators are encapsulated into an eoTRansform object</span>
|
||||
00209 <a class="code" href="classeo_s_g_a_transform.html">eoSGATransform<Indi></a> transform(xover, pCross, mutation, pMut);
|
||||
00210
|
||||
00211 <span class="comment">// STOP</span>
|
||||
00213 <span class="comment"></span> <span class="comment">// termination condition see FirstBitEA.cpp</span>
|
||||
00215 <span class="comment"></span> <a class="code" href="classeo_gen_continue.html">eoGenContinue<Indi></a> genCont(maxGen);
|
||||
00216 <a class="code" href="classeo_steady_fit_continue.html">eoSteadyFitContinue<Indi></a> steadyCont(minGen, steadyGen);
|
||||
00217 <a class="code" href="classeo_fit_continue.html">eoFitContinue<Indi></a> fitCont(0);
|
||||
00218 <a class="code" href="classeo_combined_continue.html">eoCombinedContinue<Indi></a> continuator(genCont);
|
||||
00219 continuator.add(steadyCont);
|
||||
00220 continuator.add(fitCont);
|
||||
00221
|
||||
00222
|
||||
00223 <span class="comment">// CHECKPOINT</span>
|
||||
00224 <span class="comment">// but now you want to make many different things every generation</span>
|
||||
00225 <span class="comment">// (e.g. statistics, plots, ...).</span>
|
||||
00226 <span class="comment">// the class eoCheckPoint is dedicated to just that:</span>
|
||||
00227
|
||||
00228 <span class="comment">// Declare a checkpoint (from a continuator: an eoCheckPoint</span>
|
||||
00229 <span class="comment">// IS AN eoContinue and will be called in the loop of all algorithms)</span>
|
||||
00230 <a class="code" href="classeo_check_point.html">eoCheckPoint<Indi></a> checkpoint(continuator);
|
||||
00231
|
||||
00232 <span class="comment">// Create a counter parameter</span>
|
||||
00233 <a class="code" href="classeo_value_param.html">eoValueParam<unsigned></a> generationCounter(0, <span class="stringliteral">"Gen."</span>);
|
||||
00234
|
||||
00235 <span class="comment">// Create an incrementor (sub-class of eoUpdater). Note that the</span>
|
||||
00236 <span class="comment">// parameter's value is passed by reference,</span>
|
||||
00237 <span class="comment">// so every time the incrementer is updated (every generation),</span>
|
||||
00238 <span class="comment">// the data in generationCounter will change.</span>
|
||||
00239 <a class="code" href="classeo_incrementor.html">eoIncrementor<unsigned></a> increment(generationCounter.value());
|
||||
00240
|
||||
00241 <span class="comment">// Add it to the checkpoint,</span>
|
||||
00242 <span class="comment">// so the counter is updated (here, incremented) every generation</span>
|
||||
00243 checkpoint.add(increment);
|
||||
00244
|
||||
00245 <span class="comment">// now some statistics on the population:</span>
|
||||
00246 <span class="comment">// Best fitness in population</span>
|
||||
00247 <a class="code" href="classeo_best_fitness_stat.html">eoBestFitnessStat<Indi></a> bestStat;
|
||||
00248 <span class="comment">// Second moment stats: average and stdev</span>
|
||||
00249 <a class="code" href="classeo_second_moment_stats.html">eoSecondMomentStats<Indi></a> SecondStat;
|
||||
00250
|
||||
00251 <span class="comment">// Add them to the checkpoint to get them called at the appropriate time</span>
|
||||
00252 checkpoint.add(bestStat);
|
||||
00253 checkpoint.add(SecondStat);
|
||||
00254
|
||||
00255 <span class="comment">// The Stdout monitor will print parameters to the screen ...</span>
|
||||
00256 <a class="code" href="classeo_stdout_monitor.html">eoStdoutMonitor</a> monitor(<span class="keyword">false</span>);
|
||||
00257
|
||||
00258 <span class="comment">// when called by the checkpoint (i.e. at every generation)</span>
|
||||
00259 checkpoint.add(monitor);
|
||||
00260
|
||||
00261 <span class="comment">// the monitor will output a series of parameters: add them</span>
|
||||
00262 monitor.add(generationCounter);
|
||||
00263 monitor.add(eval); <span class="comment">// because now eval is an eoEvalFuncCounter!</span>
|
||||
00264 monitor.add(bestStat);
|
||||
00265 monitor.add(SecondStat);
|
||||
00266
|
||||
00267 <span class="comment">// A file monitor: will print parameters to ... a File, yes, you got it!</span>
|
||||
00268 <a class="code" href="classeo_file_monitor.html">eoFileMonitor</a> fileMonitor(<span class="stringliteral">"stats.xg"</span>, <span class="stringliteral">" "</span>);
|
||||
00269
|
||||
00270 <span class="comment">// the checkpoint mechanism can handle multiple monitors</span>
|
||||
00271 checkpoint.add(fileMonitor);
|
||||
00272
|
||||
00273 <span class="comment">// the fileMonitor can monitor parameters, too, but you must tell it!</span>
|
||||
00274 fileMonitor.add(generationCounter);
|
||||
00275 fileMonitor.add(bestStat);
|
||||
00276 fileMonitor.add(SecondStat);
|
||||
00277
|
||||
00278 <span class="comment">// Last type of item the eoCheckpoint can handle: state savers:</span>
|
||||
00279 <a class="code" href="classeo_state.html">eoState</a> outState;
|
||||
00280 <span class="comment">// Register the algorithm into the state (so it has something to save!!)</span>
|
||||
00281 outState.<a class="code" href="classeo_state.html#a2">registerObject</a>(parser);
|
||||
00282 outState.<a class="code" href="classeo_state.html#a2">registerObject</a>(pop);
|
||||
00283 outState.<a class="code" href="classeo_state.html#a2">registerObject</a>(rng);
|
||||
00284
|
||||
00285 <span class="comment">// and feed the state to state savers</span>
|
||||
00286 <span class="comment">// save state every 100th generation</span>
|
||||
00287 <a class="code" href="classeo_counted_state_saver.html">eoCountedStateSaver</a> stateSaver1(20, outState, <span class="stringliteral">"generation"</span>);
|
||||
00288 <span class="comment">// save state every 1 seconds</span>
|
||||
00289 <a class="code" href="classeo_timed_state_saver.html">eoTimedStateSaver</a> stateSaver2(1, outState, <span class="stringliteral">"time"</span>);
|
||||
00290
|
||||
00291 <span class="comment">// Don't forget to add the two savers to the checkpoint</span>
|
||||
00292 checkpoint.add(stateSaver1);
|
||||
00293 checkpoint.add(stateSaver2);
|
||||
00294 <span class="comment">// and that's it for the (control and) output</span>
|
||||
00295
|
||||
00296 <span class="comment">// GENERATION</span>
|
||||
00298 <span class="comment"></span> <span class="comment">// the algorithm</span>
|
||||
00300 <span class="comment"></span>
|
||||
00301 <span class="comment">// Easy EA requires</span>
|
||||
00302 <span class="comment">// stopping criterion, eval, selection, transformation, replacement</span>
|
||||
00303 <a class="code" href="classeo_easy_e_a.html">eoEasyEA<Indi></a> gga(checkpoint, eval, select, transform, replace);
|
||||
00304
|
||||
00305 <span class="comment">// Apply algo to pop - that's it!</span>
|
||||
00306 gga(pop);
|
||||
00307
|
||||
00308 <span class="comment">// OUTPUT</span>
|
||||
00309 <span class="comment">// Print (sorted) intial population</span>
|
||||
00310 pop.sort();
|
||||
00311 cout << <span class="stringliteral">"FINAL Population\n"</span> << pop << endl;
|
||||
00312 <span class="comment">// GENERAL</span>
|
||||
00313 }
|
||||
00314
|
||||
00315 <span class="comment">// A main that catches the exceptions</span>
|
||||
00316
|
||||
00317 <span class="keywordtype">int</span> main(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> **argv)
|
||||
00318 {
|
||||
00319 <span class="keywordflow">try</span>
|
||||
00320 {
|
||||
00321 main_function(argc, argv);
|
||||
00322 }
|
||||
00323 <span class="keywordflow">catch</span>(exception& e)
|
||||
00324 {
|
||||
00325 cout << <span class="stringliteral">"Exception: "</span> << e.what() << <span class="charliteral">'\n'</span>;
|
||||
00326 }
|
||||
00327
|
||||
00328 <span class="keywordflow">return</span> 1;
|
||||
00329 }
|
||||
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:42 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>
|
||||
170
trunk/paradiseo-eo/doc/html/_sym_8cpp-source.html
Normal file
|
|
@ -0,0 +1,170 @@
|
|||
<!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: Sym.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_000007.html">contrib</a> / <a class="el" href="dir_000008.html">mathsym</a> / <a class="el" href="dir_000028.html">sym</a></div>
|
||||
<h1>Sym.cpp</h1><div class="fragment"><pre class="fragment">00001 <span class="comment">/* </span>
|
||||
00002 <span class="comment"> * Copyright (C) 2005 Maarten Keijzer</span>
|
||||
00003 <span class="comment"> *</span>
|
||||
00004 <span class="comment"> * This program is free software; you can redistribute it and/or modify</span>
|
||||
00005 <span class="comment"> * it under the terms of version 2 of the GNU General Public License as </span>
|
||||
00006 <span class="comment"> * published by the Free Software Foundation. </span>
|
||||
00007 <span class="comment"> *</span>
|
||||
00008 <span class="comment"> * This program is distributed in the hope that it will be useful,</span>
|
||||
00009 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
|
||||
00010 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
|
||||
00011 <span class="comment"> * GNU General Public License for more details.</span>
|
||||
00012 <span class="comment"> *</span>
|
||||
00013 <span class="comment"> * You should have received a copy of the GNU General Public License</span>
|
||||
00014 <span class="comment"> * along with this program; if not, write to the Free Software</span>
|
||||
00015 <span class="comment"> * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>
|
||||
00016 <span class="comment"> */</span>
|
||||
00017
|
||||
00018 <span class="preprocessor">#include <sstream></span>
|
||||
00019 <span class="preprocessor">#include <vector></span>
|
||||
00020
|
||||
00021 <span class="preprocessor">#include "Sym.h"</span>
|
||||
00022
|
||||
00023 <span class="keyword">using</span> <span class="keyword">namespace </span>std;
|
||||
00024
|
||||
00025 <span class="keyword">typedef</span> UniqueNodeStats* (*NodeStatFunc)(Sym&);
|
||||
00026
|
||||
00027 UniqueNodeStats* (*Sym::factory)(<span class="keyword">const</span> Sym&) = 0;
|
||||
00028
|
||||
00029 SymMap Sym::dag(100000); <span class="comment">// reserve space for so many nodes</span>
|
||||
00030 std::vector<unsigned> Sym::token_count;
|
||||
00031
|
||||
00032
|
||||
00033 size_t get_size(<span class="keyword">const</span> SymVec& vec) {
|
||||
00034 size_t sz = 0;
|
||||
00035 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < vec.size(); ++i) {
|
||||
00036 sz += vec[i].size();
|
||||
00037 }
|
||||
00038 <span class="keywordflow">return</span> sz;
|
||||
00039 }
|
||||
00040
|
||||
00041 size_t get_depth(<span class="keyword">const</span> SymVec& vec) {
|
||||
00042 size_t dp = 1;
|
||||
00043 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < vec.size(); ++i) {
|
||||
00044 dp = std::max(dp, vec[i].depth());
|
||||
00045 }
|
||||
00046 <span class="keywordflow">return</span> dp;
|
||||
00047 }
|
||||
00048
|
||||
00049 Sym::Sym(token_t tok, <span class="keyword">const</span> SymVec& args_) : node(dag.end())
|
||||
00050 {
|
||||
00051 detail::SymKey key(tok, detail::SymArgs(args_));
|
||||
00052 detail::SymValue val;
|
||||
00053
|
||||
00054 node = dag.insert(pair<const detail::SymKey, detail::SymValue>(key, val)).first;
|
||||
00055
|
||||
00056 <span class="keywordflow">if</span> (__unchecked_refcount() == 0) { <span class="comment">// new node, set some stats </span>
|
||||
00057 node->second.size = 1 + get_size(args_);
|
||||
00058 node->second.depth = 1 + get_depth(args_);
|
||||
00059
|
||||
00060 <span class="comment">// token count</span>
|
||||
00061 <span class="keywordflow">if</span> (tok >= token_count.size()) {
|
||||
00062 token_count.resize(tok+1);
|
||||
00063 }
|
||||
00064
|
||||
00065 incref();
|
||||
00066 node->first.fixate();
|
||||
00067 <span class="comment">// call the factory function if available</span>
|
||||
00068 <span class="keywordflow">if</span> (factory) node->second.uniqueNodeStats = factory(*<span class="keyword">this</span>);
|
||||
00069
|
||||
00070 }
|
||||
00071 <span class="keywordflow">else</span> incref();
|
||||
00072 }
|
||||
00073
|
||||
00074 Sym::Sym(token_t tok, <span class="keyword">const</span> Sym& a) : node(dag.end()) {
|
||||
00075 SymVec args_; args_.push_back(a);
|
||||
00076 detail::SymKey key(tok, detail::SymArgs(args_));
|
||||
00077 detail::SymValue val;
|
||||
00078
|
||||
00079 node = dag.insert(pair<const detail::SymKey, detail::SymValue>(key, val)).first;
|
||||
00080
|
||||
00081 <span class="keywordflow">if</span> (__unchecked_refcount() == 0) { <span class="comment">// new node, set some stats </span>
|
||||
00082 node->second.size = 1 + get_size(args_);
|
||||
00083 node->second.depth = 1 + get_depth(args_);
|
||||
00084
|
||||
00085 <span class="comment">// token count</span>
|
||||
00086 <span class="keywordflow">if</span> (tok >= token_count.size()) {
|
||||
00087 token_count.resize(tok+1);
|
||||
00088 }
|
||||
00089
|
||||
00090 incref();
|
||||
00091 node->first.fixate();
|
||||
00092 <span class="comment">// call the factory function if available</span>
|
||||
00093 <span class="keywordflow">if</span> (factory) node->second.uniqueNodeStats = factory(*<span class="keyword">this</span>);
|
||||
00094 }
|
||||
00095 <span class="keywordflow">else</span> incref();
|
||||
00096 }
|
||||
00097
|
||||
00098 Sym::Sym(token_t tok) : node(dag.end()) {
|
||||
00099 detail::SymKey key(tok);
|
||||
00100 detail::SymValue val;
|
||||
00101 node = dag.insert(pair<const detail::SymKey, detail::SymValue>(key, val)).first;
|
||||
00102
|
||||
00103 <span class="keywordflow">if</span> (__unchecked_refcount() == 0) { <span class="comment">// new node, set some stats </span>
|
||||
00104 node->second.size = 1;
|
||||
00105 node->second.depth = 1;
|
||||
00106
|
||||
00107 <span class="comment">// token count</span>
|
||||
00108 <span class="keywordflow">if</span> (tok >= token_count.size()) {
|
||||
00109 token_count.resize(tok+1);
|
||||
00110 }
|
||||
00111
|
||||
00112 incref();
|
||||
00113
|
||||
00114 <span class="comment">// call the factory function if available</span>
|
||||
00115 <span class="keywordflow">if</span> (factory) node->second.uniqueNodeStats = factory(*<span class="keyword">this</span>);
|
||||
00116
|
||||
00117 }
|
||||
00118 <span class="keywordflow">else</span> incref();
|
||||
00119 }
|
||||
00120
|
||||
00121 std::pair<Sym,bool> insert_subtree_impl(<span class="keyword">const</span> Sym& cur, size_t w, <span class="keyword">const</span> Sym& nw) {
|
||||
00122 <span class="keywordflow">if</span> (w-- == 0) <span class="keywordflow">return</span> make_pair(nw, !(nw == cur));
|
||||
00123
|
||||
00124 <span class="keyword">const</span> SymVec& vec = cur.args();
|
||||
00125 std::pair<Sym,bool> result;
|
||||
00126 <span class="keywordtype">unsigned</span> i;
|
||||
00127
|
||||
00128 <span class="keywordflow">for</span> (i = 0; i < vec.size(); ++i) {
|
||||
00129 <span class="keywordflow">if</span> (w < vec[i].size()) {
|
||||
00130 result = insert_subtree_impl(vec[i], w, nw);
|
||||
00131 <span class="keywordflow">if</span> (result.second == <span class="keyword">false</span>) <span class="keywordflow">return</span> std::make_pair(cur, <span class="keyword">false</span>); <span class="comment">// unchanged</span>
|
||||
00132 <span class="keywordflow">break</span>;
|
||||
00133 }
|
||||
00134 w -= vec[i].size();
|
||||
00135 }
|
||||
00136 SymVec newvec = cur.args();
|
||||
00137 newvec[i] = result.first;
|
||||
00138 <span class="keywordflow">return</span> make_pair(Sym(cur.token(), newvec), <span class="keyword">true</span>);
|
||||
00139 }
|
||||
00140
|
||||
00141 Sym insert_subtree(<span class="keyword">const</span> Sym& cur, size_t w, <span class="keyword">const</span> Sym& nw) {
|
||||
00142 <span class="keywordflow">return</span> insert_subtree_impl(cur,w,nw).first;
|
||||
00143 }
|
||||
00144 Sym get_subtree(<span class="keyword">const</span> Sym& cur, size_t w) {
|
||||
00145 <span class="keywordflow">if</span> (w-- == 0) <span class="keywordflow">return</span> cur;
|
||||
00146
|
||||
00147 <span class="keyword">const</span> SymVec& vec = cur.args();
|
||||
00148 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < vec.size(); ++i) {
|
||||
00149 <span class="keywordflow">if</span> (w < vec[i].size()) <span class="keywordflow">return</span> get_subtree(vec[i], w);
|
||||
00150 w-=vec[i].size();
|
||||
00151 }
|
||||
00152 <span class="keywordflow">return</span> cur;
|
||||
00153 }
|
||||
00154
|
||||
00155
|
||||
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:42 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>
|
||||
189
trunk/paradiseo-eo/doc/html/_sym_8h-source.html
Normal file
|
|
@ -0,0 +1,189 @@
|
|||
<!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: Sym.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_000008.html">mathsym</a> / <a class="el" href="dir_000028.html">sym</a></div>
|
||||
<h1>Sym.h</h1><div class="fragment"><pre class="fragment">00001 <span class="comment">/* </span>
|
||||
00002 <span class="comment"> * Copyright (C) 2005 Maarten Keijzer</span>
|
||||
00003 <span class="comment"> *</span>
|
||||
00004 <span class="comment"> * This program is free software; you can redistribute it and/or modify</span>
|
||||
00005 <span class="comment"> * it under the terms of version 2 of the GNU General Public License as </span>
|
||||
00006 <span class="comment"> * published by the Free Software Foundation. </span>
|
||||
00007 <span class="comment"> *</span>
|
||||
00008 <span class="comment"> * This program is distributed in the hope that it will be useful,</span>
|
||||
00009 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
|
||||
00010 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
|
||||
00011 <span class="comment"> * GNU General Public License for more details.</span>
|
||||
00012 <span class="comment"> *</span>
|
||||
00013 <span class="comment"> * You should have received a copy of the GNU General Public License</span>
|
||||
00014 <span class="comment"> * along with this program; if not, write to the Free Software</span>
|
||||
00015 <span class="comment"> * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>
|
||||
00016 <span class="comment"> */</span>
|
||||
00017
|
||||
00018 <span class="preprocessor">#ifndef SYMNODE_H_</span>
|
||||
00019 <span class="preprocessor"></span><span class="preprocessor">#define SYMNODE_H_</span>
|
||||
00020 <span class="preprocessor"></span>
|
||||
00021 <span class="preprocessor">#include <cassert></span>
|
||||
00022
|
||||
00023 <span class="preprocessor">#if __GNUC__ >= 3</span>
|
||||
00024 <span class="preprocessor"></span><span class="preprocessor">#include <backward/hash_map.h></span>
|
||||
00025 <span class="preprocessor">#elif __GNUC__ < 3</span>
|
||||
00026 <span class="preprocessor"></span><span class="preprocessor">#include <hash_map.h></span>
|
||||
00027 <span class="keyword">using</span> std::hash_map;
|
||||
00028 <span class="preprocessor">#endif</span>
|
||||
00029 <span class="preprocessor"></span>
|
||||
00030 <span class="comment">/* Empty 'extra statistics' structure, derive from this to keep other characteristics of nodes */</span>
|
||||
00031 <span class="keyword">struct </span>UniqueNodeStats { <span class="keyword">virtual</span> ~UniqueNodeStats(){} };
|
||||
00032
|
||||
00033 <span class="preprocessor">#include "SymImpl.h"</span>
|
||||
00034 <span class="preprocessor">#include "token.h"</span>
|
||||
00035
|
||||
00036 <span class="preprocessor">#if __GNUC__ == 4</span>
|
||||
00037 <span class="preprocessor"></span><span class="preprocessor">#define USE_TR1 1</span>
|
||||
00038 <span class="preprocessor"></span><span class="preprocessor">#else</span>
|
||||
00039 <span class="preprocessor"></span><span class="preprocessor">#define USE_TR1 0</span>
|
||||
00040 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
|
||||
00041 <span class="preprocessor"></span>
|
||||
00042 <span class="preprocessor">#if USE_TR1</span>
|
||||
00043 <span class="preprocessor"></span><span class="preprocessor">#include <tr1/unordered_map></span>
|
||||
00044 <span class="keyword">typedef</span> std::tr1::unordered_map<detail::SymKey, detail::SymValue, detail::SymKey::Hash> SymMap;
|
||||
00045 <span class="preprocessor">#else</span>
|
||||
00046 <span class="preprocessor"></span><span class="keyword">typedef</span> hash_map<detail::SymKey, detail::SymValue, detail::SymKey::Hash> SymMap;
|
||||
00047 <span class="preprocessor">#endif</span>
|
||||
00048 <span class="preprocessor"></span>
|
||||
00049 <span class="keyword">typedef</span> SymMap::iterator SymIterator;
|
||||
00050
|
||||
00051 <span class="comment">/* Sym is the tree, for which all the nodes are stored in a hash table. </span>
|
||||
00052 <span class="comment"> * This makes checking for equality O(1) */</span>
|
||||
00053 <span class="keyword">class </span>Sym
|
||||
00054 {
|
||||
00055 <span class="keyword">public</span>:
|
||||
00056
|
||||
00057 Sym() : node(dag.end()) {}
|
||||
00058 <span class="keyword">explicit</span> Sym(token_t token, <span class="keyword">const</span> SymVec& args);
|
||||
00059 <span class="keyword">explicit</span> Sym(token_t token, <span class="keyword">const</span> Sym& args);
|
||||
00060 <span class="keyword">explicit</span> Sym(token_t var);
|
||||
00061
|
||||
00062 <span class="keyword">explicit</span> Sym(SymIterator it) : node(it) { incref(); }
|
||||
00063
|
||||
00064 Sym(<span class="keyword">const</span> Sym& oth) : node(oth.node) { incref(); }
|
||||
00065 ~Sym() { decref(); }
|
||||
00066
|
||||
00067 <span class="keyword">const</span> Sym& operator=(<span class="keyword">const</span> Sym& oth) {
|
||||
00068 <span class="keywordflow">if</span> (oth.node == node) <span class="keywordflow">return</span> *<span class="keyword">this</span>;
|
||||
00069 decref();
|
||||
00070 node = oth.node;
|
||||
00071 incref();
|
||||
00072 <span class="keywordflow">return</span> *<span class="keyword">this</span>;
|
||||
00073 }
|
||||
00074
|
||||
00075 <span class="comment">/* Unique Stats are user defined */</span>
|
||||
00076 UniqueNodeStats* extra_stats()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> empty()? 0 : node->second.uniqueNodeStats; }
|
||||
00077
|
||||
00078 <span class="keywordtype">int</span> hashcode()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> node->first.get_hash_code(); } <span class="comment">//detail::SymKey::Hash hash; return hash(node->first); }</span>
|
||||
00079
|
||||
00080 <span class="comment">// Friends, need to touch the node</span>
|
||||
00081 <span class="keyword">friend</span> <span class="keyword">struct </span>detail::SymKey::Hash;
|
||||
00082 <span class="keyword">friend</span> <span class="keyword">struct </span>detail::SymKey;
|
||||
00083
|
||||
00084 <span class="keywordtype">unsigned</span> refcount()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> empty()? 0: node->second.refcount; }
|
||||
00085
|
||||
00086 <span class="keywordtype">bool</span> operator==(<span class="keyword">const</span> Sym& other)<span class="keyword"> const </span>{
|
||||
00087 <span class="keywordflow">return</span> node == other.node;
|
||||
00088 }
|
||||
00089 <span class="keywordtype">bool</span> operator!=(<span class="keyword">const</span> Sym& other)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> !(*<span class="keyword">this</span> == other); }
|
||||
00090
|
||||
00091 <span class="keywordtype">bool</span> empty()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> node == dag.end(); }
|
||||
00092
|
||||
00093 <span class="comment">/* Support for traversing trees */</span>
|
||||
00094 <span class="keywordtype">unsigned</span> arity()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> node->first.arity(); }
|
||||
00095 token_t token()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> node->first.token; }
|
||||
00096
|
||||
00097 <span class="keyword">const</span> SymVec& args()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> node->first.vec(); }
|
||||
00098
|
||||
00099 <span class="comment">/* size() - depth */</span>
|
||||
00100 <span class="keywordtype">unsigned</span> size()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> empty()? 0 : node->second.size; }
|
||||
00101 <span class="keywordtype">unsigned</span> depth()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> empty()? 0 : node->second.depth; }
|
||||
00102
|
||||
00103 SymMap::iterator iterator()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> node; }
|
||||
00104
|
||||
00105 <span class="comment">/* Statics accessing some static members */</span>
|
||||
00106 <span class="keyword">static</span> SymMap& get_dag() { <span class="keywordflow">return</span> dag; }
|
||||
00107
|
||||
00108 <span class="comment">/* This function can be set to create some UniqueNodeStats derivative that can contain extra stats for a node,</span>
|
||||
00109 <span class="comment"> * it can for instance be used to create ERC's and what not. */</span>
|
||||
00110 <span class="keyword">static</span> <span class="keywordtype">void</span> set_factory_function(UniqueNodeStats* (*f)(<span class="keyword">const</span> Sym&)) { factory=f; }
|
||||
00111 <span class="keyword">static</span> <span class="keywordtype">void</span> clear_factory_function() { factory = 0; }
|
||||
00112
|
||||
00113 <span class="keyword">static</span> <span class="keyword">const</span> std::vector<unsigned>& token_refcount() { <span class="keywordflow">return</span> token_count; }
|
||||
00114
|
||||
00115 <span class="keywordtype">unsigned</span> address()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> reinterpret_cast<unsigned>(&*node); }
|
||||
00116
|
||||
00117 <span class="keyword">private</span> :
|
||||
00118
|
||||
00119 <span class="comment">// implements getting subtrees</span>
|
||||
00120 Sym private_get(size_t w) <span class="keyword">const</span>;
|
||||
00121
|
||||
00122 <span class="keywordtype">unsigned</span> __unchecked_refcount()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> node->second.refcount; }
|
||||
00123
|
||||
00124 <span class="keywordtype">void</span> incref() {
|
||||
00125 <span class="keywordflow">if</span> (!empty()) {
|
||||
00126 ++(node->second.refcount);
|
||||
00127 ++token_count[token()];
|
||||
00128 }
|
||||
00129 }
|
||||
00130 <span class="keywordtype">void</span> decref() {
|
||||
00131 <span class="keywordflow">if</span> (!empty()) {
|
||||
00132 --token_count[token()];
|
||||
00133 <span class="keywordflow">if</span> (--(node->second.refcount) == 0) {
|
||||
00134 dag.erase(node);
|
||||
00135 }
|
||||
00136 }
|
||||
00137 }
|
||||
00138
|
||||
00139 <span class="comment">// The one and only data member, an iterator into the static map below</span>
|
||||
00140 SymIterator node;
|
||||
00141
|
||||
00142 <span class="comment">// A static hash_map that contains all live nodes.. </span>
|
||||
00143 <span class="keyword">static</span> SymMap dag;
|
||||
00144
|
||||
00145 <span class="keyword">static</span> std::vector<unsigned> token_count;
|
||||
00146
|
||||
00147 <span class="comment">// Factory function for creating extra node stats, default will be 0</span>
|
||||
00148 <span class="keyword">static</span> UniqueNodeStats* (*factory)(<span class="keyword">const</span> Sym&);
|
||||
00149
|
||||
00150 };
|
||||
00151
|
||||
00152 <span class="comment">/* Utility hash functor for syms */</span>
|
||||
00153 <span class="keyword">class </span>HashSym {
|
||||
00154 <span class="keyword">public</span>:
|
||||
00155 <span class="keywordtype">int</span> operator()(<span class="keyword">const</span> Sym& sym)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> sym.hashcode(); }
|
||||
00156 };
|
||||
00157
|
||||
00158 <span class="comment">/* Utility Functions */</span>
|
||||
00159
|
||||
00160 <span class="comment">// get_subtree retrieves a subtree by standard ordering (0=root, and then depth first)</span>
|
||||
00161 Sym get_subtree(<span class="keyword">const</span> Sym& org, size_t w);
|
||||
00162
|
||||
00163 <span class="comment">// insert_subtree uses the same ordering as get and inserts the second argument, returning a new tree</span>
|
||||
00164 Sym insert_subtree(<span class="keyword">const</span> Sym& org, size_t w, <span class="keyword">const</span> Sym& nw);
|
||||
00165
|
||||
00166 <span class="comment">/* Get the successor from the hashtable, no particular purpose other than an interesting way to mutate */</span>
|
||||
00167 <span class="keyword">inline</span> Sym next(<span class="keyword">const</span> Sym& sym) {
|
||||
00168 SymIterator it = sym.iterator();
|
||||
00169 ++it;
|
||||
00170 <span class="keywordflow">if</span> (it == Sym::get_dag().end()) it = Sym::get_dag().begin();
|
||||
00171 <span class="keywordflow">return</span> Sym(it);
|
||||
00172 }
|
||||
00173
|
||||
00174 <span class="preprocessor">#endif</span>
|
||||
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:42 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>
|
||||
124
trunk/paradiseo-eo/doc/html/_sym_impl_8cpp-source.html
Normal file
|
|
@ -0,0 +1,124 @@
|
|||
<!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: SymImpl.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_000007.html">contrib</a> / <a class="el" href="dir_000008.html">mathsym</a> / <a class="el" href="dir_000028.html">sym</a></div>
|
||||
<h1>SymImpl.cpp</h1><div class="fragment"><pre class="fragment">00001 <span class="comment">/* </span>
|
||||
00002 <span class="comment"> * Copyright (C) 2005 Maarten Keijzer</span>
|
||||
00003 <span class="comment"> *</span>
|
||||
00004 <span class="comment"> * This program is free software; you can redistribute it and/or modify</span>
|
||||
00005 <span class="comment"> * it under the terms of version 2 of the GNU General Public License as </span>
|
||||
00006 <span class="comment"> * published by the Free Software Foundation. </span>
|
||||
00007 <span class="comment"> *</span>
|
||||
00008 <span class="comment"> * This program is distributed in the hope that it will be useful,</span>
|
||||
00009 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
|
||||
00010 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
|
||||
00011 <span class="comment"> * GNU General Public License for more details.</span>
|
||||
00012 <span class="comment"> *</span>
|
||||
00013 <span class="comment"> * You should have received a copy of the GNU General Public License</span>
|
||||
00014 <span class="comment"> * along with this program; if not, write to the Free Software</span>
|
||||
00015 <span class="comment"> * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>
|
||||
00016 <span class="comment"> */</span>
|
||||
00017 <span class="preprocessor">#include "Sym.h"</span>
|
||||
00018
|
||||
00019 <span class="keyword">using</span> <span class="keyword">namespace </span>std;
|
||||
00020 <span class="keyword">namespace </span>detail {
|
||||
00021
|
||||
00022 <span class="keyword">class </span>SymArgsImpl {
|
||||
00023 <span class="keyword">public</span>:
|
||||
00024 std::vector<Sym> owned_args;
|
||||
00025 };
|
||||
00026
|
||||
00027 size_t SymArgs::len()<span class="keyword"> const </span>{
|
||||
00028 <span class="keywordflow">return</span> vec().size();
|
||||
00029 }
|
||||
00030
|
||||
00031 SymArgs::SymArgs() : pimpl( new SymArgsImpl ) {
|
||||
00032 args_ptr = &pimpl->owned_args;
|
||||
00033 }
|
||||
00034
|
||||
00035 SymArgs::SymArgs(<span class="keyword">const</span> std::vector<Sym>& v) : pimpl(0) {
|
||||
00036 args_ptr = &v;
|
||||
00037 }
|
||||
00038
|
||||
00039 SymArgs::~SymArgs() {
|
||||
00040 <span class="keyword">delete</span> pimpl;
|
||||
00041 }
|
||||
00042
|
||||
00043 SymArgs::SymArgs(<span class="keyword">const</span> SymArgs& args) : pimpl(0), args_ptr(args.args_ptr) {
|
||||
00044 <span class="keywordflow">if</span> (args.pimpl && args.args_ptr == &args.pimpl->owned_args) {
|
||||
00045 pimpl = <span class="keyword">new</span> SymArgsImpl(*args.pimpl);
|
||||
00046 args_ptr = &pimpl->owned_args;
|
||||
00047 }
|
||||
00048 }
|
||||
00049
|
||||
00050 <span class="keyword">const</span> SymArgs& SymArgs::operator=(<span class="keyword">const</span> SymArgs& args) {
|
||||
00051 <span class="keywordflow">if</span> (args.pimpl && args.args_ptr == &args.pimpl->owned_args) {
|
||||
00052 pimpl = <span class="keyword">new</span> SymArgsImpl(*args.pimpl);
|
||||
00053 args_ptr = &pimpl->owned_args;
|
||||
00054 } <span class="keywordflow">else</span> {
|
||||
00055 args_ptr = args.args_ptr;
|
||||
00056 }
|
||||
00057
|
||||
00058 <span class="keywordflow">return</span> *<span class="keyword">this</span>;
|
||||
00059 }
|
||||
00060
|
||||
00061 <span class="keywordtype">void</span> SymArgs::fixate()<span class="keyword"> const </span>{
|
||||
00062 assert(pimpl == 0);
|
||||
00063 pimpl = <span class="keyword">new</span> SymArgsImpl;
|
||||
00064 pimpl->owned_args = *args_ptr;
|
||||
00065 args_ptr = &pimpl->owned_args;
|
||||
00066 }
|
||||
00067
|
||||
00068 <span class="comment">// For Tackett's hashcode</span>
|
||||
00069 <span class="preprocessor">#define PRIMET 21523</span>
|
||||
00070 <span class="preprocessor"></span><span class="preprocessor">#define HASHMOD 277218551</span>
|
||||
00071 <span class="preprocessor"></span>
|
||||
00072 <span class="keyword">const</span> <span class="keywordtype">int</span> nprimes = 4;
|
||||
00073 <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> primes[] = {3221225473ul, 201326611ul, 1610612741ul, 805306457ul};
|
||||
00074
|
||||
00075 <span class="keywordtype">int</span> SymKey::calc_hash()<span class="keyword"> const </span>{
|
||||
00076 <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> hash = unsigned(token);
|
||||
00077 hash *= PRIMET;
|
||||
00078
|
||||
00079 <span class="keyword">const</span> std::vector<Sym>& v = args.vec();
|
||||
00080 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < v.size(); ++i) {
|
||||
00081 hash += ( (v[i].address() >> 3) * primes[i%nprimes]) % HASHMOD;
|
||||
00082 }
|
||||
00083
|
||||
00084 <span class="keywordflow">return</span> hash;<span class="comment">// % HASHMOD;</span>
|
||||
00085 }
|
||||
00086
|
||||
00087 <span class="keywordtype">bool</span> SymKey::operator==(<span class="keyword">const</span> SymKey& other)<span class="keyword"> const </span>{
|
||||
00088 <span class="keywordflow">if</span> (token != other.token) <span class="keywordflow">return</span> <span class="keyword">false</span>;
|
||||
00089 <span class="keywordflow">return</span> args.vec() == other.args.vec();
|
||||
00090 }
|
||||
00091
|
||||
00092 <span class="comment">/* Just to store this info somewhere:</span>
|
||||
00093 <span class="comment"> * </span>
|
||||
00094 <span class="comment"> * Address Based Hash Function Implementation</span>
|
||||
00095 <span class="comment"> * uint32 address_hash(char* addr)</span>
|
||||
00096 <span class="comment"> * {</span>
|
||||
00097 <span class="comment"> * register uint32 key;</span>
|
||||
00098 <span class="comment"> * key = (uint32) addr;</span>
|
||||
00099 <span class="comment"> * return (key >> 3) * 2654435761;</span>
|
||||
00100 <span class="comment"> * }</span>
|
||||
00101 <span class="comment"> */</span>
|
||||
00102
|
||||
00103 SymValue::SymValue() : refcount(0), size(0), depth(0), uniqueNodeStats(0) {}
|
||||
00104
|
||||
00105 SymValue::~SymValue() { <span class="keyword">delete</span> uniqueNodeStats; }
|
||||
00106
|
||||
00107
|
||||
00108
|
||||
00109 } <span class="comment">// namespace detail</span>
|
||||
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:42 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>
|
||||
128
trunk/paradiseo-eo/doc/html/_sym_impl_8h-source.html
Normal file
|
|
@ -0,0 +1,128 @@
|
|||
<!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: SymImpl.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_000008.html">mathsym</a> / <a class="el" href="dir_000028.html">sym</a></div>
|
||||
<h1>SymImpl.h</h1><div class="fragment"><pre class="fragment">00001 <span class="comment">/* </span>
|
||||
00002 <span class="comment"> * Copyright (C) 2005 Maarten Keijzer</span>
|
||||
00003 <span class="comment"> *</span>
|
||||
00004 <span class="comment"> * This program is free software; you can redistribute it and/or modify</span>
|
||||
00005 <span class="comment"> * it under the terms of version 2 of the GNU General Public License as </span>
|
||||
00006 <span class="comment"> * published by the Free Software Foundation. </span>
|
||||
00007 <span class="comment"> *</span>
|
||||
00008 <span class="comment"> * This program is distributed in the hope that it will be useful,</span>
|
||||
00009 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
|
||||
00010 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
|
||||
00011 <span class="comment"> * GNU General Public License for more details.</span>
|
||||
00012 <span class="comment"> *</span>
|
||||
00013 <span class="comment"> * You should have received a copy of the GNU General Public License</span>
|
||||
00014 <span class="comment"> * along with this program; if not, write to the Free Software</span>
|
||||
00015 <span class="comment"> * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>
|
||||
00016 <span class="comment"> */</span>
|
||||
00017 <span class="preprocessor">#ifndef __SYM_IMPL_H__</span>
|
||||
00018 <span class="preprocessor"></span><span class="preprocessor">#define __SYM_IMPL_H__</span>
|
||||
00019 <span class="preprocessor"></span>
|
||||
00020 <span class="preprocessor">#include <vector></span>
|
||||
00021
|
||||
00022 <span class="preprocessor">#include "token.h"</span>
|
||||
00023
|
||||
00024 <span class="keyword">class </span>Sym;
|
||||
00025
|
||||
00026 <span class="preprocessor">#if __GNUC__ > 4 </span>
|
||||
00027 <span class="preprocessor"></span><span class="preprocessor">#include <ext/pool_allocator.h></span>
|
||||
00028 <span class="keyword">typedef</span> std::vector<Sym, __gnu_cxx::__pool_alloc<Sym> > std::vector<Sym>;
|
||||
00029 <span class="comment">//typedef std::vector<Sym> SymVec;</span>
|
||||
00030 <span class="preprocessor">#else</span>
|
||||
00031 <span class="preprocessor"></span><span class="keyword">typedef</span> std::vector<Sym> SymVec;
|
||||
00032 <span class="preprocessor">#endif</span>
|
||||
00033 <span class="preprocessor"></span>
|
||||
00034
|
||||
00035 <span class="keyword">namespace </span>detail {
|
||||
00036
|
||||
00037 <span class="keyword">class </span>SymArgsImpl;
|
||||
00038 <span class="keyword">class </span>SymArgs {
|
||||
00039
|
||||
00040 <span class="keyword">mutable</span> SymArgsImpl* pimpl; <span class="comment">// contains circular reference to vector<Sym></span>
|
||||
00041 <span class="keyword">mutable</span> <span class="keyword">const</span> std::vector<Sym>* args_ptr;
|
||||
00042
|
||||
00043 <span class="keyword">public</span>:
|
||||
00044
|
||||
00045 SymArgs();
|
||||
00046 SymArgs(<span class="keyword">const</span> std::vector<Sym>& v);
|
||||
00047 ~SymArgs();
|
||||
00048
|
||||
00049 SymArgs(<span class="keyword">const</span> SymArgs& args);
|
||||
00050 <span class="keyword">const</span> SymArgs& SymArgs::operator=(<span class="keyword">const</span> SymArgs& other);
|
||||
00051
|
||||
00052 size_t len() <span class="keyword">const</span>;
|
||||
00053 <span class="keyword">const</span> std::vector<Sym>& vec()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> *args_ptr; }
|
||||
00054 <span class="keywordtype">void</span> fixate() <span class="keyword">const</span>;
|
||||
00055 };
|
||||
00056
|
||||
00057 <span class="keyword">class </span>SymKey
|
||||
00058 {
|
||||
00059 <span class="keyword">public</span>:
|
||||
00060 SymKey(token_t _token) : args(), token(_token), hash_code(calc_hash()) {}
|
||||
00061 SymKey(token_t _token, <span class="keyword">const</span> detail::SymArgs& _args) : args(_args), token(_token), hash_code(calc_hash()) {}
|
||||
00062
|
||||
00063 <span class="keywordtype">bool</span> operator==(<span class="keyword">const</span> SymKey& other) <span class="keyword">const</span>;
|
||||
00064
|
||||
00065 <span class="keyword">struct </span>Hash
|
||||
00066 {
|
||||
00067 <span class="keywordtype">int</span> operator()(<span class="keyword">const</span> SymKey& k)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> k.calc_hash(); };
|
||||
00068 };
|
||||
00069
|
||||
00070 <span class="keywordtype">unsigned</span> arity()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> args.len(); }
|
||||
00071 <span class="keyword">const</span> std::vector<Sym>& vec()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> args.vec(); }
|
||||
00072
|
||||
00073 <span class="comment">// fixates (i.e. claims memory) for the embedded vector of Syms</span>
|
||||
00074 <span class="keywordtype">void</span> fixate()<span class="keyword"> const </span>{ args.fixate(); }
|
||||
00075
|
||||
00076 <span class="keywordtype">int</span> get_hash_code()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> hash_code; }
|
||||
00077
|
||||
00078 detail::SymArgs args;
|
||||
00079 token_t token; <span class="comment">// identifies the function</span>
|
||||
00080
|
||||
00081 <span class="keyword">private</span>:
|
||||
00082 <span class="keywordtype">int</span> calc_hash() <span class="keyword">const</span>;
|
||||
00083 <span class="keywordtype">int</span> hash_code;
|
||||
00084 };
|
||||
00085
|
||||
00086 <span class="keyword">struct </span>SymValue
|
||||
00087 {
|
||||
00088 <span class="keyword">friend</span> <span class="keyword">class </span>Sym;
|
||||
00089
|
||||
00090 SymValue();
|
||||
00091 ~SymValue();
|
||||
00092
|
||||
00093 <span class="keywordtype">unsigned</span> getRefCount()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> refcount; }
|
||||
00094 <span class="keywordtype">unsigned</span> getSize()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> size; }
|
||||
00095 <span class="keywordtype">unsigned</span> getDepth()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> depth; }
|
||||
00096
|
||||
00097
|
||||
00098
|
||||
00099 <span class="comment">// for reference counting</span>
|
||||
00100 <span class="keywordtype">unsigned</span> refcount;
|
||||
00101
|
||||
00102 <span class="comment">// some simple stats</span>
|
||||
00103 <span class="keywordtype">unsigned</span> size;
|
||||
00104 <span class="keywordtype">unsigned</span> depth;
|
||||
00105 UniqueNodeStats* uniqueNodeStats;
|
||||
00106
|
||||
00107 };
|
||||
00108
|
||||
00109
|
||||
00110 } <span class="comment">// namespace detail</span>
|
||||
00111
|
||||
00112 <span class="preprocessor">#endif</span>
|
||||
00113 <span class="preprocessor"></span>
|
||||
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:42 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>
|
||||
124
trunk/paradiseo-eo/doc/html/_sym_ops_8cpp-source.html
Normal file
|
|
@ -0,0 +1,124 @@
|
|||
<!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: SymOps.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_000007.html">contrib</a> / <a class="el" href="dir_000008.html">mathsym</a> / <a class="el" href="dir_000022.html">fun</a></div>
|
||||
<h1>SymOps.cpp</h1><div class="fragment"><pre class="fragment">00001 <span class="comment">/* </span>
|
||||
00002 <span class="comment"> * Copyright (C) 2005 Maarten Keijzer</span>
|
||||
00003 <span class="comment"> *</span>
|
||||
00004 <span class="comment"> * This program is free software; you can redistribute it and/or modify</span>
|
||||
00005 <span class="comment"> * it under the terms of version 2 of the GNU General Public License as </span>
|
||||
00006 <span class="comment"> * published by the Free Software Foundation. </span>
|
||||
00007 <span class="comment"> *</span>
|
||||
00008 <span class="comment"> * This program is distributed in the hope that it will be useful,</span>
|
||||
00009 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
|
||||
00010 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
|
||||
00011 <span class="comment"> * GNU General Public License for more details.</span>
|
||||
00012 <span class="comment"> *</span>
|
||||
00013 <span class="comment"> * You should have received a copy of the GNU General Public License</span>
|
||||
00014 <span class="comment"> * along with this program; if not, write to the Free Software</span>
|
||||
00015 <span class="comment"> * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>
|
||||
00016 <span class="comment"> */</span>
|
||||
00017
|
||||
00018 <span class="preprocessor">#include "FunDef.h"</span>
|
||||
00019 <span class="preprocessor">#include "SymOps.h"</span>
|
||||
00020 <span class="preprocessor">#include "Sym.h"</span>
|
||||
00021
|
||||
00022 <span class="keyword">using</span> <span class="keyword">namespace </span>std;
|
||||
00023
|
||||
00024 <span class="keywordtype">void</span> collect(token_t t, Sym a, SymVec& args) {
|
||||
00025
|
||||
00026 <span class="keywordflow">if</span> (a.token() == t) {
|
||||
00027 <span class="keyword">const</span> SymVec& a_args = a.args();
|
||||
00028 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < a_args.size(); ++i) {
|
||||
00029 collect(t, a_args[i], args);
|
||||
00030 }
|
||||
00031 <span class="keywordflow">return</span>;
|
||||
00032 }
|
||||
00033
|
||||
00034 args.push_back(a);
|
||||
00035 }
|
||||
00036
|
||||
00037 Sym operator+(Sym a, Sym b) {
|
||||
00038
|
||||
00039 SymVec args;
|
||||
00040
|
||||
00041 collect(sum_token, a, args);
|
||||
00042 collect(sum_token, b, args);
|
||||
00043
|
||||
00044 <span class="keywordflow">return</span> Sym(sum_token, args);
|
||||
00045 }
|
||||
00046
|
||||
00047 Sym operator*(Sym a, Sym b) {
|
||||
00048
|
||||
00049 SymVec args;
|
||||
00050
|
||||
00051 collect(prod_token, a, args);
|
||||
00052 collect(prod_token, b, args);
|
||||
00053
|
||||
00054 <span class="keywordflow">return</span> Sym(prod_token, args);
|
||||
00055 }
|
||||
00056
|
||||
00057 Sym operator/(Sym a, Sym b) {
|
||||
00058
|
||||
00059 SymVec args;
|
||||
00060
|
||||
00061 collect(prod_token, a, args);
|
||||
00062
|
||||
00063 SymVec args2;
|
||||
00064 collect(prod_token, b, args2);
|
||||
00065
|
||||
00066 SymVec inv;
|
||||
00067 inv.push_back(Sym(prod_token, args2));
|
||||
00068
|
||||
00069 args.push_back( Sym(inv_token, inv) );
|
||||
00070
|
||||
00071 <span class="keywordflow">return</span> Sym(prod_token, args);
|
||||
00072 }
|
||||
00073
|
||||
00074 Sym operator-(Sym a, Sym b) {
|
||||
00075
|
||||
00076 SymVec args;
|
||||
00077
|
||||
00078 collect(sum_token, a, args);
|
||||
00079
|
||||
00080 SymVec args2;
|
||||
00081 collect(sum_token, b, args2);
|
||||
00082
|
||||
00083 SymVec min;
|
||||
00084 min.push_back(Sym(sum_token, args2));
|
||||
00085
|
||||
00086 args.push_back( Sym(min_token, min) );
|
||||
00087
|
||||
00088 <span class="keywordflow">return</span> Sym(sum_token, args);
|
||||
00089 }
|
||||
00090
|
||||
00091 Sym operator-(Sym a) {
|
||||
00092 <span class="keywordflow">return</span> Sym(min_token, a);
|
||||
00093 }
|
||||
00094
|
||||
00095 Sym pow(Sym a, Sym b) {
|
||||
00096 SymVec args;
|
||||
00097 args.push_back(a);
|
||||
00098 args.push_back(b);
|
||||
00099 <span class="keywordflow">return</span> Sym(pow_token, args);
|
||||
00100 }
|
||||
00101
|
||||
00102 Sym ifltz(Sym a, Sym b, Sym c) {
|
||||
00103 SymVec args;
|
||||
00104 args.push_back(a);
|
||||
00105 args.push_back(b);
|
||||
00106 args.push_back(c);
|
||||
00107 <span class="keywordflow">return</span> Sym(ifltz_token, args);
|
||||
00108 }
|
||||
00109
|
||||
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:42 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>
|
||||
46
trunk/paradiseo-eo/doc/html/_sym_ops_8h-source.html
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
<!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: SymOps.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_000008.html">mathsym</a> / <a class="el" href="dir_000022.html">fun</a></div>
|
||||
<h1>SymOps.h</h1><div class="fragment"><pre class="fragment">00001 <span class="comment">/* </span>
|
||||
00002 <span class="comment"> * Copyright (C) 2005 Maarten Keijzer</span>
|
||||
00003 <span class="comment"> *</span>
|
||||
00004 <span class="comment"> * This program is free software; you can redistribute it and/or modify</span>
|
||||
00005 <span class="comment"> * it under the terms of version 2 of the GNU General Public License as </span>
|
||||
00006 <span class="comment"> * published by the Free Software Foundation. </span>
|
||||
00007 <span class="comment"> *</span>
|
||||
00008 <span class="comment"> * This program is distributed in the hope that it will be useful,</span>
|
||||
00009 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
|
||||
00010 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
|
||||
00011 <span class="comment"> * GNU General Public License for more details.</span>
|
||||
00012 <span class="comment"> *</span>
|
||||
00013 <span class="comment"> * You should have received a copy of the GNU General Public License</span>
|
||||
00014 <span class="comment"> * along with this program; if not, write to the Free Software</span>
|
||||
00015 <span class="comment"> * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>
|
||||
00016 <span class="comment"> */</span>
|
||||
00017
|
||||
00018 <span class="preprocessor">#ifndef SYMOPS_H</span>
|
||||
00019 <span class="preprocessor"></span><span class="preprocessor">#define SYMOPS_H</span>
|
||||
00020 <span class="preprocessor"></span>
|
||||
00021 <span class="preprocessor">#include "Sym.h"</span>
|
||||
00022
|
||||
00023 <span class="keyword">extern</span> Sym operator+(Sym a, Sym b);
|
||||
00024 <span class="keyword">extern</span> Sym operator*(Sym a, Sym b);
|
||||
00025 <span class="keyword">extern</span> Sym operator/(Sym a, Sym b);
|
||||
00026 <span class="keyword">extern</span> Sym operator-(Sym a, Sym b);
|
||||
00027 <span class="keyword">extern</span> Sym pow(Sym a, Sym b);
|
||||
00028 <span class="keyword">extern</span> Sym ifltz(Sym a, Sym b, Sym c);
|
||||
00029 <span class="keyword">extern</span> Sym operator-(Sym a);
|
||||
00030
|
||||
00031 <span class="preprocessor">#endif</span>
|
||||
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:42 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>
|
||||
153
trunk/paradiseo-eo/doc/html/_target_info_8cpp-source.html
Normal file
|
|
@ -0,0 +1,153 @@
|
|||
<!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: TargetInfo.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_000007.html">contrib</a> / <a class="el" href="dir_000008.html">mathsym</a> / <a class="el" href="dir_000012.html">regression</a></div>
|
||||
<h1>TargetInfo.cpp</h1><div class="fragment"><pre class="fragment">00001 <span class="comment">/* </span>
|
||||
00002 <span class="comment"> * Copyright (C) 2005 Maarten Keijzer</span>
|
||||
00003 <span class="comment"> *</span>
|
||||
00004 <span class="comment"> * This program is free software; you can redistribute it and/or modify</span>
|
||||
00005 <span class="comment"> * it under the terms of version 2 of the GNU General Public License as </span>
|
||||
00006 <span class="comment"> * published by the Free Software Foundation. </span>
|
||||
00007 <span class="comment"> *</span>
|
||||
00008 <span class="comment"> * This program is distributed in the hope that it will be useful,</span>
|
||||
00009 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
|
||||
00010 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
|
||||
00011 <span class="comment"> * GNU General Public License for more details.</span>
|
||||
00012 <span class="comment"> *</span>
|
||||
00013 <span class="comment"> * You should have received a copy of the GNU General Public License</span>
|
||||
00014 <span class="comment"> * along with this program; if not, write to the Free Software</span>
|
||||
00015 <span class="comment"> * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>
|
||||
00016 <span class="comment"> */</span>
|
||||
00017
|
||||
00018 <span class="preprocessor">#include "TargetInfo.h"</span>
|
||||
00019
|
||||
00020 <span class="keyword">using</span> <span class="keyword">namespace </span>std;
|
||||
00021
|
||||
00022 TargetInfo::TargetInfo(<span class="keyword">const</span> TargetInfo& org) { operator=(org); }
|
||||
00023
|
||||
00024 TargetInfo& TargetInfo::operator=(<span class="keyword">const</span> TargetInfo& org) {
|
||||
00025 _targets.resize(org._targets.size());
|
||||
00026 _weights.resize(org._weights.size());
|
||||
00027 _tcov_part.resize(org._tcov_part.size());
|
||||
00028
|
||||
00029 _targets = org._targets;
|
||||
00030 _weights = org._weights;
|
||||
00031 _tcov_part = org._tcov_part;
|
||||
00032
|
||||
00033 _tmean = org._tmean;
|
||||
00034 _tvar = org._tvar;
|
||||
00035 _tstd = org._tstd;
|
||||
00036 _tmed = org._tmed;
|
||||
00037 <span class="keywordflow">return</span> *<span class="keyword">this</span>;
|
||||
00038 }
|
||||
00039
|
||||
00040
|
||||
00041 TargetInfo::TargetInfo(<span class="keyword">const</span> std::valarray<double>& t) {
|
||||
00042 _weights.resize(0);
|
||||
00043 _targets.resize(t.size());
|
||||
00044 _targets = t;
|
||||
00045
|
||||
00046 _tmean = _targets.sum()/_targets.size();
|
||||
00047
|
||||
00048 _tcov_part.resize(_targets.size());
|
||||
00049 _tcov_part = _targets;
|
||||
00050 _tcov_part -= _tmean;
|
||||
00051
|
||||
00052 std::valarray<double> tmp = _tcov_part;
|
||||
00053 tmp = _tcov_part;
|
||||
00054 tmp *= tmp;
|
||||
00055
|
||||
00056 _tvar = tmp.sum() / (tmp.size()-1);
|
||||
00057 _tstd = sqrt(_tvar);
|
||||
00058 _tmed = 0;
|
||||
00059 }
|
||||
00060
|
||||
00061 TargetInfo::TargetInfo(<span class="keyword">const</span> std::valarray<double>& t, <span class="keyword">const</span> std::valarray<double>& w) {
|
||||
00062
|
||||
00063 _targets.resize(t.size());
|
||||
00064 _weights.resize(w.size());
|
||||
00065
|
||||
00066 _targets = t;
|
||||
00067 _weights = w;
|
||||
00068
|
||||
00069 <span class="keywordtype">double</span> sumw = _weights.sum();
|
||||
00070 <span class="comment">// scale weights so that they'll add up to 1</span>
|
||||
00071 _weights /= sumw;
|
||||
00072
|
||||
00073 _tmean = (_targets * _weights).sum();
|
||||
00074 _tcov_part.resize(_targets.size());
|
||||
00075 _tcov_part = _targets;
|
||||
00076 _tcov_part -= _tmean;
|
||||
00077
|
||||
00078 _tvar = (pow(_targets - _tmean, 2.0) * _weights).sum();
|
||||
00079 _tstd = sqrt(_tvar);
|
||||
00080 _tmed = 0.;
|
||||
00081 }
|
||||
00082
|
||||
00083 <span class="comment">// calculate the members, now in the context of a mask</span>
|
||||
00084 <span class="keywordtype">void</span> TargetInfo::set_training_mask(<span class="keyword">const</span> std::valarray<bool>& tmask) {
|
||||
00085
|
||||
00086 TargetInfo tmp;
|
||||
00087
|
||||
00088 <span class="keywordflow">if</span> (has_weights() ) {
|
||||
00089 tmp = TargetInfo( _targets[tmask], _weights[tmask]);
|
||||
00090 } <span class="keywordflow">else</span> {
|
||||
00091 tmp = TargetInfo( _targets[tmask] );
|
||||
00092 }
|
||||
00093
|
||||
00094 _tcov_part.resize(tmp._tcov_part.size());
|
||||
00095 _tcov_part = tmp._tcov_part;
|
||||
00096
|
||||
00097 _tmean = tmp._tmean;
|
||||
00098 _tvar = tmp._tvar;
|
||||
00099 _tstd = tmp._tstd;
|
||||
00100 _tmed = tmp._tmed;
|
||||
00101
|
||||
00102 _training_mask.resize(tmask.size());
|
||||
00103 _training_mask = tmask;
|
||||
00104 }
|
||||
00105
|
||||
00106 <span class="keyword">struct </span>SortOnTargets
|
||||
00107 {
|
||||
00108 <span class="keyword">const</span> valarray<double>& t;
|
||||
00109 SortOnTargets(<span class="keyword">const</span> valarray<double>& v) : t(v) {}
|
||||
00110
|
||||
00111 <span class="keywordtype">bool</span> operator()(<span class="keywordtype">int</span> i, <span class="keywordtype">int</span> j)<span class="keyword"> const </span>{
|
||||
00112 <span class="keywordflow">return</span> fabs(t[i]) < fabs(t[j]);
|
||||
00113 }
|
||||
00114 };
|
||||
00115
|
||||
00116 vector<int> TargetInfo::sort() {
|
||||
00117
|
||||
00118 vector<int> ind(_targets.size());
|
||||
00119 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < ind.size(); ++i) { ind[i] = i; }
|
||||
00120
|
||||
00121 std::sort(ind.begin(), ind.end(), SortOnTargets(_targets));
|
||||
00122
|
||||
00123 valarray<double> tmptargets = _targets;
|
||||
00124 valarray<double> tmpweights = _weights;
|
||||
00125 valarray<double> tmpcov = _tcov_part;
|
||||
00126
|
||||
00127 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < ind.size(); ++i)
|
||||
00128 {
|
||||
00129 _targets[i] = tmptargets[ ind[i] ];
|
||||
00130 _tcov_part[i] = tmpcov[ ind[i] ];
|
||||
00131 <span class="keywordflow">if</span> (_weights.size()) _weights[i] = tmpweights[ ind[i] ];
|
||||
00132 }
|
||||
00133
|
||||
00134 <span class="keywordflow">return</span> ind;
|
||||
00135 }
|
||||
00136
|
||||
00137
|
||||
00138
|
||||
</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>
|
||||
80
trunk/paradiseo-eo/doc/html/_target_info_8h-source.html
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
<!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: TargetInfo.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_000008.html">mathsym</a> / <a class="el" href="dir_000012.html">regression</a></div>
|
||||
<h1>TargetInfo.h</h1><div class="fragment"><pre class="fragment">00001 <span class="comment">/* </span>
|
||||
00002 <span class="comment"> * Copyright (C) 2005 Maarten Keijzer</span>
|
||||
00003 <span class="comment"> *</span>
|
||||
00004 <span class="comment"> * This program is free software; you can redistribute it and/or modify</span>
|
||||
00005 <span class="comment"> * it under the terms of version 2 of the GNU General Public License as </span>
|
||||
00006 <span class="comment"> * published by the Free Software Foundation. </span>
|
||||
00007 <span class="comment"> *</span>
|
||||
00008 <span class="comment"> * This program is distributed in the hope that it will be useful,</span>
|
||||
00009 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
|
||||
00010 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
|
||||
00011 <span class="comment"> * GNU General Public License for more details.</span>
|
||||
00012 <span class="comment"> *</span>
|
||||
00013 <span class="comment"> * You should have received a copy of the GNU General Public License</span>
|
||||
00014 <span class="comment"> * along with this program; if not, write to the Free Software</span>
|
||||
00015 <span class="comment"> * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>
|
||||
00016 <span class="comment"> */</span>
|
||||
00017
|
||||
00018 <span class="preprocessor">#ifndef TARGETINFO_H_</span>
|
||||
00019 <span class="preprocessor"></span><span class="preprocessor">#define TARGETINFO_H_</span>
|
||||
00020 <span class="preprocessor"></span>
|
||||
00021 <span class="preprocessor">#include <valarray></span>
|
||||
00022 <span class="preprocessor">#include <vector></span>
|
||||
00023
|
||||
00024 <span class="keyword">class </span>TargetInfo {
|
||||
00025 std::valarray<double> _targets;
|
||||
00026 std::valarray<double> _weights;
|
||||
00027 std::valarray<bool> _training_mask;
|
||||
00028
|
||||
00029 <span class="comment">// some stuff for ols</span>
|
||||
00030 std::valarray<double> _tcov_part;
|
||||
00031 <span class="keywordtype">double</span> _tmean;
|
||||
00032 <span class="keywordtype">double</span> _tvar;
|
||||
00033 <span class="keywordtype">double</span> _tstd;
|
||||
00034 <span class="keywordtype">double</span> _tmed;
|
||||
00035
|
||||
00036 <span class="keyword">public</span>:
|
||||
00037 TargetInfo() {}
|
||||
00038
|
||||
00039 TargetInfo(<span class="keyword">const</span> std::valarray<double>& t);
|
||||
00040 TargetInfo(<span class="keyword">const</span> std::valarray<double>& t, <span class="keyword">const</span> std::valarray<double>& w);
|
||||
00041
|
||||
00042 TargetInfo(<span class="keyword">const</span> TargetInfo& org);
|
||||
00043 TargetInfo& operator=(<span class="keyword">const</span> TargetInfo& org);
|
||||
00044 ~TargetInfo() {}
|
||||
00045
|
||||
00046 <span class="keyword">const</span> std::valarray<double>& targets()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> _targets; }
|
||||
00047 <span class="keyword">const</span> std::valarray<double>& weights()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> _weights; }
|
||||
00048 <span class="keyword">const</span> std::valarray<bool>& mask()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> _training_mask; }
|
||||
00049
|
||||
00050 <span class="keywordtype">void</span> set_training_mask(<span class="keyword">const</span> std::valarray<bool>& mask);
|
||||
00051
|
||||
00052 <span class="keywordtype">bool</span> has_weights()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> _weights.size(); }
|
||||
00053 <span class="keywordtype">bool</span> has_mask()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> _training_mask.size(); }
|
||||
00054
|
||||
00055 std::vector<int> sort();
|
||||
00056
|
||||
00057 <span class="keyword">const</span> std::valarray<double>& tcov_part()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> _tcov_part; }
|
||||
00058 <span class="keywordtype">double</span> tmean()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> _tmean; }
|
||||
00059 <span class="keywordtype">double</span> tvar()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> _tvar; }
|
||||
00060 <span class="keywordtype">double</span> tstd()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> _tstd; }
|
||||
00061 <span class="keywordtype">double</span> devmedian()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> _tmed; }
|
||||
00062 };
|
||||
00063
|
||||
00064 <span class="preprocessor">#endif</span>
|
||||
00065 <span class="preprocessor"></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>
|
||||
61
trunk/paradiseo-eo/doc/html/_tree_builder_8cpp-source.html
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
<!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: TreeBuilder.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_000007.html">contrib</a> / <a class="el" href="dir_000008.html">mathsym</a> / <a class="el" href="dir_000024.html">gen</a></div>
|
||||
<h1>TreeBuilder.cpp</h1><div class="fragment"><pre class="fragment">00001 <span class="comment">/* </span>
|
||||
00002 <span class="comment"> * Copyright (C) 2005 Maarten Keijzer</span>
|
||||
00003 <span class="comment"> *</span>
|
||||
00004 <span class="comment"> * This program is free software; you can redistribute it and/or modify</span>
|
||||
00005 <span class="comment"> * it under the terms of version 2 of the GNU General Public License as </span>
|
||||
00006 <span class="comment"> * published by the Free Software Foundation. </span>
|
||||
00007 <span class="comment"> *</span>
|
||||
00008 <span class="comment"> * This program is distributed in the hope that it will be useful,</span>
|
||||
00009 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
|
||||
00010 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
|
||||
00011 <span class="comment"> * GNU General Public License for more details.</span>
|
||||
00012 <span class="comment"> *</span>
|
||||
00013 <span class="comment"> * You should have received a copy of the GNU General Public License</span>
|
||||
00014 <span class="comment"> * along with this program; if not, write to the Free Software</span>
|
||||
00015 <span class="comment"> * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>
|
||||
00016 <span class="comment"> */</span>
|
||||
00017
|
||||
00018 <span class="preprocessor">#include <utils/eoRNG.h></span>
|
||||
00019 <span class="preprocessor">#include "TreeBuilder.h"</span>
|
||||
00020
|
||||
00021 Sym TreeBuilder::make_terminal()<span class="keyword"> const </span>{
|
||||
00022 <span class="keywordflow">if</span> (rng.<a class="code" href="classeo_rng.html#a6">flip</a>(vcprob)) {
|
||||
00023 <span class="keywordflow">return</span> table.get_random_var();
|
||||
00024 }
|
||||
00025
|
||||
00026 <span class="keywordflow">return</span> table.get_random_const();
|
||||
00027 }
|
||||
00028
|
||||
00029 Sym TreeBuilder::build_tree(<span class="keywordtype">unsigned</span> max_depth, <span class="keywordtype">bool</span> grow)<span class="keyword"> const </span>{
|
||||
00030 <span class="keywordflow">if</span> (max_depth == 0 || grow && rng.<a class="code" href="classeo_rng.html#a5">random</a>(2) == 0) {
|
||||
00031 <span class="keywordflow">return</span> make_terminal();
|
||||
00032 }
|
||||
00033
|
||||
00034 <span class="comment">// pick a random function, no matter what arity</span>
|
||||
00035
|
||||
00036 functor_t func = table.get_random_function();
|
||||
00037
|
||||
00038 SymVec args(func.arity);
|
||||
00039
|
||||
00040 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < args.size(); ++i) {
|
||||
00041 args[i] = build_tree(max_depth-1, grow);
|
||||
00042 }
|
||||
00043
|
||||
00044 <span class="keywordflow">return</span> Sym(func.token, args);
|
||||
00045 }
|
||||
00046
|
||||
</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>
|
||||
60
trunk/paradiseo-eo/doc/html/_tree_builder_8h-source.html
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
<!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: TreeBuilder.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_000008.html">mathsym</a> / <a class="el" href="dir_000024.html">gen</a></div>
|
||||
<h1>TreeBuilder.h</h1><div class="fragment"><pre class="fragment">00001 <span class="comment">/* </span>
|
||||
00002 <span class="comment"> * Copyright (C) 2005 Maarten Keijzer</span>
|
||||
00003 <span class="comment"> *</span>
|
||||
00004 <span class="comment"> * This program is free software; you can redistribute it and/or modify</span>
|
||||
00005 <span class="comment"> * it under the terms of version 2 of the GNU General Public License as </span>
|
||||
00006 <span class="comment"> * published by the Free Software Foundation. </span>
|
||||
00007 <span class="comment"> *</span>
|
||||
00008 <span class="comment"> * This program is distributed in the hope that it will be useful,</span>
|
||||
00009 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
|
||||
00010 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
|
||||
00011 <span class="comment"> * GNU General Public License for more details.</span>
|
||||
00012 <span class="comment"> *</span>
|
||||
00013 <span class="comment"> * You should have received a copy of the GNU General Public License</span>
|
||||
00014 <span class="comment"> * along with this program; if not, write to the Free Software</span>
|
||||
00015 <span class="comment"> * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>
|
||||
00016 <span class="comment"> */</span>
|
||||
00017
|
||||
00018 <span class="preprocessor">#ifndef TREEBUILDER_H_</span>
|
||||
00019 <span class="preprocessor"></span><span class="preprocessor">#define TREEBUILDER_H_</span>
|
||||
00020 <span class="preprocessor"></span>
|
||||
00021 <span class="preprocessor">#include "Sym.h"</span>
|
||||
00022 <span class="preprocessor">#include "LanguageTable.h"</span>
|
||||
00023
|
||||
00024 <span class="keyword">class </span>TreeBuilder {
|
||||
00025 <span class="keyword">const</span> LanguageTable& table;
|
||||
00026
|
||||
00027 <span class="comment">// probability of selecting a var versus a const when the choice boils down to selecting a terminal</span>
|
||||
00028 <span class="keywordtype">double</span> vcprob;
|
||||
00029
|
||||
00030 Sym make_terminal() <span class="keyword">const</span>;
|
||||
00031 <span class="keyword">public</span>:
|
||||
00032
|
||||
00033 TreeBuilder(<span class="keyword">const</span> LanguageTable& t) : table(t), vcprob(0.9) {};
|
||||
00034 TreeBuilder(<span class="keyword">const</span> LanguageTable& t, <span class="keywordtype">double</span> vc) : table(t), vcprob(vc) {};
|
||||
00035
|
||||
00036 <span class="keywordtype">void</span> set_var_vs_const_probability(<span class="keywordtype">double</span> p) { vcprob = p; }
|
||||
00037
|
||||
00038 Sym build_tree(<span class="keywordtype">unsigned</span> max_depth, <span class="keywordtype">bool</span> grow) <span class="keyword">const</span>;
|
||||
00039
|
||||
00040 <span class="keywordtype">void</span> build_tree(Sym& tree, <span class="keywordtype">unsigned</span> max_depth, <span class="keywordtype">bool</span> grow)<span class="keyword"> const </span>{ tree = build_tree(max_depth, grow); }
|
||||
00041
|
||||
00042 };
|
||||
00043
|
||||
00044 <span class="preprocessor">#endif</span>
|
||||
00045 <span class="preprocessor"></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>
|
||||
133
trunk/paradiseo-eo/doc/html/_virus_op_8h-source.html
Normal file
|
|
@ -0,0 +1,133 @@
|
|||
<!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>
|
||||
61
trunk/paradiseo-eo/doc/html/abstract1_8cpp-source.html
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
<!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: abstract1.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_000000.html">src</a> / <a class="el" href="dir_000001.html">pyeo</a></div>
|
||||
<h1>abstract1.cpp</h1><div class="fragment"><pre class="fragment">00001 <span class="comment">/*</span>
|
||||
00002 <span class="comment"> PyEO</span>
|
||||
00003 <span class="comment"> </span>
|
||||
00004 <span class="comment"> Copyright (C) 2003 Maarten Keijzer</span>
|
||||
00005 <span class="comment"></span>
|
||||
00006 <span class="comment"> This program is free software; you can redistribute it and/or modify</span>
|
||||
00007 <span class="comment"> it under the terms of the GNU General Public License as published by</span>
|
||||
00008 <span class="comment"> the Free Software Foundation; either version 2 of the License, or</span>
|
||||
00009 <span class="comment"> (at your option) any later version.</span>
|
||||
00010 <span class="comment"></span>
|
||||
00011 <span class="comment"> This program is distributed in the hope that it will be useful,</span>
|
||||
00012 <span class="comment"> but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
|
||||
00013 <span class="comment"> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
|
||||
00014 <span class="comment"> GNU General Public License for more details.</span>
|
||||
00015 <span class="comment"></span>
|
||||
00016 <span class="comment"> You should have received a copy of the GNU General Public License</span>
|
||||
00017 <span class="comment"> along with this program; if not, write to the Free Software</span>
|
||||
00018 <span class="comment"> Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>
|
||||
00019 <span class="comment">*/</span>
|
||||
00020
|
||||
00021 <span class="preprocessor">#include <eoEvalFunc.h></span>
|
||||
00022 <span class="preprocessor">#include <eoInit.h></span>
|
||||
00023 <span class="preprocessor">#include <eoTransform.h></span>
|
||||
00024 <span class="preprocessor">#include <eoSGATransform.h></span>
|
||||
00025 <span class="preprocessor">#include <eoPopEvalFunc.h></span>
|
||||
00026
|
||||
00027 <span class="preprocessor">#include "PyEO.h"</span>
|
||||
00028 <span class="preprocessor">#include "def_abstract_functor.h"</span>
|
||||
00029
|
||||
00030 <span class="keyword">using</span> <span class="keyword">namespace </span>boost::python;
|
||||
00031
|
||||
00032 <span class="keywordtype">void</span> abstract1()
|
||||
00033 {
|
||||
00034 <span class="comment">/* Abstract Classes: overrideble from python */</span>
|
||||
00035 def_abstract_functor<eoEvalFunc<PyEO> >(<span class="stringliteral">"eoEvalFunc"</span>);
|
||||
00036 def_abstract_functor<eoInit< PyEO > >(<span class="stringliteral">"eoInit"</span>);
|
||||
00037
|
||||
00038 def_abstract_functor<eoTransform<PyEO> >(<span class="stringliteral">"eoTransform"</span>);
|
||||
00039
|
||||
00040 class_<eoSGATransform<PyEO>, bases<eoTransform<PyEO> > >(<span class="stringliteral">"eoSGATransform"</span>,
|
||||
00041 init< eoQuadOp<PyEO>&, double,
|
||||
00042 <a class="code" href="classeo_mon_op.html">eoMonOp<PyEO></a>&, <span class="keywordtype">double</span>>())
|
||||
00043 .def(<span class="stringliteral">"__call__"</span>, &<a class="code" href="classeo_s_g_a_transform.html">eoSGATransform<PyEO></a>::<span class="keyword">operator</span>());
|
||||
00044
|
||||
00045 def_abstract_functor<eoPopEvalFunc<PyEO> >(<span class="stringliteral">"eoPopEvalFunc"</span>);
|
||||
00046 }
|
||||
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:34 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>
|
||||
121
trunk/paradiseo-eo/doc/html/algos_8cpp-source.html
Normal file
|
|
@ -0,0 +1,121 @@
|
|||
<!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: algos.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_000000.html">src</a> / <a class="el" href="dir_000001.html">pyeo</a></div>
|
||||
<h1>algos.cpp</h1><div class="fragment"><pre class="fragment">00001 <span class="comment">/*</span>
|
||||
00002 <span class="comment"> PyEO</span>
|
||||
00003 <span class="comment"> </span>
|
||||
00004 <span class="comment"> Copyright (C) 2003 Maarten Keijzer</span>
|
||||
00005 <span class="comment"></span>
|
||||
00006 <span class="comment"> This program is free software; you can redistribute it and/or modify</span>
|
||||
00007 <span class="comment"> it under the terms of the GNU General Public License as published by</span>
|
||||
00008 <span class="comment"> the Free Software Foundation; either version 2 of the License, or</span>
|
||||
00009 <span class="comment"> (at your option) any later version.</span>
|
||||
00010 <span class="comment"></span>
|
||||
00011 <span class="comment"> This program is distributed in the hope that it will be useful,</span>
|
||||
00012 <span class="comment"> but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
|
||||
00013 <span class="comment"> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
|
||||
00014 <span class="comment"> GNU General Public License for more details.</span>
|
||||
00015 <span class="comment"></span>
|
||||
00016 <span class="comment"> You should have received a copy of the GNU General Public License</span>
|
||||
00017 <span class="comment"> along with this program; if not, write to the Free Software</span>
|
||||
00018 <span class="comment"> Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>
|
||||
00019 <span class="comment">*/</span>
|
||||
00020
|
||||
00021 <span class="preprocessor">#include <eoSGA.h></span>
|
||||
00022 <span class="preprocessor">#include <eoEasyEA.h></span>
|
||||
00023 <span class="preprocessor">#include <eoDetSelect.h></span>
|
||||
00024 <span class="preprocessor">#include <eoCellularEasyEA.h></span>
|
||||
00025
|
||||
00026 <span class="preprocessor">#include "PyEO.h"</span>
|
||||
00027 <span class="preprocessor">#include "def_abstract_functor.h"</span>
|
||||
00028
|
||||
00029 <span class="keyword">using</span> <span class="keyword">namespace </span>boost::python;
|
||||
00030
|
||||
00031 <span class="keywordtype">void</span> algos()
|
||||
00032 {
|
||||
00033 def_abstract_functor<eoAlgo<PyEO> >(<span class="stringliteral">"eoAlgo"</span>);
|
||||
00034
|
||||
00035 <span class="comment">/* Algorithms */</span>
|
||||
00036 class_<eoSGA<PyEO>, bases<eoAlgo<PyEO> >, boost::noncopyable>(<span class="stringliteral">"eoSGA"</span>,
|
||||
00037 init<eoSelectOne<PyEO>&,
|
||||
00038 <a class="code" href="classeo_quad_op.html">eoQuadOp<PyEO></a>&, float,
|
||||
00039 <a class="code" href="classeo_mon_op.html">eoMonOp<PyEO></a>&, float,
|
||||
00040 <a class="code" href="classeo_eval_func.html">eoEvalFunc<PyEO></a>&,
|
||||
00041 <a class="code" href="classeo_continue.html">eoContinue<PyEO></a>&>()
|
||||
00042 [
|
||||
00043 with_custodian_and_ward<1,2,
|
||||
00044 with_custodian_and_ward<1,3,
|
||||
00045 with_custodian_and_ward<1,5,
|
||||
00046 with_custodian_and_ward<1,7,
|
||||
00047 with_custodian_and_ward<1,8>
|
||||
00048 >
|
||||
00049 >
|
||||
00050 >
|
||||
00051 >()
|
||||
00052 ])
|
||||
00053 .def(<span class="stringliteral">"__call__"</span>, &<a class="code" href="classeo_s_g_a.html">eoSGA<PyEO></a>::<span class="keyword">operator</span>())
|
||||
00054 ;
|
||||
00055
|
||||
00056 class_<eoEasyEA<PyEO>, bases<eoAlgo<PyEO> > >(<span class="stringliteral">"eoEasyEA"</span>,
|
||||
00057 init<
|
||||
00058 <a class="code" href="classeo_continue.html">eoContinue<PyEO></a>&,
|
||||
00059 eoEvalFunc<PyEO>&,
|
||||
00060 <a class="code" href="classeo_breed.html">eoBreed<PyEO></a>&,
|
||||
00061 <a class="code" href="classeo_replacement.html">eoReplacement<PyEO></a>& >() )
|
||||
00062 .def( init<
|
||||
00063 eoContinue<PyEO>&,
|
||||
00064 <a class="code" href="classeo_pop_eval_func.html">eoPopEvalFunc<PyEO></a>&,
|
||||
00065 eoBreed<PyEO>&,
|
||||
00066 <a class="code" href="classeo_replacement.html">eoReplacement<PyEO></a>&>() )
|
||||
00067 .def( init<
|
||||
00068 eoContinue<PyEO>&,
|
||||
00069 eoEvalFunc<PyEO>&,
|
||||
00070 eoBreed<PyEO>&,
|
||||
00071 <a class="code" href="classeo_merge.html">eoMerge<PyEO></a>&,
|
||||
00072 <a class="code" href="classeo_reduce.html">eoReduce<PyEO></a>& >() )
|
||||
00073 .def( init<
|
||||
00074 eoContinue<PyEO>&,
|
||||
00075 eoEvalFunc<PyEO>&,
|
||||
00076 <a class="code" href="classeo_select.html">eoSelect<PyEO></a>&,
|
||||
00077 <a class="code" href="classeo_transform.html">eoTransform<PyEO></a>&,
|
||||
00078 <a class="code" href="classeo_replacement.html">eoReplacement<PyEO></a>&>())
|
||||
00079 .def( init<
|
||||
00080 eoContinue<PyEO>&,
|
||||
00081 eoEvalFunc<PyEO>&,
|
||||
00082 <a class="code" href="classeo_select.html">eoSelect<PyEO></a>&,
|
||||
00083 <a class="code" href="classeo_transform.html">eoTransform<PyEO></a>&,
|
||||
00084 <a class="code" href="classeo_merge.html">eoMerge<PyEO></a>&,
|
||||
00085 <a class="code" href="classeo_reduce.html">eoReduce<PyEO></a>&>())
|
||||
00086 .def(<span class="stringliteral">"__call__"</span>, &<a class="code" href="classeo_easy_e_a.html">eoEasyEA<PyEO></a>::<span class="keyword">operator</span>())
|
||||
00087 ;
|
||||
00088
|
||||
00089 <span class="comment">/*</span>
|
||||
00090 <span class="comment"> class_<eoCellularEasyEA<PyEO>, bases< eoAlgo<PyEO> > >("eoCellularEasyEA", </span>
|
||||
00091 <span class="comment"> init< eoContinue<PyEO>&,</span>
|
||||
00092 <span class="comment"> eoEvalFunc<PyEO>&,</span>
|
||||
00093 <span class="comment"> eoSelectOne<PyEO>&,</span>
|
||||
00094 <span class="comment"> eoBinOp<PyEO>&,</span>
|
||||
00095 <span class="comment"> eoMonOp<PyEO>&,</span>
|
||||
00096 <span class="comment"> eoSelectOne<PyEO>&>())</span>
|
||||
00097 <span class="comment"> .def(</span>
|
||||
00098 <span class="comment"> init< eoContinue<PyEO>&,</span>
|
||||
00099 <span class="comment"> eoEvalFunc<PyEO>&,</span>
|
||||
00100 <span class="comment"> eoSelectOne<PyEO>&,</span>
|
||||
00101 <span class="comment"> eoQuadOp<PyEO>&,</span>
|
||||
00102 <span class="comment"> eoMonOp<PyEO>&,</span>
|
||||
00103 <span class="comment"> eoSelectOne<PyEO>&>())</span>
|
||||
00104 <span class="comment"> ;</span>
|
||||
00105 <span class="comment"> */</span>
|
||||
00106 }
|
||||
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:34 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>
|
||||
361
trunk/paradiseo-eo/doc/html/annotated.html
Normal file
|
|
@ -0,0 +1,361 @@
|
|||
<!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: Class List</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="qindexHL" 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>
|
||||
<h1>EO Class List</h1>Here are the classes, structs, unions and interfaces with brief descriptions:<table>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo1_pt_bit_crossover.html">eo1PtBitCrossover</a></td><td class="indexvalue">Eo1PtBitXover --> classic 1-point crossover </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_aged.html">eoAged< Object ></a></td><td class="indexvalue">EoAge is a template class that adds an age to an object.\ Requisites for template instantiation are that the object must admit a default ctor and a copy ctor </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_algo.html">eoAlgo< EOT ></a></td><td class="indexvalue">This is a generic class for population-transforming algorithms </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_arithmetic_crossover.html">eoArithmeticCrossover</a></td><td class="indexvalue">EoHypercubeCrossover --> uniform choice in hypercube == arithmetical with different values for each coordinate </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_assembled_fitness_average_stat.html">eoAssembledFitnessAverageStat< EOT ></a></td><td class="indexvalue">Average fitness values of a population, where the fitness is of type eoScalarAssembledFitness </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_assembled_fitness_best_stat.html">eoAssembledFitnessBestStat< EOT ></a></td><td class="indexvalue">Fitness values of best individuum in a population, where the fitness is of type eoScalarAssembledFitness </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_atom_exchange.html">eoAtomExchange< Atom ></a></td><td class="indexvalue">A helper class for choosing which genes to exchange </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_average_stat.html">eoAverageStat< EOT ></a></td><td class="indexvalue">Average fitness of a population </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_best_fitness_stat.html">eoBestFitnessStat< EOT ></a></td><td class="indexvalue">Best fitness of a population </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_best_select.html">eoBestSelect< EOT ></a></td><td class="indexvalue">EoBestSelect: a selection method that always return the best (mainly for testing purposes) </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_b_f.html">eoBF< A1, A2, R ></a></td><td class="indexvalue">Basic Binary Functor </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="class_biased_node_selector.html">BiasedNodeSelector</a></td><td class="indexvalue">A node selector that does a specified number of rounds ignoring terminals </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_binary_functor_counter.html">eoBinaryFunctorCounter< BinaryFunctor ></a></td><td class="indexvalue">Generic counter class that counts the number of times a binary function is used </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_bin_clone_op.html">eoBinCloneOp< EOT ></a></td><td class="indexvalue">Binary clone: two operands, only the first could be modified </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_bin_gen_op.html">eoBinGenOp< EOT ></a></td><td class="indexvalue">Wrapper for binop: here we use select method of <a class="el" href="classeo_populator.html">eoPopulator</a> but we could also have an embedded selector to select the second parent </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_bin_op.html">eoBinOp< EOType ></a></td><td class="indexvalue">Binary genetic operator: subclasses <a class="el" href="classeo_op.html">eoOp</a>, and defines basically the operator() with two operands, only the first one can be modified When defining your own, make sure that you return a boolean value indicating that you have changed the content </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_bit.html">eoBit< FitT ></a></td><td class="indexvalue">Implementation of bitstring chromosome </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_bit_bit_flip.html">eoBitBitFlip</a></td><td class="indexvalue">EoBitFlip --> changes 1 bit </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_bit_gx_over.html">eoBitGxOver< Chrom ></a></td><td class="indexvalue">EoBitGxOver --> Npts crossover when bistd::string considered as a std::string of binary-encoded genes (exchanges genes) Is anybody still using it apart from historians ??? :-) </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_bit_inversion.html">eoBitInversion< Chrom ></a></td><td class="indexvalue">EoBitInversion: inverts the bits of the chromosome between an interval </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_bit_mutation.html">eoBitMutation< Chrom ></a></td><td class="indexvalue">EoBitMutation --> classical mutation </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_bit_next.html">eoBitNext< Chrom ></a></td><td class="indexvalue">EoBitNext --> next value when bitstring considered as binary value </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_bit_op_factory.html">eoBitOpFactory< EOT ></a></td><td class="indexvalue"><a class="el" href="class_e_o.html">EO</a> Factory </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_bit_prev.html">eoBitPrev< Chrom ></a></td><td class="indexvalue">EoBitPrev --> previous value when bitstring treated as binary value </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classboolean__generator.html">boolean_generator</a></td><td class="indexvalue">The class boolean_generator can be used in the STL generate function to easily generate random booleans with a specified bias </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_boolean_generator.html">eoBooleanGenerator</a></td><td class="indexvalue">The class eoBooleanGenerator can be used in the STL generate function to easily generate random booleans with a specified bias </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_boolean_init.html">eoBooleanInit</a></td><td class="indexvalue">The class eoBooleanInit can be used in the STL apply function to easily generate random booleans with a specified bias </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_bool_flip.html">eoBoolFlip</a></td><td class="indexvalue">Simple boolean mutation - to be used in generic eoOp's </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_branch_mutation.html">eoBranchMutation< FType, Node ></a></td><td class="indexvalue">EoBranchMutation --> replace a subtree with a randomly created subtree </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_breed.html">eoBreed< EOT ></a></td><td class="indexvalue">Breeding: combination of selecting and transforming a population </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_cellular_easy_e_a.html">eoCellularEasyEA< EOT ></a></td><td class="indexvalue">The abstract cellular easy algorithm </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_check_point.html">eoCheckPoint< EOT ></a></td><td class="indexvalue">EoCheckPoint is a container class </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_c_m_a_breed.html">eoCMABreed< FitT ></a></td><td class="indexvalue">TODO, handle bounds </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_c_m_a_init.html">eoCMAInit< FitT ></a></td><td class="indexvalue">TODO, handle bounds </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_collapse_subtree_mutation.html">eoCollapseSubtreeMutation< FType, Node ></a></td><td class="indexvalue">EoCollapseSubtree --> replace a subtree with a randomly chosen terminal </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_combined_continue.html">eoCombinedContinue< EOT ></a></td><td class="indexvalue">Combined continuators - logical AND: Continues until one of the embedded continuators says halt! </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_combined_init.html">eoCombinedInit< EOT ></a></td><td class="indexvalue">Combined INIT: a proportional recombination of <a class="el" href="classeo_init.html">eoInit</a> objects </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_comma_replacement.html">eoCommaReplacement< EOT ></a></td><td class="indexvalue">ES type of replacement strategy: ignore parents, truncate offspring </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_continue.html">eoContinue< EOT ></a></td><td class="indexvalue">Termination condition for the genetic algorithm Takes the population as input, returns true for continue, false for termination </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_counted_dyn_update.html">eoCountedDynUpdate</a></td><td class="indexvalue">An <a class="el" href="classeo_updater.html">eoUpdater</a> to update an <a class="el" href="classeo_updatable.html">eoUpdatable</a> object every given tic </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_counted_state_saver.html">eoCountedStateSaver</a></td><td class="indexvalue">EoUpdater that saves a state every given generations </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="class_cov.html">Cov</a></td><td class="indexvalue">Single covariance between two variates </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_ctrl_c_continue.html">eoCtrlCContinue< EOT ></a></td><td class="indexvalue">Ctrl C handling: this <a class="el" href="classeo_continue.html">eoContinue</a> tells whether the user pressed Ctrl C </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_det_bit_flip.html">eoDetBitFlip< Chrom ></a></td><td class="indexvalue">EoDetBitFlip --> changes exactly k bits </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_deterministic_sa_d_replacement.html">eoDeterministicSaDReplacement< EOT ></a></td><td class="indexvalue">EoDeterministicSaDReplacement: replacement strategy that is just, in sequence saves best and kill worse from parents + saves best and kill worse from offspring + merge remaining (neither save nor killed) parents and offspring + reduce that merged population = returns reduced pop + best parents + best offspring </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_deterministic_survive_and_die.html">eoDeterministicSurviveAndDie< EOT ></a></td><td class="indexvalue">An instance (theonly one as of today, Dec </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_det_select.html">eoDetSelect< EOT ></a></td><td class="indexvalue">EoDetSelect selects many individuals determinisctically </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_det_tournament_select.html">eoDetTournamentSelect< EOT ></a></td><td class="indexvalue">EoDetTournamentSelect: a selection method that selects ONE individual by deterministic tournament -MS- 24/10/99 </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_det_tournament_truncate.html">eoDetTournamentTruncate< EOT ></a></td><td class="indexvalue">Truncate class based on a repeated deterministic (reverse!) tournament To be used in SSGA-like replacements (e.g </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_det_tournament_truncate_split.html">eoDetTournamentTruncateSplit< EOT ></a></td><td class="indexvalue">ReduceSplit class based on a repeated deterministic (reverse!) tournament To be used in SSGA-like replacements (e.g </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_det_tournament_worth_select.html">eoDetTournamentWorthSelect< EOT, WorthT ></a></td><td class="indexvalue">An instance of eoSelectPerf2Worth that does selection from the Worthes using a .. </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_det_uniform_mutation.html">eoDetUniformMutation< EOT ></a></td><td class="indexvalue">EoDetUniformMutation --> changes exactly k values of the std::vector by uniform choice with range epsilon </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_distance.html">eoDistance< EOT ></a></td><td class="indexvalue">This is a generic class for distance functors: takes 2 things ane returns a double </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_distrib_updater.html">eoDistribUpdater< EOT ></a></td><td class="indexvalue">Base class for Distribution Evolution Algorithms within <a class="el" href="class_e_o.html">EO</a>: the update rule of distribution </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_distribution.html">eoDistribution< EOT ></a></td><td class="indexvalue">Abstract class for Distribution Evolution Algorithms within <a class="el" href="class_e_o.html">EO</a>: the distribution itself </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classd_matrix.html">dMatrix</a></td><td class="indexvalue">A helper class for Sharing - to hold distances </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_dominance_map.html">eoDominanceMap< EoType ></a></td><td class="indexvalue">EoDominanceMap, utility class to calculate and maintain a map (std::vector<std::vector<bool> >) of pareto dominance statistics </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_double_exchange.html">eoDoubleExchange</a></td><td class="indexvalue">Discrete crossover == exchange of values </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_double_intermediate.html">eoDoubleIntermediate</a></td><td class="indexvalue">Intermediate crossover == linear combination </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_drawable.html">eoDrawable< Object ></a></td><td class="indexvalue">EoDrawable is a template class that adds a drawing interface to an object.\ Requisites for template instantiation are that the object must admit a default ctor and a copy ctor </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="struct_dummy.html">Dummy</a></td><td class="indexvalue">Test program for the general operator - millenium version! uses dummy individuals </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_dyn_s_g_a_transform.html">eoDynSGATransform< EOT ></a></td><td class="indexvalue">EoDynSGATransform: transforms a population using genetic operators </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_dyn_updater.html">eoDynUpdater</a></td><td class="indexvalue">A base class to actually update an <a class="el" href="classeo_updatable.html">eoUpdatable</a> object </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_easy_e_a.html">eoEasyEA< EOT ></a></td><td class="indexvalue">An easy-to-use evolutionary algorithm; you can use any chromosome, and any selection transformation, merging and evaluation algorithms; you can even change in runtime parameters of those sub-algorithms </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_e_d_a.html">eoEDA< EOT ></a></td><td class="indexvalue">EoEDA: Estimation of Distribution Algorithm within <a class="el" href="class_e_o.html">EO</a> </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_elite_sequential_select.html">eoEliteSequentialSelect< EOT ></a></td><td class="indexvalue">All Individuals in order </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_elitism.html">eoElitism< EOT ></a></td><td class="indexvalue">Straightforward elitism class, specify the number of individuals to copy into new geneneration or the rate w.r.t </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="class_e_o.html">EO< F ></a></td><td class="indexvalue">EO is a base class for evolvable objects, that is, the subjects of evolution </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_e_p_reduce.html">eoEPReduce< EOT ></a></td><td class="indexvalue">EP truncation method (some global stochastic tournament + sort) Softer selective pressure than pure truncate </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_e_p_replacement.html">eoEPReplacement< EOT ></a></td><td class="indexvalue">EP type of replacement strategy: first add parents to population, then truncate using EP tournament </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_es_chrom_init.html">eoEsChromInit< EOT ></a></td><td class="indexvalue">Random Es-chromosome initializer (therefore derived from <a class="el" href="classeo_init.html">eoInit</a>) </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_es_full.html">eoEsFull< Fit ></a></td><td class="indexvalue">The most complex evolutionary strategy representation </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_es_global_xover.html">eoEsGlobalXover< EOT ></a></td><td class="indexvalue">Gloabl crossover operator for ES genotypes </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_es_mutate.html">eoEsMutate< EOT ></a></td><td class="indexvalue">ES-style mutation in the large </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_es_mutation_init.html">eoEsMutationInit</a></td><td class="indexvalue">Initialize Mutation operator </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_es_simple.html">eoEsSimple< Fit ></a></td><td class="indexvalue">Simple Evolution Strategy </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_es_standard_xover.html">eoEsStandardXover< EOT ></a></td><td class="indexvalue">Standard (i.e </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_es_stdev.html">eoEsStdev< Fit ></a></td><td class="indexvalue">Evolutionary Strategy with a standard deviation per parameter </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_eval_continue.html">eoEvalContinue< EOT ></a></td><td class="indexvalue">Continues until a number of evaluations has been made </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_eval_func.html">eoEvalFunc< EOT ></a></td><td class="indexvalue">Evaluate: takes one <a class="el" href="class_e_o.html">EO</a> and sets its "fitness" property returning this fitness also </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_eval_func_counter.html">eoEvalFuncCounter< EOT ></a></td><td class="indexvalue">Counts the number of evaluations actually performed, thus checks first if it has to evaluate. </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="structeo_eval_func_ptr.html">eoEvalFuncPtr< EOT, FitT, FunctionArg ></a></td><td class="indexvalue">EOEvalFuncPtr: This class takes an existing function pointer and converts it into a evaluation function class </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_expansion_mutation.html">eoExpansionMutation< FType, Node ></a></td><td class="indexvalue">EoExpansionMutation --> replace a terminal with a randomly created subtree </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_external_bin_op.html">eoExternalBinOp< F, External, ExternalEO ></a></td><td class="indexvalue">Crossover of external struct, ctor expects a function of the following signature: </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_external_e_o.html">eoExternalEO< Fit, External ></a></td><td class="indexvalue">Definition of an object that allows an external struct to be inserted in <a class="el" href="class_e_o.html">EO</a> </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_external_eval_func.html">eoExternalEvalFunc< F, External, ExternalEO ></a></td><td class="indexvalue">Evaluation of external struct, ctor expects a function of the following signature: </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_external_init.html">eoExternalInit< F, External, ExternalEO ></a></td><td class="indexvalue">Initialization of external struct, ctor expects a function of the following signature: </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_external_mon_op.html">eoExternalMonOp< F, External, ExternalEO ></a></td><td class="indexvalue">Mutation of external struct, ctor expects a function of the following signature: </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_external_quad_op.html">eoExternalQuadOp< F, External, ExternalEO ></a></td><td class="indexvalue">Crossover of external struct, ctor expects a function of the following signature: </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_f.html">eoF< R ></a></td><td class="indexvalue">Basic Function </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_factory.html">eoFactory< EOClass ></a></td><td class="indexvalue"><a class="el" href="class_e_o.html">EO</a> Factory </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_f_d_c_file_snapshot.html">eoFDCFileSnapshot< EOT ></a></td><td class="indexvalue">Specific class for FDCStat monitoring: As I failed to have FDC stat as an <a class="el" href="classeo_stat.html">eoStat</a>, this is the trick to put the 2 <a class="el" href="classeo_param.html">eoParam</a><std::vector<double> > into a monitor This class does nothing else </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_f_d_c_stat.html">eoFDCStat< EOT ></a></td><td class="indexvalue">The FDC computation - stores the values into eoValueParam<EOT,double> so they can be snapshot by some eoGnuplotSnapshot .. </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_file_monitor.html">eoFileMonitor</a></td><td class="indexvalue">Prints statistics to file </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_file_snapshot.html">eoFileSnapshot</a></td><td class="indexvalue">Prints snapshots of fitnesses to a (new) file every N generations </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_fit_continue.html">eoFitContinue< EOT ></a></td><td class="indexvalue">Fitness continuation: </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_fitness_scaling_select.html">eoFitnessScalingSelect< EOT ></a></td><td class="indexvalue">EoFitnessScalingSelect: select an individual proportional to the linearly scaled fitness that is computed by the private <a class="el" href="classeo_linear_fit_scaling.html">eoLinearFitScaling</a> object </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_fitness_stat.html">eoFitnessStat< EOT, FitT ></a></td><td class="indexvalue">The fitnesses of a whole population, as a vector </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_fl_or1pt_bin_op.html">eoFlOr1ptBinOp< EOT ></a></td><td class="indexvalue">The 1pt crossover (just in case someone wants it some day!) </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_fl_or1pt_quad_op.html">eoFlOr1ptQuadOp< EOT ></a></td><td class="indexvalue">The 1pt crossover (just in case someone wants it some day!) </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_fl_or_all_atom_bin_op.html">eoFlOrAllAtomBinOp< EOT ></a></td><td class="indexvalue">Bin Crossover using an Atom Crossover that is applied to a ALL components with given rate </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_fl_or_all_atom_quad_op.html">eoFlOrAllAtomQuadOp< EOT ></a></td><td class="indexvalue">Quad Crossover using an Atom Crossover </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_fl_or_all_mutation.html">eoFlOrAllMutation< EOT ></a></td><td class="indexvalue">Applies an atomic mutation to all the components with a given rate </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_fl_or_k_atom_bin_op.html">eoFlOrKAtomBinOp< EOT ></a></td><td class="indexvalue">Bin Crossover using an Atom Crossover that is applied to a FIXED NB of components </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_fl_or_k_atom_quad_op.html">eoFlOrKAtomQuadOp< EOT ></a></td><td class="indexvalue">Quad Crossover using an Atom Crossover that is applied to a FIXED NB of components </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_fl_or_k_mutation.html">eoFlOrKMutation< EOT ></a></td><td class="indexvalue">Applies an atomic mutation to a fixed number of components (1 by default) </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_fl_or_uniform_bin_op.html">eoFlOrUniformBinOp< EOT ></a></td><td class="indexvalue">The uniform crossover - exchanges atoms uniformly ! </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_fl_or_uniform_quad_op.html">eoFlOrUniformQuadOp< EOT ></a></td><td class="indexvalue">The uniform crossover - exchanges atoms uniformly ! </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_functor_base.html">eoFunctorBase</a></td><td class="indexvalue">Base class for functors to get a nice hierarchy diagram </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="structeo_functor_base_1_1binary__function__tag.html">eoFunctorBase::binary_function_tag</a></td><td class="indexvalue">Tag to identify a binary function in compile time function selection functor_category </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="structeo_functor_base_1_1procedure__tag.html">eoFunctorBase::procedure_tag</a></td><td class="indexvalue">Tag to identify a procedure in compile time function selection functor_category </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="structeo_functor_base_1_1unary__function__tag.html">eoFunctorBase::unary_function_tag</a></td><td class="indexvalue">Tag to identify a unary function in compile time function selection functor_category </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_functor_store.html">eoFunctorStore</a></td><td class="indexvalue">EoFunctorStore is a class that stores functors that are allocated on the heap </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_g3_replacement.html">eoG3Replacement< EOT ></a></td><td class="indexvalue">EoG3Replacement is an <a class="el" href="classeo_replacement.html">eoReplacement</a>: - no strong elitism (is suppposed to be within a steady-state engine) - choose N (2) parents RANDOMLY - remove them from the parent population - merge offspring and the N removed parents - select best N of this merged population - put them back into parent population </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_gen_continue.html">eoGenContinue< EOT ></a></td><td class="indexvalue">Generational continuator: continues until a number of generations is reached </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_gene_del_chooser.html">eoGeneDelChooser< EOT ></a></td><td class="indexvalue">A helper class for choosing which site to delete </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_general_breeder.html">eoGeneralBreeder< EOT ></a></td><td class="indexvalue">Base class for breeders using generalized operators </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_general_int_bounds.html">eoGeneralIntBounds</a></td><td class="indexvalue">A class that encapsulate all possible <a class="el" href="classeo_int_bounds.html">eoIntBounds</a> </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_general_real_bounds.html">eoGeneralRealBounds</a></td><td class="indexvalue">A class that encapsulate all possible <a class="el" href="classeo_int_bounds.html">eoIntBounds</a> </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_generational_replacement.html">eoGenerationalReplacement< EOT ></a></td><td class="indexvalue">Generational replacement == swap populations </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_gen_op.html">eoGenOp< EOT ></a></td><td class="indexvalue">The base class for General Operators Subclass this operator is you want to define an operator that falls outside of the <a class="el" href="classeo_mon_op.html">eoMonOp</a>, <a class="el" href="classeo_bin_op.html">eoBinOp</a>, <a class="el" href="classeo_quad_op.html">eoQuadOp</a> classification </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_gnuplot.html">eoGnuplot</a></td><td class="indexvalue">Base class for calls to gnuplot </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_gnuplot1_d_monitor.html">eoGnuplot1DMonitor</a></td><td class="indexvalue">Plot <a class="el" href="classeo_stat.html">eoStat</a> </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_gnuplot1_d_snapshot.html">eoGnuplot1DSnapshot</a></td><td class="indexvalue">Plot stats through gnuplot </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_hamming_distance.html">eoHammingDistance< EOT ></a></td><td class="indexvalue">This is a generic class for L1 distance computation: assumes the 2 things are std::vectors of something that is double-castable For bitstrings, this is the Hamming distance </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_hoist_mutation.html">eoHoistMutation< FType, Node ></a></td><td class="indexvalue">EoHoistMutation --> replace the individual with one of its subtree's </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_how_many.html">eoHowMany</a></td><td class="indexvalue">A helper class, to determine a number of individuals from another one Typically, is used in selection / replacement procedures, e.g </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_incrementor.html">eoIncrementor< T ></a></td><td class="indexvalue">EoUpdater that simply increments a counter </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_incrementor_param.html">eoIncrementorParam< T ></a></td><td class="indexvalue">EoUpdater that is an <a class="el" href="classeo_value_param.html">eoValueParam</a> (and thus OWNS its counter) Mandatory for generation counter in make_checkpoint </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_init.html">eoInit< EOT ></a></td><td class="indexvalue">Base (name) class for Initialization of chromosomes, used in a population contructor </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_init_adaptor.html">eoInitAdaptor< EOT ></a></td><td class="indexvalue">EoInitAdaptor changes the place in the hierarchy from <a class="el" href="classeo_init.html">eoInit</a> to <a class="el" href="classeo_mon_op.html">eoMonOp</a> </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_init_fixed_length.html">eoInitFixedLength< EOT ></a></td><td class="indexvalue">Initializer for fixed length representations with a single type </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_init_generator.html">eoInitGenerator< EOT ></a></td><td class="indexvalue">Turning an <a class="el" href="classeo_init.html">eoInit</a> into a generator probably we should only use genrators - and suppress <a class="el" href="classeo_init.html">eoInit</a> ??? MS - July 2001 </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_init_variable_length.html">eoInitVariableLength< EOT ></a></td><td class="indexvalue">Initializer for variable length representations with a single type </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_init_virus.html">eoInitVirus< FitT ></a></td><td class="indexvalue">Initializer for binary chromosome with MGE </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_init_virus1bit.html">eoInitVirus1bit< FitT ></a></td><td class="indexvalue">Inits the virus with one bit to the left set to one </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_inner_exchange_quad_op.html">eoInnerExchangeQuadOp< EOT ></a></td><td class="indexvalue">Crossover using an AtomCrossover </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_int_above_bound.html">eoIntAboveBound</a></td><td class="indexvalue">An eoIntBound bounded from above only </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_int_below_bound.html">eoIntBelowBound</a></td><td class="indexvalue">EoIntBound bounded from below only </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_int_bounds.html">eoIntBounds</a></td><td class="indexvalue">Defines bound classes for real numbers </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_int_interval.html">eoIntInterval</a></td><td class="indexvalue">Fully bounded eoIntBound == interval </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_int_no_bounds.html">eoIntNoBounds</a></td><td class="indexvalue">A default class for unbounded variables </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_invalidate_bin_op.html">eoInvalidateBinOp< EOT ></a></td><td class="indexvalue">One of the invalidator operators </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_invalidate_mon_op.html">eoInvalidateMonOp< EOT ></a></td><td class="indexvalue">One of the invalidator operators </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_invalidate_quad_op.html">eoInvalidateQuadOp< EOT ></a></td><td class="indexvalue">One of the invalidator operators </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_linear_fit_scaling.html">eoLinearFitScaling< EOT ></a></td><td class="indexvalue">An instance of <a class="el" href="classeo_perf2_worth.html">eoPerf2Worth</a> COmputes the linearly scaled fitnesses with given selective pressure Pselect(Best) == pressure/sizePop Pselect(average) == 1.0/sizePop truncate negative values to 0 - </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_linear_random_split.html">eoLinearRandomSplit< EOT ></a></td><td class="indexvalue">Random truncation - linear version </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_linear_truncate.html">eoLinearTruncate< EOT ></a></td><td class="indexvalue">Truncate class that does not sort, but repeatidely kills the worse </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_linear_truncate_split.html">eoLinearTruncateSplit< EOT ></a></td><td class="indexvalue">ReduceSplit class that does not sort, but repeatidely kills the worse </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="class_mem_pool.html">MemPool</a></td><td class="indexvalue">Pool allocator for the subtree and parse tree classes (homebrew and not compliant to ANSI allocator requirements) (c) copyright Maarten Keijzer 1999, 2000 </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classgp__parse__tree_1_1_mem_pool.html">gp_parse_tree::MemPool</a></td><td class="indexvalue">Pool allocator for the subtree and parse tree classes (homebrew and not compliant to ANSI allocator requirements) (c) copyright Maarten Keijzer 1999, 2000 </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_merge.html">eoMerge< Chrom ></a></td><td class="indexvalue">EoMerge: Base class for elitist replacement algorithms </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_merge_reduce.html">eoMergeReduce< EOT ></a></td><td class="indexvalue">EoMergeReduce: abstract replacement strategy that is just an application of an embedded merge, followed by an embedded reduce </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_m_g_g_replacement.html">eoMGGReplacement< EOT ></a></td><td class="indexvalue">EoMGGReplacement is an <a class="el" href="classeo_replacement.html">eoReplacement</a>: - choose N (2) parents RANDOMLY - remove them from the parent population - select best offspring, add to parents - merge (other?) offspring and the N removed parents - select best N-1 of this merged population (detTournament only at the moment) - put them back into parent population </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="class_minimizing_traits.html">MinimizingTraits</a></td><td class="indexvalue">Test program for Pareto Fitness </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_m_o_fitness_stat.html">eoMOFitnessStat< EOT, PartFitT ></a></td><td class="indexvalue">For multi-objective fitness, we need to translate a stat<vector<double> > into a vector<stat>, so each objective gets a seperate stat </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_mon_clone_op.html">eoMonCloneOp< EOT ></a></td><td class="indexvalue">Mon clone: one argument </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_mon_gen_op.html">eoMonGenOp< EOT ></a></td><td class="indexvalue">Wrapper for <a class="el" href="classeo_mon_op.html">eoMonOp</a> </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_monitor.html">eoMonitor</a></td><td class="indexvalue">The abstract monitor class is a std::vector of parameter pointers </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_mon_op.html">eoMonOp< EOType ></a></td><td class="indexvalue">EoMonOp is the monary operator: genetic operator that takes only one <a class="el" href="class_e_o.html">EO</a> </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_n_d_plus_replacement.html">eoNDPlusReplacement< EOT, WorthT ></a></td><td class="indexvalue">An elitist non-dominated sorted replacement scheme </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_n_d_sorting.html">eoNDSorting< EOT ></a></td><td class="indexvalue">Non dominated sorting, it *is a* std::vector of doubles, the integer part is the rank (to which front it belongs), the fractional part the niching penalty or distance penalty or whatever penalty you want to squeeze into the bits </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_n_d_sorting_1_1_dummy_e_o.html">eoNDSorting< EOT >::DummyEO</a></td><td class="indexvalue">Used in fast nondominated sorting <a class="el" href="classeo_n_d_sorting_1_1_dummy_e_o.html">DummyEO</a> is just a storage place for fitnesses and to store the original index </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_n_d_sorting___i.html">eoNDSorting_I< EOT ></a></td><td class="indexvalue">The original Non Dominated Sorting algorithm from Srinivas and Deb </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_n_d_sorting___i_i.html">eoNDSorting_II< EOT ></a></td><td class="indexvalue">Fast Elitist Non-Dominant Sorting Genetic Algorithm </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classnegexp__generator.html">negexp_generator< T ></a></td><td class="indexvalue">The class negexp_generator can be used in the STL generate function to easily generate negative exponential distributed floats and doubles </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_neg_exp_generator.html">eoNegExpGenerator< T ></a></td><td class="indexvalue">The class <a class="el" href="classnegexp__generator.html">negexp_generator</a> can be used in the STL generate function to easily generate negative exponential distributed floats and doubles </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_neg_exp_init.html">eoNegExpInit< T ></a></td><td class="indexvalue">The class <a class="el" href="classnegexp__generator.html">negexp_generator</a> can be used in the STL generate function to easily generate negative exponential distributed floats and doubles </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="class_node_selector.html">NodeSelector</a></td><td class="indexvalue">Base class for selecting nodes </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_no_elitism.html">eoNoElitism< EOT ></a></td><td class="indexvalue">No elite </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_no_perf2_worth.html">eoNoPerf2Worth< EOT ></a></td><td class="indexvalue">A dummy perf2worth, just in case you need it </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classnormal__generator.html">normal_generator< T ></a></td><td class="indexvalue">The class normal_generator can be used in the STL generate function to easily generate gaussian distributed floats and doubles </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_normal_generator.html">eoNormalGenerator< T ></a></td><td class="indexvalue">The class <a class="el" href="classnormal__generator.html">normal_generator</a> can be used in the STL generate function to easily generate gaussian distributed floats and doubles </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_normal_init.html">eoNormalInit< T ></a></td><td class="indexvalue">The class <a class="el" href="classnormal__generator.html">normal_generator</a> can be used in the STL generate function to easily generate gaussian distributed floats and doubles </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_normal_mutation.html">eoNormalMutation< EOT ></a></td><td class="indexvalue">Simple normal mutation of a std::vector of real values </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_normal_vec_mutation.html">eoNormalVecMutation< EOT ></a></td><td class="indexvalue">Simple normal mutation of a std::vector of real values </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_no_select.html">eoNoSelect< EOT ></a></td><td class="indexvalue">EoNoSelect: returns all individual in order WITHOUT USING FITNESS!!! looping back to the beginning when exhasuted </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_n_pts_bit_xover.html">eoNPtsBitXover< Chrom ></a></td><td class="indexvalue">EoNPtsBitXover --> n-point crossover </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_nth_element_fitness_stat.html">eoNthElementFitnessStat< EOT ></a></td><td class="indexvalue">The n_th element fitness in the population (see <a class="el" href="classeo_best_fitness_stat.html">eoBestFitnessStat</a>) </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_object.html">eoObject</a></td><td class="indexvalue">EoObject used to be the base class for the whole hierarchy, but this has changed </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_one_fifth_mutation.html">eoOneFifthMutation< EOT ></a></td><td class="indexvalue">Dynamic version: just say it is updatable - and write the <a class="el" href="classeo_one_fifth_mutation.html#a3">update()</a> method! here the 1 fifth rule: count the proportion of successful mutations, and increase sigma if more than threshold (1/5 !) </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_one_max.html">eoOneMax< FitT ></a></td><td class="indexvalue">Always write a comment in this format before class definition if you want the class to be documented by Doxygen </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_one_max_eval_func.html">eoOneMaxEvalFunc< EOT ></a></td><td class="indexvalue">Always write a comment in this format before class definition if you want the class to be documented by Doxygen </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_one_max_init.html">eoOneMaxInit< GenotypeT ></a></td><td class="indexvalue">Always write a comment in this format before class definition if you want the class to be documented by Doxygen </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_one_max_mutation.html">eoOneMaxMutation< GenotypeT ></a></td><td class="indexvalue">Always write a comment in this format before class definition if you want the class to be documented by Doxygen </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_one_max_quad_crossover.html">eoOneMaxQuadCrossover< GenotypeT ></a></td><td class="indexvalue">Always write a comment in this format before class definition if you want the class to be documented by Doxygen </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_op.html">eoOp< EOType ></a></td><td class="indexvalue">Abstract data types for <a class="el" href="class_e_o.html">EO</a> operators </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_op_container.html">eoOpContainer< EOT ></a></td><td class="indexvalue">EoOpContainer is a base class for the sequential and proportional selectors It takes care of wrapping the other operators, and deleting stuff that it has allocated </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_op_sel_mason.html">eoOpSelMason< eoClass ></a></td><td class="indexvalue"><a class="el" href="class_e_o.html">EO</a> Mason, or builder, for operator selectors </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_param.html">eoParam</a></td><td class="indexvalue">EoParam: Base class for monitoring and parsing parameters </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_parameter_loader.html">eoParameterLoader</a></td><td class="indexvalue">Parameter saving and loading </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_param_param_type.html">eoParamParamType</a></td><td class="indexvalue">Another helper class for parsing parameters like Keyword(arg1, arg2, ...) </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_pareto_fitness.html">eoParetoFitness< FitnessTraits ></a></td><td class="indexvalue">EoParetoFitness class: std::vector of doubles with overloaded comparison operators </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_pareto_fitness_traits.html">eoParetoFitnessTraits</a></td><td class="indexvalue">EoFitnessTraits: a traits class to specify the number of objectives and which one are maximizing or not See test/t-eoParetoFitness for its use </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_pareto_one_constraint_fitness.html">eoParetoOneConstraintFitness< FitnessTraits ></a></td><td class="indexvalue">EoParetoOneConstraintFitness class: std::vector of doubles + constraint value </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_pareto_ranking.html">eoParetoRanking< EOT ></a></td><td class="indexvalue">Straightforward pareto ranking </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_parser.html">eoParser</a></td><td class="indexvalue">EoParser: command line parser and configuration file reader This class is persistent, so it can be stored and reloaded to restore parameter settings </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_parse_tree.html">eoParseTree< FType, Node ></a></td><td class="indexvalue">Implementation of parse-tree for genetic programming </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_parse_tree_depth_init.html">eoParseTreeDepthInit< FType, Node ></a></td><td class="indexvalue">EoParseTreeDepthInit : the initializer class for <a class="el" href="classeo_parse_tree.html">eoParseTree</a> </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_p_b_i_l_additive.html">eoPBILAdditive< EOT ></a></td><td class="indexvalue">Distribution Class for PBIL algorithm (Population-Based Incremental Learning, Baluja and Caruana 96) </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_p_b_i_l_distrib.html">eoPBILDistrib< EOT ></a></td><td class="indexvalue">Distribution Class for PBIL algorithm (Population-Based Incremental Learning, Baluja and Caruana 96) </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_p_b_i_l_org.html">eoPBILOrg< EOT ></a></td><td class="indexvalue">Distribution Class for PBIL algorithm (Population-Based Incremental Learning, Baluja and Caruana 95) </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_perf2_worth.html">eoPerf2Worth< EOT, WorthT ></a></td><td class="indexvalue">Base class to transform raw fitnesses into fitness for selection </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_perf2_worth_1_1compare__worth.html">eoPerf2Worth< EOT, WorthT >::compare_worth</a></td><td class="indexvalue">Helper class used to sort indices into populations/worths </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_perf2_worth_cached.html">eoPerf2WorthCached< EOT, WorthT ></a></td><td class="indexvalue">Perf2Worth with fitness cache </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_perf2_worth_cached_1_1compare__worth.html">eoPerf2WorthCached< EOT, WorthT >::compare_worth</a></td><td class="indexvalue">Helper class used to sort indices into populations/worths </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_persistent.html">eoPersistent</a></td><td class="indexvalue">An persistent object that knows how to write (through functions inherited from <a class="el" href="classeo_printable.html">eoPrintable</a>#) and read itself </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_plus.html">eoPlus< EOT ></a></td><td class="indexvalue">Very elitist class, copies entire population into next gen </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_plus_replacement.html">eoPlusReplacement< EOT ></a></td><td class="indexvalue">ES type of replacement strategy: first add parents to population, then truncate </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_point_mutation.html">eoPointMutation< FType, Node ></a></td><td class="indexvalue">EoPointMutation --> replace a Node with a Node of the same arity </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_pop.html">eoPop< EOT ></a></td><td class="indexvalue">A std::vector of <a class="el" href="class_e_o.html">EO</a> object, to be used in all algorithms (selectors, operators, replacements, ...) </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="structeo_pop_1_1_cmp.html">eoPop< EOT >::Cmp</a></td><td class="indexvalue">Helper struct for comparing on pointers </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="structeo_pop_1_1_ref.html">eoPop< EOT >::Ref</a></td><td class="indexvalue">Helper struct for getting a pointer </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_pop_algo.html">eoPopAlgo< EOT ></a></td><td class="indexvalue">For all "population transforming" algos .. </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_pop_eval_func.html">eoPopEvalFunc< EOT ></a></td><td class="indexvalue">EoPopEvalFunc: This abstract class is for GLOBAL evaluators of a population after variation </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_pop_loop_eval.html">eoPopLoopEval< EOT ></a></td><td class="indexvalue">EoPopLoopEval: an instance of <a class="el" href="classeo_pop_eval_func.html">eoPopEvalFunc</a> that simply applies a private <a class="el" href="classeo_eval_func.html">eoEvalFunc</a> to all offspring </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_pop_stat.html">eoPopStat< EOT ></a></td><td class="indexvalue">Thanks to MS/VC++, <a class="el" href="classeo_param.html">eoParam</a> mechanism is unable to handle std::vectors of stats </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_populator.html">eoPopulator< EOT ></a></td><td class="indexvalue">EoPopulator is a helper class for general operators <a class="el" href="classeo_gen_op.html">eoGenOp</a> It is an <a class="el" href="classeo_pop.html">eoPop</a> but also behaves like an eoPop::iterator as far as operator* and operator++ are concerned </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_printable.html">eoPrintable</a></td><td class="indexvalue">Base class for objects that can print themselves (<a class="el" href="classeo_printable.html#a1">printOn</a>#) </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_procedure_counter.html">eoProcedureCounter< Procedure ></a></td><td class="indexvalue">Generic counter class that counts the number of times a procedure is used </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_prop_combined_bin_op.html">eoPropCombinedBinOp< EOT ></a></td><td class="indexvalue">COmbined Binary genetic operator: operator() has two operands, only the first one can be modified </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_prop_combined_mon_op.html">eoPropCombinedMonOp< EOT ></a></td><td class="indexvalue">EoMonOp is the monary operator: genetic operator that takes only one <a class="el" href="class_e_o.html">EO</a> </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_prop_combined_quad_op.html">eoPropCombinedQuadOp< EOT ></a></td><td class="indexvalue">Combined quad genetic operator: operator() has two operands, both can be modified </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_prop_g_a_gen_op.html">eoPropGAGenOp< EOT ></a></td><td class="indexvalue">*************************************************************************** eoPropGAGenOp (for Simple GA, but Proportional) choice between Crossover, mutation or cloining with respect to given relatve weights </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_proportional_op.html">eoProportionalOp< EOT ></a></td><td class="indexvalue">The proportional versions: easy! </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_proportional_select.html">eoProportionalSelect< EOT ></a></td><td class="indexvalue">EoProportionalSelect: select an individual proportional to her stored fitness value </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_quad2_bin_op.html">eoQuad2BinOp< EOT ></a></td><td class="indexvalue">Turning an <a class="el" href="classeo_quad_op.html">eoQuadOp</a> into an <a class="el" href="classeo_bin_op.html">eoBinOp</a>: simply don't touch the second arg! </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_quad_clone_op.html">eoQuadCloneOp< EOT ></a></td><td class="indexvalue">Quad clone: two operands, both could be modified - but are not! </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_quad_distance.html">eoQuadDistance< EOT ></a></td><td class="indexvalue">This is a generic class for Euclidain distance (L2 norm) computation: assumes the 2 things are std::vectors of something that is double-castable </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_quad_gen_op.html">eoQuadGenOp< EOT ></a></td><td class="indexvalue">Wrapper for quadop: easy as pie </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_quad_op.html">eoQuadOp< EOType ></a></td><td class="indexvalue">Quad genetic operator: subclasses <a class="el" href="classeo_op.html">eoOp</a>, and defines basically the operator() with two operands, both can be modified </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classrandom__generator.html">random_generator< T ></a></td><td class="indexvalue">The class random_generator can be used in the STL generate function to easily generate random ints either between [0, _max) if only one value (_max) is given to the ctor or in [_min,_max) if 2 values are given (_min, _max) </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="class_random_node_selector.html">RandomNodeSelector</a></td><td class="indexvalue">Select nodes uniformly </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_random_reduce.html">eoRandomReduce< EOT ></a></td><td class="indexvalue">Random truncation </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_random_select.html">eoRandomSelect< EOT ></a></td><td class="indexvalue">EoRandomSelect: a selection method that selects ONE individual randomly </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_random_split.html">eoRandomSplit< EOT ></a></td><td class="indexvalue">Random truncation - batch version </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_ranking.html">eoRanking< EOT ></a></td><td class="indexvalue">An instance of eoPerfFromWorth COmputes the ranked fitness: fitnesses range in [m,M] with m=2-pressure/popSize and M=pressure/popSize </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_ranking_select.html">eoRankingSelect< EOT ></a></td><td class="indexvalue">EoRankingSelect: select an individual by roulette wheel on its rank is an <a class="el" href="classeo_roulette_worth_select.html">eoRouletteWorthSelect</a>, i.e </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_real.html">eoReal< FitT ></a></td><td class="indexvalue">EoReal: implementation of simple real-valued chromosome </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_real_above_bound.html">eoRealAboveBound</a></td><td class="indexvalue">An eoRealBound bounded from above only </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_real_base_vector_bounds.html">eoRealBaseVectorBounds</a></td><td class="indexvalue">Vector type for bounds (see <a class="el" href="eo_real_bounds_8h.html">eoRealBounds.h</a> for scalar types) ------------ Class <a class="el" href="classeo_real_vector_bounds.html">eoRealVectorBounds</a> implements the std::vectorized version: it is basically a std::vector of <a class="el" href="classeo_real_bounds.html">eoRealBounds</a> * and forwards all request to the elements of the std::vector </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_real_below_bound.html">eoRealBelowBound</a></td><td class="indexvalue">EoRealBound bounded from below only </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_real_bounds.html">eoRealBounds</a></td><td class="indexvalue">Defines bound classes for real numbers </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_real_init_bounded.html">eoRealInitBounded< EOT ></a></td><td class="indexvalue">Simple initialization for any EOT that derives from std::vector<double> uniformly in some bounds </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_real_interval.html">eoRealInterval</a></td><td class="indexvalue">Fully bounded eoRealBound == interval </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_real_no_bounds.html">eoRealNoBounds</a></td><td class="indexvalue">A default class for unbounded variables </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_real_ux_over.html">eoRealUxOver</a></td><td class="indexvalue">EoRealUxOver --> Uniform crossover, also termed intermediate crossover </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_real_vector_bounds.html">eoRealVectorBounds</a></td><td class="indexvalue">Now a derived class, for parser reading It holds some of the bounds (and destroy them when dying) </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_real_vector_no_bounds.html">eoRealVectorNoBounds</a></td><td class="indexvalue"><a class="el" href="struct_dummy.html">Dummy</a> unbounded <a class="el" href="classeo_real_vector_bounds.html">eoRealVectorBounds</a>: usefull if you don't need bounds! everything is inlined </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_reduce.html">eoReduce< EOT ></a></td><td class="indexvalue">EoReduce: .reduce the new generation to the specified size At the moment, limited to truncation - with 2 different methods, one that sorts the whole population, and one that repeatidely kills the worst </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_reduce_merge.html">eoReduceMerge< EOT ></a></td><td class="indexvalue">EoReduceMerge: Replacement strategies that start by reducing the parents, then merge with the offspring </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_reduce_merge_reduce.html">eoReduceMergeReduce< EOT ></a></td><td class="indexvalue">EoReduceMergeReduce is an <a class="el" href="classeo_replacement.html">eoReplacement</a>: - saves possible elite parents - reduces rest of parents - reduces offspring - merges reduced populations - reduces resulting merged pop if necessary </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_reduce_split.html">eoReduceSplit< EOT ></a></td><td class="indexvalue">EoReduceSplit: reduce the pop to the specified size AND eventually returns the eliminated guys </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_replacement.html">eoReplacement< EOT ></a></td><td class="indexvalue"></td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_rnd_generator.html">eoRndGenerator< T ></a></td><td class="indexvalue">By popular demand re-introducing a base class for a family of random number generators </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_rng.html">eoRng</a></td><td class="indexvalue">Random Number Generator </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_roulette_worth_select.html">eoRouletteWorthSelect< EOT, WorthT ></a></td><td class="indexvalue">An instance of eoSelectPerf2Worth that does selection from the Worthes using a .. </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_scalar_fitness.html">eoScalarFitness< ScalarType, Compare ></a></td><td class="indexvalue">EoScalarFitness<ScalarType, Compare = less<ScalarType> >: Wraps a scalar fitness values such as a double or int, with the option of maximizing (using less<ScalarType>) or minimizing (using greater<ScalarType>) </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_scalar_fitness_assembled.html">eoScalarFitnessAssembled< ScalarType, Compare, FitnessTraits ></a></td><td class="indexvalue">Implements fitness as std::vector, storing all values that might occur during fitness assembly </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_scalar_fitness_assembled_traits.html">eoScalarFitnessAssembledTraits</a></td><td class="indexvalue">Defines properties of <a class="el" href="classeo_scalar_fitness_assembled.html">eoScalarFitnessAssembled</a> </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_scalar_fitness_stat.html">eoScalarFitnessStat< EOT, FitT ></a></td><td class="indexvalue">The fitnesses of a whole population, as a std::vector </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_second_moment_stats.html">eoSecondMomentStats< EOT ></a></td><td class="indexvalue">Average fitness + Std </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_segment_crossover.html">eoSegmentCrossover< EOT ></a></td><td class="indexvalue">EoSegmentCrossover --> uniform choice in segment == arithmetical with same value along all coordinates </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_sel_bin_gen_op.html">eoSelBinGenOp< EOT ></a></td><td class="indexvalue">Wrapper for <a class="el" href="classeo_bin_op.html">eoBinOp</a> with a selector </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_select.html">eoSelect< EOT ></a></td><td class="indexvalue">EoSelect selects a number of individuals from the first argument and puts it in the second </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_select_factory.html">eoSelectFactory< EOT ></a></td><td class="indexvalue"><a class="el" href="class_e_o.html">EO</a> Factory.An instance of the factory class to create selectors, that is, <a class="el" href="classeo_select.html">eoSelect</a> objects </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_select_from_worth.html">eoSelectFromWorth< EOT, WorthType ></a></td><td class="indexvalue">Selects one element from a population (is an <a class="el" href="classeo_select_one.html">eoSelectOne</a>) but the selection is based on a std::vector of Worth that is different from the fitnesses (e.g </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_selective_populator.html">eoSelectivePopulator< EOT ></a></td><td class="indexvalue">SelectivePopulator an eoPoplator that uses an <a class="el" href="classeo_select_one.html">eoSelectOne</a> to select guys </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_select_many.html">eoSelectMany< EOT ></a></td><td class="indexvalue">EoSelectMany selects many individuals using <a class="el" href="classeo_select_one.html">eoSelectOne</a> as it's mechanism </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_select_number.html">eoSelectNumber< EOT ></a></td><td class="indexvalue">EoSelectNumber selects many individuals using <a class="el" href="classeo_select_one.html">eoSelectOne</a> as it's mechanism </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_select_one.html">eoSelectOne< EOT, WorthT ></a></td><td class="indexvalue">EoSelectOne selects only one element from a whole population </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_select_perc.html">eoSelectPerc< EOT ></a></td><td class="indexvalue">EoSelectPerc selects many individuals using <a class="el" href="classeo_select_one.html">eoSelectOne</a> as it's mechanism </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_select_transform.html">eoSelectTransform< EOT ></a></td><td class="indexvalue">Embedded select, followed by an embedded transform </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_seq_populator.html">eoSeqPopulator< EOT ></a></td><td class="indexvalue">SeqPopulator: an <a class="el" href="classeo_populator.html">eoPopulator</a> that sequentially goes through the population is supposed to be used after a batch select of a whole bunch or genitors </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_sequential_op.html">eoSequentialOp< EOT ></a></td><td class="indexvalue">Sequential selection: note the mark, rewind, unmark cycle here operators are repeatedly applied on the same individual(s) not all too elegant, but it sort of works.. </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_sequential_select.html">eoSequentialSelect< EOT ></a></td><td class="indexvalue">All Individuals in order </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_s_g_a.html">eoSGA< EOT ></a></td><td class="indexvalue">The Simple Genetic Algorithm, following Holland and Goldberg </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_s_g_a_gen_op.html">eoSGAGenOp< EOT ></a></td><td class="indexvalue">*************************************************************************** eoSGAGenOp (for Simple GA) mimicks the usual crossover with proba pCross + mutation with proba pMut inside an eoGeneralOp It does it exactly as class <a class="el" href="classeo_s_g_a_transform.html">eoSGATransform</a>, i.e </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_s_g_a_transform.html">eoSGATransform< EOT ></a></td><td class="indexvalue">EoSGATransform: transforms a population using genetic operators </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_sharing.html">eoSharing< EOT ></a></td><td class="indexvalue">Sharing is a perf2worth class that implements Goldberg and Richardson's basic sharing see <a class="el" href="classeo_sharing_select.html">eoSharingSelect</a> for how to use it and test/t-eoSharing.cpp for a sample use of both </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_sharing_select.html">eoSharingSelect< EOT ></a></td><td class="indexvalue">EoSharingSelect: select an individual by roulette wheel on its SHARED fitness </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_simple_e_d_a.html">eoSimpleEDA< EOT ></a></td><td class="indexvalue">EoSimpleEDA: a very simple Estimation of Distribution Algorithm </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_sorted_pop_stat.html">eoSortedPopStat< EOT ></a></td><td class="indexvalue">Thanks to MS/VC++, <a class="el" href="classeo_param.html">eoParam</a> mechanism is unable to handle std::vectors of stats </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_sorted_stat.html">eoSortedStat< EOT, ParamType ></a></td><td class="indexvalue">The actual class that will be used as base for all statistics that need to be calculated over the sorted population It's an <a class="el" href="classeo_sorted_stat_base.html">eoSortedStatBase</a> AND an <a class="el" href="classeo_value_param.html">eoValueParam</a> so it can be used in Monitors </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_sorted_stat_base.html">eoSortedStatBase< EOT ></a></td><td class="indexvalue">Base class for statistics calculated over a sorted snapshot of the population </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_s_s_g_a_det_tournament_replacement.html">eoSSGADetTournamentReplacement< EOT ></a></td><td class="indexvalue">SSGA deterministic tournament replacement </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_s_s_g_a_stoch_tournament_replacement.html">eoSSGAStochTournamentReplacement< EOT ></a></td><td class="indexvalue">SSGA stochastic tournament replacement </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_s_s_g_a_worse_replacement.html">eoSSGAWorseReplacement< EOT ></a></td><td class="indexvalue">SSGA replace worst </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_stat.html">eoStat< EOT, T ></a></td><td class="indexvalue">The actual class that will be used as base for all statistics that need to be calculated over the (unsorted) population It is an <a class="el" href="classeo_stat_base.html">eoStatBase</a> AND an <a class="el" href="classeo_value_param.html">eoValueParam</a> so it can be used in Monitors </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_stat_base.html">eoStatBase< EOT ></a></td><td class="indexvalue">Base class for all statistics that need to be calculated over the (unsorted) population (I guess it is not really necessary? MS </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_state.html">eoState</a></td><td class="indexvalue">EoState can be used to register derivants of <a class="el" href="classeo_persistent.html">eoPersistent</a> </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="structeo_state_1_1loading__error.html">eoState::loading_error</a></td><td class="indexvalue">Loading error thrown when nothing seems to work </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_st_branch_mutation.html">eoStBranchMutation< FType, Node ></a></td><td class="indexvalue">EoStBranchMutation --> replace a strongly typed subtree with a randomly created strongly typed subtree </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_stdout_monitor.html">eoStdoutMonitor</a></td><td class="indexvalue">Prints statistics to stdout </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_steady_fit_continue.html">eoSteadyFitContinue< EOT ></a></td><td class="indexvalue">A continuator: does a minimum number of generations, then stops whenever a given number of generations takes place without improvement </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_st_hoist_mutation.html">eoStHoistMutation< FType, Node ></a></td><td class="indexvalue">EoStHoistMutation --> replace the individual with one of its strongly typed subtree's </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_s_t_l_b_f.html">eoSTLBF< A1, A2, R ></a></td><td class="indexvalue">Generic set of classes that wrap an <a class="el" href="classeo_f.html">eoF</a>, <a class="el" href="classeo_u_f.html">eoUF</a> or <a class="el" href="classeo_b_f.html">eoBF</a> so that they have the copy semantics the STL functions usually require (i.e </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_s_t_l_f.html">eoSTLF< R ></a></td><td class="indexvalue">Generic set of classes that wrap an <a class="el" href="classeo_f.html">eoF</a>, <a class="el" href="classeo_u_f.html">eoUF</a> or <a class="el" href="classeo_b_f.html">eoBF</a> so that they have the copy semantics the STL functions usually require (i.e </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_s_t_l_u_f.html">eoSTLUF< A1, R ></a></td><td class="indexvalue">Generic set of classes that wrap an <a class="el" href="classeo_f.html">eoF</a>, <a class="el" href="classeo_u_f.html">eoUF</a> or <a class="el" href="classeo_b_f.html">eoBF</a> so that they have the copy semantics the STL functions usually require (i.e </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_stochastic_universal_select.html">eoStochasticUniversalSelect< EOT ></a></td><td class="indexvalue">EoStochasticUniversalSelect: select an individual proportional to her stored fitness value, but in contrast with eoStochasticUniversalSelect, get rid of most finite sampling effects by doing all selections in one go, using a single random number </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_stoch_tournament_select.html">eoStochTournamentSelect< EOT ></a></td><td class="indexvalue">EoStochTournamentSelect: a selection method that selects ONE individual by binary stochastic tournament -MS- 24/10/99 </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_stoch_tournament_truncate.html">eoStochTournamentTruncate< EOT ></a></td><td class="indexvalue">Truncate class based on a repeated deterministic (reverse!) tournament To be used in SSGA-like replacements (e.g </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_stoch_tournament_truncate_split.html">eoStochTournamentTruncateSplit< EOT ></a></td><td class="indexvalue">ReduceSplit class based on a repeated deterministic (reverse!) tournament To be used in SSGA-like replacements (e.g </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_stoch_tournament_worth_select.html">eoStochTournamentWorthSelect< EOT, WorthT ></a></td><td class="indexvalue">An instance of eoSelectPerf2Worth that does selection from the Worthes using a .. </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_st_parse_tree_depth_init.html">eoStParseTreeDepthInit< FType, Node ></a></td><td class="indexvalue">EoStParseTreeDepthInit : the initializer class for strongly typed tree-based genetic programming </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_st_point_mutation.html">eoStPointMutation< FType, Node ></a></td><td class="indexvalue">EoStPointMutation --> replace a Node with a Node of the same arity and type </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_string.html">eoString< fitnessT ></a></td><td class="indexvalue">Adaptor that turns an STL std::string into an <a class="el" href="class_e_o.html">EO</a> </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_st_subtree_x_over.html">eoStSubtreeXOver< FType, Node ></a></td><td class="indexvalue">EoStSubtreeXOver --> subtree xover for strongly typed tree-based genetic programming </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_subtree_x_over.html">eoSubtreeXOver< FType, Node ></a></td><td class="indexvalue">EoSubtreeXOver --> subtree xover </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_survive_and_die.html">eoSurviveAndDie< EOT ></a></td><td class="indexvalue">EoSurviveAndDie A pure abstract class, to store the howmany's </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_sym_init.html">eoSymInit< EoType ></a></td><td class="indexvalue">Default initializer, Koza style </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="struct_t__pickle__suite.html">T_pickle_suite< T ></a></td><td class="indexvalue">Implements pickle support for <a class="el" href="classeo_persistent.html">eoPersistent</a> derivatives </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_time_counter.html">eoTimeCounter</a></td><td class="indexvalue">An <a class="el" href="classeo_stat.html">eoStat</a> that simply gives the user time since first generation It has to be tempatized by EOT because it must be an <a class="el" href="classeo_stat.html">eoStat</a> </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_timed_dyn_update.html">eoTimedDynUpdate</a></td><td class="indexvalue">An <a class="el" href="classeo_updater.html">eoUpdater</a> to update an <a class="el" href="classeo_updatable.html">eoUpdatable</a> object every given time interval </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_timed_monitor.html">eoTimedMonitor</a></td><td class="indexvalue">Holds a collection of monitors and only fires them when a time limit has been reached </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_timed_state_saver.html">eoTimedStateSaver</a></td><td class="indexvalue">EoUpdater that saves a state every given time interval </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_time_varying_loop_eval.html">eoTimeVaryingLoopEval< EOT ></a></td><td class="indexvalue">EoPopLoopEval: an instance of <a class="el" href="classeo_pop_eval_func.html">eoPopEvalFunc</a> that simply applies a private <a class="el" href="classeo_eval_func.html">eoEvalFunc</a> to all offspring AND ALL PARENTS as the fitness is supposed here to vary </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_transform.html">eoTransform< EOT ></a></td><td class="indexvalue">EoTransform transforms a population by applying genetic operators on it </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_truncate.html">eoTruncate< EOT ></a></td><td class="indexvalue">Truncation method using sort </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_truncated_select_many.html">eoTruncatedSelectMany< EOT ></a></td><td class="indexvalue">EoTruncatedSelectMany selects many individuals using <a class="el" href="classeo_select_one.html">eoSelectOne</a> as it's mechanism </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_truncated_select_one.html">eoTruncatedSelectOne< EOT ></a></td><td class="indexvalue">EoTruncatedSelectOne selects one individual using <a class="el" href="classeo_select_one.html">eoSelectOne</a> as it's mechanism </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_truncate_split.html">eoTruncateSplit< EOT ></a></td><td class="indexvalue">Deterministic truncation method using sort </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_trunc_select.html">eoTruncSelect< EOT ></a></td><td class="indexvalue">EoTruncSelect selects individuals after truncating the population using <a class="el" href="classeo_select_one.html">eoSelectOne</a> as it's mechanism </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_u_bit_xover.html">eoUBitXover< Chrom ></a></td><td class="indexvalue">EoUBitXover --> classic Uniform crossover </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_u_f.html">eoUF< A1, R ></a></td><td class="indexvalue">Basic Unary Functor </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="class_u_f__random__generator.html">UF_random_generator< T ></a></td><td class="indexvalue">Another class <a class="el" href="classrandom__generator.html">random_generator</a> that can be used in the STL random_shuffle function (see <a class="el" href="classeo_pop.html#a7">eoPop::shuffle</a>): its operator() takes an unsigned argument m and must return an unsigned uniformly distributed in [0,m} </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_unary_functor_counter.html">eoUnaryFunctorCounter< UnaryFunctor ></a></td><td class="indexvalue">Generic counter class that counts the number of times a unary function is used </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classuniform__generator.html">uniform_generator< T ></a></td><td class="indexvalue">The class uniform_generator can be used in the STL generate function to easily generate random floats and doubles either in [0, _max) if only 1 value (_max) is given (or none, as _max defaults to 1.0) or in [_min,_max) if 2 values are given (_min, _max) </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_uniform_atom_exchange.html">eoUniformAtomExchange< Atom ></a></td><td class="indexvalue">Uniform crossover - well, not really, efficient for FixedLength </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_uniform_gene_chooser.html">eoUniformGeneChooser< EOT ></a></td><td class="indexvalue">Uniform choice of gene to delete </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_uniform_generator.html">eoUniformGenerator< T ></a></td><td class="indexvalue">The class eoUniform can be used in the STL generate function to easily generate random floats and doubles </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_uniform_init.html">eoUniformInit< T ></a></td><td class="indexvalue">The class eoUniformInit can be used in the STL apply function to easily randomize floats and doubles </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_uniform_mutation.html">eoUniformMutation< EOT ></a></td><td class="indexvalue">EoUniformMutation --> changes all values of the std::vector by uniform choice with range epsilon with probability p_change per variable </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_updatable.html">eoUpdatable</a></td><td class="indexvalue">EoUpdatable is a generic class for adding updatation to an existing class Just says it has an update() method </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_updater.html">eoUpdater</a></td><td class="indexvalue">EoUpdater is a generic procudere for updating whatever you want </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_value_param.html">eoValueParam< ValueType ></a></td><td class="indexvalue">EoValueParam<ValueType>: templatized derivation of <a class="el" href="classeo_param.html">eoParam</a> </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_variable_pareto_traits.html">eoVariableParetoTraits</a></td><td class="indexvalue">EoVariableParetoTraits : an <a class="el" href="classeo_pareto_fitness_traits.html">eoParetoFitnessTraits</a> whose characteristics can be set at run-time (nb objectives and min/max's) Why bother? For didactical purposes (and EASEA implementation :-) </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_vector.html">eoVector< FitT, GeneType ></a></td><td class="indexvalue">Base class for fixed length chromosomes, just derives from <a class="el" href="class_e_o.html">EO</a> and std::vector and redirects the smaller than operator to EO (fitness based comparison) </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="class_virus_bit_flip.html">VirusBitFlip< FitT ></a></td><td class="indexvalue">VirusBitFlip --> changes 1 bit </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="class_virus_shift_mutation.html">VirusShiftMutation< FitT ></a></td><td class="indexvalue">Works for 1-bit virus; shifts the one to the right or left </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_vl_add_mutation.html">eoVlAddMutation< EOT ></a></td><td class="indexvalue">Addition of a gene Is inserted at a random position - so can be applied to both order-dependent and order-independent </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_vl_atom_exchange_quad_op.html">eoVlAtomExchangeQuadOp< EOT ></a></td><td class="indexvalue">Exchange Crossover using an AtomExchange </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_vl_del_mutation.html">eoVlDelMutation< EOT ></a></td><td class="indexvalue">Deletion of a gene By default at a random position, but a "chooser" can be specified can of course be applied to both order-dependent and order-independent </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_vl_uniform_bin_op.html">eoVlUniformBinOp< EOT ></a></td><td class="indexvalue">Direct Uniform Exchange of genes for Variable Length, BINARY version </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_vl_uniform_quad_op.html">eoVlUniformQuadOp< EOT ></a></td><td class="indexvalue">Direct Uniform Exchange of genes (obsolete, already :-) stays there for historical reasons </td></tr>
|
||||
<tr><td class="indexkey"><a class="el" href="classeo_weak_elitist_replacement.html">eoWeakElitistReplacement< EOT ></a></td><td class="indexvalue">EoWeakElitistReplacement: a wrapper for other replacement procedures </td></tr>
|
||||
</table>
|
||||
<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>
|
||||
56
trunk/paradiseo-eo/doc/html/apply_8h-source.html
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
<!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: apply.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>apply.h</h1><div class="fragment"><pre class="fragment">00001 <span class="comment">// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-</span>
|
||||
00002
|
||||
00003 <span class="comment">//-----------------------------------------------------------------------------</span>
|
||||
00004 <span class="comment">// eoApply.h</span>
|
||||
00005 <span class="comment">// (c) Maarten Keijzer 2000</span>
|
||||
00006 <span class="comment">/* </span>
|
||||
00007 <span class="comment"> This library is free software; you can redistribute it and/or</span>
|
||||
00008 <span class="comment"> modify it under the terms of the GNU Lesser General Public</span>
|
||||
00009 <span class="comment"> License as published by the Free Software Foundation; either</span>
|
||||
00010 <span class="comment"> version 2 of the License, or (at your option) any later version.</span>
|
||||
00011 <span class="comment"></span>
|
||||
00012 <span class="comment"> This library is distributed in the hope that it will be useful,</span>
|
||||
00013 <span class="comment"> but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
|
||||
00014 <span class="comment"> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</span>
|
||||
00015 <span class="comment"> Lesser General Public License for more details.</span>
|
||||
00016 <span class="comment"></span>
|
||||
00017 <span class="comment"> You should have received a copy of the GNU Lesser General Public</span>
|
||||
00018 <span class="comment"> License along with this library; if not, write to the Free Software</span>
|
||||
00019 <span class="comment"> Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>
|
||||
00020 <span class="comment"></span>
|
||||
00021 <span class="comment"> Contact: todos@geneura.ugr.es, http://geneura.ugr.es</span>
|
||||
00022 <span class="comment"> mak@dhi.dk</span>
|
||||
00023 <span class="comment"> */</span>
|
||||
00024 <span class="comment">//-----------------------------------------------------------------------------</span>
|
||||
00025
|
||||
00026 <span class="preprocessor">#ifndef _apply_h</span>
|
||||
00027 <span class="preprocessor"></span><span class="preprocessor">#define _apply_h</span>
|
||||
00028 <span class="preprocessor"></span>
|
||||
00029 <span class="preprocessor">#include <eoFunctor.h></span>
|
||||
00030 <span class="preprocessor">#include <vector></span>
|
||||
00031
|
||||
00035 <span class="keyword">template</span> <<span class="keyword">class</span> EOT>
|
||||
00036 <span class="keywordtype">void</span> apply(<a class="code" href="classeo_u_f.html">eoUF<EOT&, void></a>& _proc, std::vector<EOT>& _pop)
|
||||
00037 {
|
||||
00038 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < _pop.size(); ++i)
|
||||
00039 {
|
||||
00040 _proc(_pop[i]);
|
||||
00041 }
|
||||
00042 }
|
||||
00043
|
||||
00044 <span class="preprocessor">#endif</span>
|
||||
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:34 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>
|
||||
66
trunk/paradiseo-eo/doc/html/breeders_8cpp-source.html
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
<!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: breeders.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_000000.html">src</a> / <a class="el" href="dir_000001.html">pyeo</a></div>
|
||||
<h1>breeders.cpp</h1><div class="fragment"><pre class="fragment">00001 <span class="comment">/*</span>
|
||||
00002 <span class="comment"> PyEO</span>
|
||||
00003 <span class="comment"> </span>
|
||||
00004 <span class="comment"> Copyright (C) 2003 Maarten Keijzer</span>
|
||||
00005 <span class="comment"></span>
|
||||
00006 <span class="comment"> This program is free software; you can redistribute it and/or modify</span>
|
||||
00007 <span class="comment"> it under the terms of the GNU General Public License as published by</span>
|
||||
00008 <span class="comment"> the Free Software Foundation; either version 2 of the License, or</span>
|
||||
00009 <span class="comment"> (at your option) any later version.</span>
|
||||
00010 <span class="comment"></span>
|
||||
00011 <span class="comment"> This program is distributed in the hope that it will be useful,</span>
|
||||
00012 <span class="comment"> but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
|
||||
00013 <span class="comment"> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
|
||||
00014 <span class="comment"> GNU General Public License for more details.</span>
|
||||
00015 <span class="comment"></span>
|
||||
00016 <span class="comment"> You should have received a copy of the GNU General Public License</span>
|
||||
00017 <span class="comment"> along with this program; if not, write to the Free Software</span>
|
||||
00018 <span class="comment"> Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>
|
||||
00019 <span class="comment">*/</span>
|
||||
00020
|
||||
00021 <span class="preprocessor">#include <eoBreed.h></span>
|
||||
00022 <span class="preprocessor">#include <eoGeneralBreeder.h></span>
|
||||
00023 <span class="preprocessor">#include <eoOneToOneBreeder.h></span>
|
||||
00024
|
||||
00025 <span class="preprocessor">#include "PyEO.h"</span>
|
||||
00026 <span class="preprocessor">#include "def_abstract_functor.h"</span>
|
||||
00027
|
||||
00028 <span class="keyword">using</span> <span class="keyword">namespace </span>boost::python;
|
||||
00029
|
||||
00030 <span class="preprocessor">#define DEF3(x, i1, i2) class_<x<PyEO>, bases<eoBreed<PyEO > > >(#x, \</span>
|
||||
00031 <span class="preprocessor"> init<i1, i2 >()[with_custodian_and_ward<1,2,with_custodian_and_ward<1,3> >()])\</span>
|
||||
00032 <span class="preprocessor"> .def("__call__", &eoBreed<PyEO>::operator())</span>
|
||||
00033 <span class="preprocessor"></span>
|
||||
00034 <span class="keywordtype">void</span> breeders()
|
||||
00035 {
|
||||
00036 def_abstract_functor<eoBreed<PyEO> >(<span class="stringliteral">"eoBreed"</span>);
|
||||
00037
|
||||
00038 DEF3(<a class="code" href="classeo_select_transform.html">eoSelectTransform</a>, <a class="code" href="classeo_select.html">eoSelect<PyEO></a>&, <a class="code" href="classeo_transform.html">eoTransform<PyEO></a>&);
|
||||
00039
|
||||
00040 DEF3(<a class="code" href="classeo_general_breeder.html">eoGeneralBreeder</a>, <a class="code" href="classeo_select_one.html">eoSelectOne<PyEO></a>&, <a class="code" href="classeo_gen_op.html">eoGenOp<PyEO></a>&)
|
||||
00041 .def( init<<a class="code" href="classeo_select_one.html">eoSelectOne<PyEO></a>&, <a class="code" href="classeo_gen_op.html">eoGenOp<PyEO></a>&, <span class="keywordtype">double</span>>()[WC2])
|
||||
00042 .def( init<eoSelectOne<PyEO>&, <a class="code" href="classeo_gen_op.html">eoGenOp<PyEO></a>&, <span class="keywordtype">double</span>, <span class="keywordtype">bool</span>>()[WC2] )
|
||||
00043 .def( init<eoSelectOne<PyEO>&, <a class="code" href="classeo_gen_op.html">eoGenOp<PyEO></a>&, <a class="code" href="classeo_how_many.html">eoHowMany</a>>() );
|
||||
00044
|
||||
00045
|
||||
00046 DEF3(eoOneToOneBreeder, <a class="code" href="classeo_gen_op.html">eoGenOp<PyEO></a>&, <a class="code" href="classeo_eval_func.html">eoEvalFunc<PyEO></a>&)
|
||||
00047 .def( init<<a class="code" href="classeo_gen_op.html">eoGenOp<PyEO></a>&, <a class="code" href="classeo_eval_func.html">eoEvalFunc<PyEO></a>&, <span class="keywordtype">double</span>>()[WC2] )
|
||||
00048 .def( init<eoGenOp<PyEO>&, <a class="code" href="classeo_eval_func.html">eoEvalFunc<PyEO></a>&, <span class="keywordtype">double</span>, <a class="code" href="classeo_how_many.html">eoHowMany</a>>()[WC2] );
|
||||
00049
|
||||
00050 }
|
||||
00051
|
||||
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:34 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>
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
<!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: Member List</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>
|
||||
<h1>BiasedNodeSelector Member List</h1>This is the complete list of members for <a class="el" href="class_biased_node_selector.html">BiasedNodeSelector</a>, including all inherited members.<p><table>
|
||||
<tr bgcolor="#f0f0f0"><td><b>BiasedNodeSelector</b>() (defined in <a class="el" href="class_biased_node_selector.html">BiasedNodeSelector</a>)</td><td><a class="el" href="class_biased_node_selector.html">BiasedNodeSelector</a></td><td><code> [inline]</code></td></tr>
|
||||
<tr bgcolor="#f0f0f0"><td><b>BiasedNodeSelector</b>(unsigned n) (defined in <a class="el" href="class_biased_node_selector.html">BiasedNodeSelector</a>)</td><td><a class="el" href="class_biased_node_selector.html">BiasedNodeSelector</a></td><td><code> [inline]</code></td></tr>
|
||||
<tr bgcolor="#f0f0f0"><td><b>nRounds</b> (defined in <a class="el" href="class_biased_node_selector.html">BiasedNodeSelector</a>)</td><td><a class="el" href="class_biased_node_selector.html">BiasedNodeSelector</a></td><td></td></tr>
|
||||
<tr bgcolor="#f0f0f0"><td><b>select_node</b>(Sym sym) const (defined in <a class="el" href="class_biased_node_selector.html">BiasedNodeSelector</a>)</td><td><a class="el" href="class_biased_node_selector.html">BiasedNodeSelector</a></td><td><code> [virtual]</code></td></tr>
|
||||
<tr bgcolor="#f0f0f0"><td><b>~NodeSelector</b>() (defined in <a class="el" href="class_node_selector.html">NodeSelector</a>)</td><td><a class="el" href="class_node_selector.html">NodeSelector</a></td><td><code> [inline, virtual]</code></td></tr>
|
||||
</table><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:45 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>
|
||||
44
trunk/paradiseo-eo/doc/html/class_biased_node_selector.html
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
<!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: BiasedNodeSelector Class Reference</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>
|
||||
<h1>BiasedNodeSelector Class Reference</h1>A node selector that does a specified number of rounds ignoring terminals.
|
||||
<a href="#_details">More...</a>
|
||||
<p>
|
||||
<code>#include <<a class="el" href="_node_selector_8h-source.html">NodeSelector.h</a>></code>
|
||||
<p>
|
||||
<p>Inheritance diagram for BiasedNodeSelector:
|
||||
<p><center><img src="class_biased_node_selector.png" usemap="#BiasedNodeSelector_map" border="0" alt=""></center>
|
||||
<map name="BiasedNodeSelector_map">
|
||||
<area href="class_node_selector.html" alt="NodeSelector" shape="rect" coords="0,0,127,24">
|
||||
</map>
|
||||
<a href="class_biased_node_selector-members.html">List of all members.</a><table border="0" cellpadding="0" cellspacing="0">
|
||||
<tr><td></td></tr>
|
||||
<tr><td colspan="2"><br><h2>Public Member Functions</h2></td></tr>
|
||||
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a1" doxytag="BiasedNodeSelector::BiasedNodeSelector"></a>
|
||||
</td><td class="memItemRight" valign="bottom"><b>BiasedNodeSelector</b> (unsigned n)</td></tr>
|
||||
|
||||
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a2" doxytag="BiasedNodeSelector::select_node"></a>
|
||||
NodeSelection </td><td class="memItemRight" valign="bottom"><b>select_node</b> (Sym sym) const </td></tr>
|
||||
|
||||
<tr><td colspan="2"><br><h2>Public Attributes</h2></td></tr>
|
||||
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="o0" doxytag="BiasedNodeSelector::nRounds"></a>
|
||||
unsigned </td><td class="memItemRight" valign="bottom"><b>nRounds</b></td></tr>
|
||||
|
||||
</table>
|
||||
<hr><a name="_details"></a><h2>Detailed Description</h2>
|
||||
A node selector that does a specified number of rounds ignoring terminals.
|
||||
<p>
|
||||
|
||||
<p>
|
||||
Definition at line <a class="el" href="_node_selector_8h-source.html#l00055">55</a> of file <a class="el" href="_node_selector_8h-source.html">NodeSelector.h</a>.<hr>The documentation for this class was generated from the following files:<ul>
|
||||
<li><a class="el" href="_node_selector_8h-source.html">NodeSelector.h</a><li><a class="el" href="_node_selector_8cpp-source.html">NodeSelector.cpp</a></ul>
|
||||
<hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:45 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>
|
||||
BIN
trunk/paradiseo-eo/doc/html/class_biased_node_selector.png
Normal file
|
After Width: | Height: | Size: 446 B |
23
trunk/paradiseo-eo/doc/html/class_cov-members.html
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<!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: Member List</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>
|
||||
<h1>Cov Member List</h1>This is the complete list of members for <a class="el" href="class_cov.html">Cov</a>, including all inherited members.<p><table>
|
||||
<tr bgcolor="#f0f0f0"><td><b>Cov</b>() (defined in <a class="el" href="class_cov.html">Cov</a>)</td><td><a class="el" href="class_cov.html">Cov</a></td><td><code> [inline]</code></td></tr>
|
||||
<tr bgcolor="#f0f0f0"><td><b>get_cov</b>() const (defined in <a class="el" href="class_cov.html">Cov</a>)</td><td><a class="el" href="class_cov.html">Cov</a></td><td><code> [inline]</code></td></tr>
|
||||
<tr bgcolor="#f0f0f0"><td><b>get_meana</b>() const (defined in <a class="el" href="class_cov.html">Cov</a>)</td><td><a class="el" href="class_cov.html">Cov</a></td><td><code> [inline]</code></td></tr>
|
||||
<tr bgcolor="#f0f0f0"><td><b>get_meanb</b>() const (defined in <a class="el" href="class_cov.html">Cov</a>)</td><td><a class="el" href="class_cov.html">Cov</a></td><td><code> [inline]</code></td></tr>
|
||||
<tr bgcolor="#f0f0f0"><td><b>meana</b> (defined in <a class="el" href="class_cov.html">Cov</a>)</td><td><a class="el" href="class_cov.html">Cov</a></td><td><code> [private]</code></td></tr>
|
||||
<tr bgcolor="#f0f0f0"><td><b>meanb</b> (defined in <a class="el" href="class_cov.html">Cov</a>)</td><td><a class="el" href="class_cov.html">Cov</a></td><td><code> [private]</code></td></tr>
|
||||
<tr bgcolor="#f0f0f0"><td><b>n</b> (defined in <a class="el" href="class_cov.html">Cov</a>)</td><td><a class="el" href="class_cov.html">Cov</a></td><td><code> [private]</code></td></tr>
|
||||
<tr bgcolor="#f0f0f0"><td><b>sumcov</b> (defined in <a class="el" href="class_cov.html">Cov</a>)</td><td><a class="el" href="class_cov.html">Cov</a></td><td><code> [private]</code></td></tr>
|
||||
<tr bgcolor="#f0f0f0"><td><b>update</b>(double a, double b) (defined in <a class="el" href="class_cov.html">Cov</a>)</td><td><a class="el" href="class_cov.html">Cov</a></td><td><code> [inline]</code></td></tr>
|
||||
</table><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:46 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>
|
||||
54
trunk/paradiseo-eo/doc/html/class_cov.html
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
<!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: Cov Class Reference</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>
|
||||
<h1>Cov Class Reference</h1>Single covariance between two variates.
|
||||
<a href="#_details">More...</a>
|
||||
<p>
|
||||
<code>#include <<a class="el" href="stats_8h-source.html">stats.h</a>></code>
|
||||
<p>
|
||||
<a href="class_cov-members.html">List of all members.</a><table border="0" cellpadding="0" cellspacing="0">
|
||||
<tr><td></td></tr>
|
||||
<tr><td colspan="2"><br><h2>Public Member Functions</h2></td></tr>
|
||||
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a1" doxytag="Cov::update"></a>
|
||||
void </td><td class="memItemRight" valign="bottom"><b>update</b> (double a, double b)</td></tr>
|
||||
|
||||
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a2" doxytag="Cov::get_meana"></a>
|
||||
double </td><td class="memItemRight" valign="bottom"><b>get_meana</b> () const </td></tr>
|
||||
|
||||
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a3" doxytag="Cov::get_meanb"></a>
|
||||
double </td><td class="memItemRight" valign="bottom"><b>get_meanb</b> () const </td></tr>
|
||||
|
||||
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a4" doxytag="Cov::get_cov"></a>
|
||||
double </td><td class="memItemRight" valign="bottom"><b>get_cov</b> () const </td></tr>
|
||||
|
||||
<tr><td colspan="2"><br><h2>Private Attributes</h2></td></tr>
|
||||
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="r0" doxytag="Cov::n"></a>
|
||||
double </td><td class="memItemRight" valign="bottom"><b>n</b></td></tr>
|
||||
|
||||
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="r1" doxytag="Cov::meana"></a>
|
||||
double </td><td class="memItemRight" valign="bottom"><b>meana</b></td></tr>
|
||||
|
||||
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="r2" doxytag="Cov::meanb"></a>
|
||||
double </td><td class="memItemRight" valign="bottom"><b>meanb</b></td></tr>
|
||||
|
||||
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="r3" doxytag="Cov::sumcov"></a>
|
||||
double </td><td class="memItemRight" valign="bottom"><b>sumcov</b></td></tr>
|
||||
|
||||
</table>
|
||||
<hr><a name="_details"></a><h2>Detailed Description</h2>
|
||||
Single covariance between two variates.
|
||||
<p>
|
||||
|
||||
<p>
|
||||
Definition at line <a class="el" href="stats_8h-source.html#l00058">58</a> of file <a class="el" href="stats_8h-source.html">stats.h</a>.<hr>The documentation for this class was generated from the following file:<ul>
|
||||
<li><a class="el" href="stats_8h-source.html">stats.h</a></ul>
|
||||
<hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:46 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>
|
||||
49
trunk/paradiseo-eo/doc/html/class_e_o-members.html
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
<!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: Member List</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>
|
||||
<h1>EO< F > Member List</h1>This is the complete list of members for <a class="el" href="class_e_o.html">EO< F ></a>, including all inherited members.<p><table>
|
||||
<tr class="memlist"><td><a class="el" href="class_e_o.html#z10_0">className</a>() const </td><td><a class="el" href="class_e_o.html">EO< F ></a></td><td><code> [inline, virtual]</code></td></tr>
|
||||
<tr class="memlist"><td><a class="el" href="class_e_o.html#a0">EO</a>()</td><td><a class="el" href="class_e_o.html">EO< F ></a></td><td><code> [inline]</code></td></tr>
|
||||
<tr bgcolor="#f0f0f0"><td><b>EO</b>() (defined in <a class="el" href="class_e_o.html">EO< F ></a>)</td><td><a class="el" href="class_e_o.html">EO< F ></a></td><td><code> [inline]</code></td></tr>
|
||||
<tr bgcolor="#f0f0f0"><td><b>Fitness</b> typedef (defined in <a class="el" href="class_e_o.html">EO< F ></a>)</td><td><a class="el" href="class_e_o.html">EO< F ></a></td><td></td></tr>
|
||||
<tr class="memlist"><td><a class="el" href="class_e_o.html#a2">fitness</a>() const </td><td><a class="el" href="class_e_o.html">EO< F ></a></td><td><code> [inline]</code></td></tr>
|
||||
<tr class="memlist"><td><a class="el" href="class_e_o.html#a4">fitness</a>(const Fitness &_fitness)</td><td><a class="el" href="class_e_o.html">EO< F ></a></td><td><code> [inline]</code></td></tr>
|
||||
<tr bgcolor="#f0f0f0"><td><b>fitness</b>(performance_type perf) (defined in <a class="el" href="class_e_o.html">EO< F ></a>)</td><td><a class="el" href="class_e_o.html">EO< F ></a></td><td><code> [inline]</code></td></tr>
|
||||
<tr bgcolor="#f0f0f0"><td><b>fitness</b>(void) const (defined in <a class="el" href="class_e_o.html">EO< F ></a>)</td><td><a class="el" href="class_e_o.html">EO< F ></a></td><td><code> [inline]</code></td></tr>
|
||||
<tr bgcolor="#f0f0f0"><td><b>fitness_traits</b> typedef (defined in <a class="el" href="class_e_o.html">EO< F ></a>)</td><td><a class="el" href="class_e_o.html">EO< F ></a></td><td></td></tr>
|
||||
<tr class="memlist"><td><a class="el" href="class_e_o.html#a5">invalid</a>() const </td><td><a class="el" href="class_e_o.html">EO< F ></a></td><td><code> [inline]</code></td></tr>
|
||||
<tr bgcolor="#f0f0f0"><td><b>invalidate</b>() (defined in <a class="el" href="class_e_o.html">EO< F ></a>)</td><td><a class="el" href="class_e_o.html">EO< F ></a></td><td><code> [inline]</code></td></tr>
|
||||
<tr bgcolor="#f0f0f0"><td><b>invalidate</b>(void) (defined in <a class="el" href="class_e_o.html">EO< F ></a>)</td><td><a class="el" href="class_e_o.html">EO< F ></a></td><td><code> [inline]</code></td></tr>
|
||||
<tr bgcolor="#f0f0f0"><td><b>invalidate_worth</b>(void) (defined in <a class="el" href="class_e_o.html">EO< F ></a>)</td><td><a class="el" href="class_e_o.html">EO< F ></a></td><td><code> [inline]</code></td></tr>
|
||||
<tr bgcolor="#f0f0f0"><td><b>invalidFitness</b> (defined in <a class="el" href="class_e_o.html">EO< F ></a>)</td><td><a class="el" href="class_e_o.html">EO< F ></a></td><td><code> [private]</code></td></tr>
|
||||
<tr class="memlist"><td><a class="el" href="class_e_o.html#a6">operator<</a>(const EO &_eo2) const </td><td><a class="el" href="class_e_o.html">EO< F ></a></td><td><code> [inline]</code></td></tr>
|
||||
<tr bgcolor="#f0f0f0"><td><b>operator<</b>(const EO< Fitness, Traits > &other) const (defined in <a class="el" href="class_e_o.html">EO< F ></a>)</td><td><a class="el" href="class_e_o.html">EO< F ></a></td><td><code> [inline]</code></td></tr>
|
||||
<tr bgcolor="#f0f0f0"><td><b>operator></b>(const EO &_eo2) const (defined in <a class="el" href="class_e_o.html">EO< F ></a>)</td><td><a class="el" href="class_e_o.html">EO< F ></a></td><td><code> [inline]</code></td></tr>
|
||||
<tr bgcolor="#f0f0f0"><td><b>operator></b>(const EO< Fitness, Traits > &other) const (defined in <a class="el" href="class_e_o.html">EO< F ></a>)</td><td><a class="el" href="class_e_o.html">EO< F ></a></td><td><code> [inline]</code></td></tr>
|
||||
<tr bgcolor="#f0f0f0"><td><b>performance</b>(performance_type perf) (defined in <a class="el" href="class_e_o.html">EO< F ></a>)</td><td><a class="el" href="class_e_o.html">EO< F ></a></td><td><code> [inline]</code></td></tr>
|
||||
<tr bgcolor="#f0f0f0"><td><b>performance</b>(void) const (defined in <a class="el" href="class_e_o.html">EO< F ></a>)</td><td><a class="el" href="class_e_o.html">EO< F ></a></td><td><code> [inline]</code></td></tr>
|
||||
<tr bgcolor="#f0f0f0"><td><b>performance_type</b> typedef (defined in <a class="el" href="class_e_o.html">EO< F ></a>)</td><td><a class="el" href="class_e_o.html">EO< F ></a></td><td></td></tr>
|
||||
<tr class="memlist"><td><a class="el" href="class_e_o.html#z10_2">printOn</a>(std::ostream &_os) const </td><td><a class="el" href="class_e_o.html">EO< F ></a></td><td><code> [inline, virtual]</code></td></tr>
|
||||
<tr class="memlist"><td><a class="el" href="class_e_o.html#z10_1">readFrom</a>(std::istream &_is)</td><td><a class="el" href="class_e_o.html">EO< F ></a></td><td><code> [inline, virtual]</code></td></tr>
|
||||
<tr bgcolor="#f0f0f0"><td><b>rep_fitness</b> (defined in <a class="el" href="class_e_o.html">EO< F ></a>)</td><td><a class="el" href="class_e_o.html">EO< F ></a></td><td><code> [private]</code></td></tr>
|
||||
<tr bgcolor="#f0f0f0"><td><b>repFitness</b> (defined in <a class="el" href="class_e_o.html">EO< F ></a>)</td><td><a class="el" href="class_e_o.html">EO< F ></a></td><td><code> [private]</code></td></tr>
|
||||
<tr bgcolor="#f0f0f0"><td><b>storage_type</b> typedef (defined in <a class="el" href="class_e_o.html">EO< F ></a>)</td><td><a class="el" href="class_e_o.html">EO< F ></a></td><td></td></tr>
|
||||
<tr bgcolor="#f0f0f0"><td><b>valid_performance</b> (defined in <a class="el" href="class_e_o.html">EO< F ></a>)</td><td><a class="el" href="class_e_o.html">EO< F ></a></td><td><code> [private]</code></td></tr>
|
||||
<tr bgcolor="#f0f0f0"><td><b>valid_worth</b> (defined in <a class="el" href="class_e_o.html">EO< F ></a>)</td><td><a class="el" href="class_e_o.html">EO< F ></a></td><td><code> [private]</code></td></tr>
|
||||
<tr bgcolor="#f0f0f0"><td><b>worth</b>(worth_type worth) (defined in <a class="el" href="class_e_o.html">EO< F ></a>)</td><td><a class="el" href="class_e_o.html">EO< F ></a></td><td><code> [inline]</code></td></tr>
|
||||
<tr bgcolor="#f0f0f0"><td><b>worth</b>(void) const (defined in <a class="el" href="class_e_o.html">EO< F ></a>)</td><td><a class="el" href="class_e_o.html">EO< F ></a></td><td><code> [inline]</code></td></tr>
|
||||
<tr bgcolor="#f0f0f0"><td><b>worth_type</b> typedef (defined in <a class="el" href="class_e_o.html">EO< F ></a>)</td><td><a class="el" href="class_e_o.html">EO< F ></a></td><td></td></tr>
|
||||
<tr class="memlist"><td><a class="el" href="class_e_o.html#a1">~EO</a>()</td><td><a class="el" href="class_e_o.html">EO< F ></a></td><td><code> [inline, virtual]</code></td></tr>
|
||||
<tr class="memlist"><td><a class="el" href="classeo_object.html#a0">~eoObject</a>()</td><td><a class="el" href="classeo_object.html">eoObject</a></td><td><code> [inline, virtual]</code></td></tr>
|
||||
<tr class="memlist"><td><a class="el" href="classeo_persistent.html#a0">~eoPersistent</a>()</td><td><a class="el" href="classeo_persistent.html">eoPersistent</a></td><td><code> [inline, virtual]</code></td></tr>
|
||||
<tr class="memlist"><td><a class="el" href="classeo_printable.html#a0">~eoPrintable</a>()</td><td><a class="el" href="classeo_printable.html">eoPrintable</a></td><td><code> [inline, virtual]</code></td></tr>
|
||||
</table><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:47 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>
|
||||
434
trunk/paradiseo-eo/doc/html/class_e_o.html
Normal file
|
|
@ -0,0 +1,434 @@
|
|||
<!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: EO< F > Class Template Reference</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>
|
||||
<h1>EO< F > Class Template Reference</h1>EO is a base class for evolvable objects, that is, the subjects of evolution.
|
||||
<a href="#_details">More...</a>
|
||||
<p>
|
||||
<code>#include <<a class="el" href="_e_o_8h-source.html">EO.h</a>></code>
|
||||
<p>
|
||||
<p>Inheritance diagram for EO< F >:
|
||||
<p><center><img src="class_e_o.png" usemap="#EO< F >_map" border="0" alt=""></center>
|
||||
<map name="EO< F >_map">
|
||||
<area href="classeo_object.html" alt="eoObject" shape="rect" coords="0,56,81,80">
|
||||
<area href="classeo_persistent.html" alt="eoPersistent" shape="rect" coords="91,56,172,80">
|
||||
<area href="classeo_printable.html" alt="eoPrintable" shape="rect" coords="91,0,172,24">
|
||||
</map>
|
||||
<a href="class_e_o-members.html">List of all members.</a><table border="0" cellpadding="0" cellspacing="0">
|
||||
<tr><td></td></tr>
|
||||
<tr><td colspan="2"><br><h2>Public Types</h2></td></tr>
|
||||
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="w0" doxytag="EO::Fitness"></a>
|
||||
typedef F </td><td class="memItemRight" valign="bottom"><b>Fitness</b></td></tr>
|
||||
|
||||
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="w1" doxytag="EO::fitness_traits"></a>
|
||||
typedef Traits </td><td class="memItemRight" valign="bottom"><b>fitness_traits</b></td></tr>
|
||||
|
||||
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="w2" doxytag="EO::storage_type"></a>
|
||||
typedef Traits::storage_type </td><td class="memItemRight" valign="bottom"><b>storage_type</b></td></tr>
|
||||
|
||||
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="w3" doxytag="EO::performance_type"></a>
|
||||
typedef Traits::performance_type </td><td class="memItemRight" valign="bottom"><b>performance_type</b></td></tr>
|
||||
|
||||
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="w4" doxytag="EO::worth_type"></a>
|
||||
typedef Traits::worth_type </td><td class="memItemRight" valign="bottom"><b>worth_type</b></td></tr>
|
||||
|
||||
<tr><td colspan="2"><br><h2>Public Member Functions</h2></td></tr>
|
||||
<tr><td class="memItemLeft" nowrap align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="class_e_o.html#a0">EO</a> ()</td></tr>
|
||||
|
||||
<tr><td class="mdescLeft"> </td><td class="mdescRight">Default constructor. <a href="#a0"></a><br></td></tr>
|
||||
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a1" doxytag="EO::~EO"></a>
|
||||
virtual </td><td class="memItemRight" valign="bottom"><a class="el" href="class_e_o.html#a1">~EO</a> ()</td></tr>
|
||||
|
||||
<tr><td class="mdescLeft"> </td><td class="mdescRight">Virtual dtor. <br></td></tr>
|
||||
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a2" doxytag="EO::fitness"></a>
|
||||
Fitness </td><td class="memItemRight" valign="bottom"><a class="el" href="class_e_o.html#a2">fitness</a> () const </td></tr>
|
||||
|
||||
<tr><td class="mdescLeft"> </td><td class="mdescRight">Return fitness value. <br></td></tr>
|
||||
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a3" doxytag="EO::invalidate"></a>
|
||||
void </td><td class="memItemRight" valign="bottom"><b>invalidate</b> ()</td></tr>
|
||||
|
||||
<tr><td class="memItemLeft" nowrap align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="class_e_o.html#a4">fitness</a> (const Fitness &_fitness)</td></tr>
|
||||
|
||||
<tr><td class="mdescLeft"> </td><td class="mdescRight">Set fitness. <a href="#a4"></a><br></td></tr>
|
||||
<tr><td class="memItemLeft" nowrap align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="class_e_o.html#a5">invalid</a> () const </td></tr>
|
||||
|
||||
<tr><td class="mdescLeft"> </td><td class="mdescRight">Return true If fitness value is invalid, false otherwise. <a href="#a5"></a><br></td></tr>
|
||||
<tr><td class="memItemLeft" nowrap align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="class_e_o.html#a6">operator<</a> (const <a class="el" href="class_e_o.html">EO</a> &_eo2) const </td></tr>
|
||||
|
||||
<tr><td class="mdescLeft"> </td><td class="mdescRight">Returns true if. <a href="#a6"></a><br></td></tr>
|
||||
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a7" doxytag="EO::operator>"></a>
|
||||
bool </td><td class="memItemRight" valign="bottom"><b>operator></b> (const <a class="el" href="class_e_o.html">EO</a> &_eo2) const </td></tr>
|
||||
|
||||
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a9" doxytag="EO::fitness"></a>
|
||||
void </td><td class="memItemRight" valign="bottom"><b>fitness</b> (performance_type perf)</td></tr>
|
||||
|
||||
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a10" doxytag="EO::performance"></a>
|
||||
void </td><td class="memItemRight" valign="bottom"><b>performance</b> (performance_type perf)</td></tr>
|
||||
|
||||
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a11" doxytag="EO::performance"></a>
|
||||
performance_type </td><td class="memItemRight" valign="bottom"><b>performance</b> (void) const </td></tr>
|
||||
|
||||
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a12" doxytag="EO::worth"></a>
|
||||
void </td><td class="memItemRight" valign="bottom"><b>worth</b> (worth_type worth)</td></tr>
|
||||
|
||||
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a13" doxytag="EO::worth"></a>
|
||||
worth_type </td><td class="memItemRight" valign="bottom"><b>worth</b> (void) const </td></tr>
|
||||
|
||||
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a14" doxytag="EO::fitness"></a>
|
||||
worth_type </td><td class="memItemRight" valign="bottom"><b>fitness</b> (void) const </td></tr>
|
||||
|
||||
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a15" doxytag="EO::invalidate"></a>
|
||||
void </td><td class="memItemRight" valign="bottom"><b>invalidate</b> (void)</td></tr>
|
||||
|
||||
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a16" doxytag="EO::invalidate_worth"></a>
|
||||
void </td><td class="memItemRight" valign="bottom"><b>invalidate_worth</b> (void)</td></tr>
|
||||
|
||||
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a17" doxytag="EO::operator<"></a>
|
||||
bool </td><td class="memItemRight" valign="bottom"><b>operator<</b> (const EO< Fitness, Traits > &other) const </td></tr>
|
||||
|
||||
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a18" doxytag="EO::operator>"></a>
|
||||
bool </td><td class="memItemRight" valign="bottom"><b>operator></b> (const EO< Fitness, Traits > &other) const </td></tr>
|
||||
|
||||
<tr><td colspan="2"><div class="groupHeader"></div></td></tr>
|
||||
<tr><td class="memItemLeft" nowrap align="right" valign="top">virtual std::string </td><td class="memItemRight" valign="bottom"><a class="el" href="class_e_o.html#z10_0">className</a> () const </td></tr>
|
||||
|
||||
<tr><td class="mdescLeft"> </td><td class="mdescRight">Return the class id. <a href="#z10_0"></a><br></td></tr>
|
||||
<tr><td class="memItemLeft" nowrap align="right" valign="top">virtual void </td><td class="memItemRight" valign="bottom"><a class="el" href="class_e_o.html#z10_1">readFrom</a> (std::istream &_is)</td></tr>
|
||||
|
||||
<tr><td class="mdescLeft"> </td><td class="mdescRight">Read object.\ Calls base class, just in case that one had something to do. <a href="#z10_1"></a><br></td></tr>
|
||||
<tr><td class="memItemLeft" nowrap align="right" valign="top">virtual void </td><td class="memItemRight" valign="bottom"><a class="el" href="class_e_o.html#z10_2">printOn</a> (std::ostream &_os) const </td></tr>
|
||||
|
||||
<tr><td class="mdescLeft"> </td><td class="mdescRight">Write object. <a href="#z10_2"></a><br></td></tr>
|
||||
<tr><td colspan="2"><br><h2>Private Attributes</h2></td></tr>
|
||||
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="r0" doxytag="EO::repFitness"></a>
|
||||
Fitness </td><td class="memItemRight" valign="bottom"><b>repFitness</b></td></tr>
|
||||
|
||||
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="r1" doxytag="EO::invalidFitness"></a>
|
||||
bool </td><td class="memItemRight" valign="bottom"><b>invalidFitness</b></td></tr>
|
||||
|
||||
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="r2" doxytag="EO::valid_performance"></a>
|
||||
bool </td><td class="memItemRight" valign="bottom"><b>valid_performance</b></td></tr>
|
||||
|
||||
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="r3" doxytag="EO::valid_worth"></a>
|
||||
bool </td><td class="memItemRight" valign="bottom"><b>valid_worth</b></td></tr>
|
||||
|
||||
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="r4" doxytag="EO::rep_fitness"></a>
|
||||
storage_type </td><td class="memItemRight" valign="bottom"><b>rep_fitness</b></td></tr>
|
||||
|
||||
</table>
|
||||
<hr><a name="_details"></a><h2>Detailed Description</h2>
|
||||
<h3>template<class F><br>
|
||||
class EO< F ></h3>
|
||||
|
||||
EO is a base class for evolvable objects, that is, the subjects of evolution.
|
||||
<p>
|
||||
EOs have only got a fitness, which at the same time needs to be only an object with the operation less than (<) defined. Fitness says how good is the object; evolution or change of these objects is left to the genetic operators. A fitness less than another means a worse fitness, in whatever the context; thus, fitness is always maximized; although it can be minimized with a proper definition of the < operator. The fitness object must have, besides an void ctor, a copy ctor.
|
||||
<p>
|
||||
|
||||
<p>
|
||||
Definition at line <a class="el" href="_e_o_8h-source.html#l00044">44</a> of file <a class="el" href="_e_o_8h-source.html">EO.h</a>.<hr><h2>Constructor & Destructor Documentation</h2>
|
||||
<a class="anchor" name="a0" doxytag="EO::EO"></a><p>
|
||||
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
|
||||
<tr>
|
||||
<td class="mdRow">
|
||||
<table cellpadding="0" cellspacing="0" border="0">
|
||||
<tr>
|
||||
<td class="md" colspan="4">
|
||||
template<class F> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="md" nowrap valign="top"><a class="el" href="class_e_o.html">EO</a>< F >::<a class="el" href="class_e_o.html">EO</a> </td>
|
||||
<td class="md" valign="top">( </td>
|
||||
<td class="mdname1" valign="top" nowrap> </td>
|
||||
<td class="md" valign="top"> ) </td>
|
||||
<td class="md" nowrap><code> [inline]</code></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<table cellspacing="5" cellpadding="0" border="0">
|
||||
<tr>
|
||||
<td>
|
||||
|
||||
</td>
|
||||
<td>
|
||||
|
||||
<p>
|
||||
Default constructor.
|
||||
<p>
|
||||
Fitness must have a ctor which takes 0 as a value; we can not use void ctors here since default types like float have no void initializer. VC++ allows it, but gcc does not
|
||||
<p>
|
||||
Definition at line <a class="el" href="_e_o_8h-source.html#l00054">54</a> of file <a class="el" href="_e_o_8h-source.html">EO.h</a>. </td>
|
||||
</tr>
|
||||
</table>
|
||||
<hr><h2>Member Function Documentation</h2>
|
||||
<a class="anchor" name="a4" doxytag="EO::fitness"></a><p>
|
||||
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
|
||||
<tr>
|
||||
<td class="mdRow">
|
||||
<table cellpadding="0" cellspacing="0" border="0">
|
||||
<tr>
|
||||
<td class="md" colspan="4">
|
||||
template<class F> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="md" nowrap valign="top">void <a class="el" href="class_e_o.html">EO</a>< F >::fitness </td>
|
||||
<td class="md" valign="top">( </td>
|
||||
<td class="md" nowrap valign="top">const Fitness & </td>
|
||||
<td class="mdname1" valign="top" nowrap> <em>_fitness</em> </td>
|
||||
<td class="md" valign="top"> ) </td>
|
||||
<td class="md" nowrap><code> [inline]</code></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<table cellspacing="5" cellpadding="0" border="0">
|
||||
<tr>
|
||||
<td>
|
||||
|
||||
</td>
|
||||
<td>
|
||||
|
||||
<p>
|
||||
Set fitness.
|
||||
<p>
|
||||
At the same time, validates it. <dl compact><dt><b>Parameters:</b></dt><dd>
|
||||
<table border="0" cellspacing="2" cellpadding="0">
|
||||
<tr><td valign="top"></td><td valign="top"><em>_fitness</em> </td><td>New fitness value. </td></tr>
|
||||
</table>
|
||||
</dl>
|
||||
|
||||
<p>
|
||||
Definition at line <a class="el" href="_e_o_8h-source.html#l00072">72</a> of file <a class="el" href="_e_o_8h-source.html">EO.h</a>. </td>
|
||||
</tr>
|
||||
</table>
|
||||
<a class="anchor" name="a5" doxytag="EO::invalid"></a><p>
|
||||
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
|
||||
<tr>
|
||||
<td class="mdRow">
|
||||
<table cellpadding="0" cellspacing="0" border="0">
|
||||
<tr>
|
||||
<td class="md" colspan="4">
|
||||
template<class F> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="md" nowrap valign="top">bool <a class="el" href="class_e_o.html">EO</a>< F >::invalid </td>
|
||||
<td class="md" valign="top">( </td>
|
||||
<td class="mdname1" valign="top" nowrap> </td>
|
||||
<td class="md" valign="top"> ) </td>
|
||||
<td class="md" nowrap> const<code> [inline]</code></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<table cellspacing="5" cellpadding="0" border="0">
|
||||
<tr>
|
||||
<td>
|
||||
|
||||
</td>
|
||||
<td>
|
||||
|
||||
<p>
|
||||
Return true If fitness value is invalid, false otherwise.
|
||||
<p>
|
||||
<dl compact><dt><b>Returns:</b></dt><dd>true If fitness is invalid. </dd></dl>
|
||||
|
||||
<p>
|
||||
Definition at line <a class="el" href="_e_o_8h-source.html#l00081">81</a> of file <a class="el" href="_e_o_8h-source.html">EO.h</a>.
|
||||
<p>
|
||||
Referenced by <a class="el" href="_e_o_8h-source.html#l00060">EO< PyFitness >::fitness()</a>, <a class="el" href="eo_one_max_eval_func_8h-source.html#l00045">eoOneMaxEvalFunc< EOT >::operator()()</a>, <a class="el" href="eo_normal_mutation_8h-source.html#l00216">eoOneFifthMutation< EOT >::operator()()</a>, <a class="el" href="eo_eval_func_ptr_8h-source.html#l00055">eoEvalFuncPtr< EOT, FitT, FunctionArg >::operator()()</a>, <a class="el" href="eo_eval_func_counter_8h-source.html#l00043">eoEvalFuncCounter< EOT >::operator()()</a>, and <a class="el" href="_e_o_8h-source.html#l00129">EO< PyFitness >::printOn()</a>. </td>
|
||||
</tr>
|
||||
</table>
|
||||
<a class="anchor" name="a6" doxytag="EO::operator<"></a><p>
|
||||
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
|
||||
<tr>
|
||||
<td class="mdRow">
|
||||
<table cellpadding="0" cellspacing="0" border="0">
|
||||
<tr>
|
||||
<td class="md" colspan="4">
|
||||
template<class F> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="md" nowrap valign="top">bool <a class="el" href="class_e_o.html">EO</a>< F >::operator< </td>
|
||||
<td class="md" valign="top">( </td>
|
||||
<td class="md" nowrap valign="top">const <a class="el" href="class_e_o.html">EO</a>< F > & </td>
|
||||
<td class="mdname1" valign="top" nowrap> <em>_eo2</em> </td>
|
||||
<td class="md" valign="top"> ) </td>
|
||||
<td class="md" nowrap> const<code> [inline]</code></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<table cellspacing="5" cellpadding="0" border="0">
|
||||
<tr>
|
||||
<td>
|
||||
|
||||
</td>
|
||||
<td>
|
||||
|
||||
<p>
|
||||
Returns true if.
|
||||
<p>
|
||||
<dl compact><dt><b>Returns:</b></dt><dd>true if the fitness is higher </dd></dl>
|
||||
|
||||
<p>
|
||||
Definition at line <a class="el" href="_e_o_8h-source.html#l00086">86</a> of file <a class="el" href="_e_o_8h-source.html">EO.h</a>.
|
||||
<p>
|
||||
Referenced by <a class="el" href="eo_vector_8h-source.html#l00090">eoVector< FitT, bool >::operator<()</a>. </td>
|
||||
</tr>
|
||||
</table>
|
||||
<a class="anchor" name="z10_0" doxytag="EO::className"></a><p>
|
||||
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
|
||||
<tr>
|
||||
<td class="mdRow">
|
||||
<table cellpadding="0" cellspacing="0" border="0">
|
||||
<tr>
|
||||
<td class="md" colspan="4">
|
||||
template<class F> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="md" nowrap valign="top">virtual std::string <a class="el" href="class_e_o.html">EO</a>< F >::className </td>
|
||||
<td class="md" valign="top">( </td>
|
||||
<td class="md" nowrap valign="top">void </td>
|
||||
<td class="mdname1" valign="top" nowrap> </td>
|
||||
<td class="md" valign="top"> ) </td>
|
||||
<td class="md" nowrap> const<code> [inline, virtual]</code></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<table cellspacing="5" cellpadding="0" border="0">
|
||||
<tr>
|
||||
<td>
|
||||
|
||||
</td>
|
||||
<td>
|
||||
|
||||
<p>
|
||||
Return the class id.
|
||||
<p>
|
||||
<dl compact><dt><b>Returns:</b></dt><dd>the class name as a std::string </dd></dl>
|
||||
|
||||
<p>
|
||||
Implements <a class="el" href="classeo_object.html#a1">eoObject</a>.
|
||||
<p>
|
||||
Reimplemented in <a class="el" href="classeo_es_full.html#a1">eoEsFull< Fit ></a>, <a class="el" href="classeo_es_simple.html#a1">eoEsSimple< Fit ></a>, <a class="el" href="classeo_es_stdev.html#a1">eoEsStdev< Fit ></a>, <a class="el" href="classeo_real.html#a1">eoReal< FitT ></a>, <a class="el" href="classeo_bit.html#a1">eoBit< FitT ></a>, <a class="el" href="classeo_parse_tree.html#a4">eoParseTree< FType, Node ></a>, <a class="el" href="classeo_string.html#z26_0">eoString< fitnessT ></a>, and <a class="el" href="classeo_one_max.html#a2">eoOneMax< FitT ></a>.
|
||||
<p>
|
||||
Definition at line <a class="el" href="_e_o_8h-source.html#l00095">95</a> of file <a class="el" href="_e_o_8h-source.html">EO.h</a>. </td>
|
||||
</tr>
|
||||
</table>
|
||||
<a class="anchor" name="z10_1" doxytag="EO::readFrom"></a><p>
|
||||
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
|
||||
<tr>
|
||||
<td class="mdRow">
|
||||
<table cellpadding="0" cellspacing="0" border="0">
|
||||
<tr>
|
||||
<td class="md" colspan="4">
|
||||
template<class F> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="md" nowrap valign="top">virtual void <a class="el" href="class_e_o.html">EO</a>< F >::readFrom </td>
|
||||
<td class="md" valign="top">( </td>
|
||||
<td class="md" nowrap valign="top">std::istream & </td>
|
||||
<td class="mdname1" valign="top" nowrap> <em>_is</em> </td>
|
||||
<td class="md" valign="top"> ) </td>
|
||||
<td class="md" nowrap><code> [inline, virtual]</code></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<table cellspacing="5" cellpadding="0" border="0">
|
||||
<tr>
|
||||
<td>
|
||||
|
||||
</td>
|
||||
<td>
|
||||
|
||||
<p>
|
||||
Read object.\ Calls base class, just in case that one had something to do.
|
||||
<p>
|
||||
The read and print methods should be compatible and have the same format. In principle, format is "plain": they just print a number <dl compact><dt><b>Parameters:</b></dt><dd>
|
||||
<table border="0" cellspacing="2" cellpadding="0">
|
||||
<tr><td valign="top"></td><td valign="top"><em>_is</em> </td><td>a std::istream. </td></tr>
|
||||
</table>
|
||||
</dl>
|
||||
<dl compact><dt><b>Exceptions:</b></dt><dd>
|
||||
<table border="0" cellspacing="2" cellpadding="0">
|
||||
<tr><td valign="top"></td><td valign="top"><em>runtime_std::exception</em> </td><td>If a valid object can't be read. </td></tr>
|
||||
</table>
|
||||
</dl>
|
||||
|
||||
<p>
|
||||
Implements <a class="el" href="classeo_persistent.html#a1">eoPersistent</a>.
|
||||
<p>
|
||||
Reimplemented in <a class="el" href="classeo_vector.html#a5">eoVector< FitT, GeneType ></a>, <a class="el" href="classeo_es_full.html#a3">eoEsFull< Fit ></a>, <a class="el" href="classeo_es_simple.html#a3">eoEsSimple< Fit ></a>, <a class="el" href="classeo_es_stdev.html#a3">eoEsStdev< Fit ></a>, <a class="el" href="classeo_bit.html#a3">eoBit< FitT ></a>, <a class="el" href="classeo_parse_tree.html#a6">eoParseTree< FType, Node ></a>, <a class="el" href="classeo_external_e_o.html#a3">eoExternalEO< Fit, External ></a>, <a class="el" href="classeo_vector.html#a5">eoVector< Fit, double ></a>, <a class="el" href="classeo_vector.html#a5">eoVector< FitT, double ></a>, and <a class="el" href="classeo_vector.html#a5">eoVector< FitT, bool ></a>.
|
||||
<p>
|
||||
Definition at line <a class="el" href="_e_o_8h-source.html#l00105">105</a> of file <a class="el" href="_e_o_8h-source.html">EO.h</a>.
|
||||
<p>
|
||||
Referenced by <a class="el" href="eo_vector_8h-source.html#l00107">eoVector< FitT, bool >::readFrom()</a>, <a class="el" href="eo_pop_8h-source.html#l00274">eoPop< Dummy >::readFrom()</a>, <a class="el" href="eo_parse_tree_8h-source.html#l00128">eoParseTree< FType, Node >::readFrom()</a>, <a class="el" href="eo_one_max_8h-source.html#l00072">eoOneMax< FitT >::readFrom()</a>, <a class="el" href="eo_external_e_o_8h-source.html#l00059">eoExternalEO< Fit, External >::readFrom()</a>, and <a class="el" href="eo_bit_8h-source.html#l00094">eoBit< FitT >::readFrom()</a>. </td>
|
||||
</tr>
|
||||
</table>
|
||||
<a class="anchor" name="z10_2" doxytag="EO::printOn"></a><p>
|
||||
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
|
||||
<tr>
|
||||
<td class="mdRow">
|
||||
<table cellpadding="0" cellspacing="0" border="0">
|
||||
<tr>
|
||||
<td class="md" colspan="4">
|
||||
template<class F> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="md" nowrap valign="top">virtual void <a class="el" href="class_e_o.html">EO</a>< F >::printOn </td>
|
||||
<td class="md" valign="top">( </td>
|
||||
<td class="md" nowrap valign="top">std::ostream & </td>
|
||||
<td class="mdname1" valign="top" nowrap> <em>_os</em> </td>
|
||||
<td class="md" valign="top"> ) </td>
|
||||
<td class="md" nowrap> const<code> [inline, virtual]</code></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<table cellspacing="5" cellpadding="0" border="0">
|
||||
<tr>
|
||||
<td>
|
||||
|
||||
</td>
|
||||
<td>
|
||||
|
||||
<p>
|
||||
Write object.
|
||||
<p>
|
||||
Called printOn since it prints the object _on_ a stream. <dl compact><dt><b>Parameters:</b></dt><dd>
|
||||
<table border="0" cellspacing="2" cellpadding="0">
|
||||
<tr><td valign="top"></td><td valign="top"><em>_os</em> </td><td>A std::ostream. </td></tr>
|
||||
</table>
|
||||
</dl>
|
||||
|
||||
<p>
|
||||
Implements <a class="el" href="classeo_printable.html#a1">eoPrintable</a>.
|
||||
<p>
|
||||
Reimplemented in <a class="el" href="classeo_vector.html#a4">eoVector< FitT, GeneType ></a>, <a class="el" href="classeo_es_full.html#a2">eoEsFull< Fit ></a>, <a class="el" href="classeo_es_simple.html#a2">eoEsSimple< Fit ></a>, <a class="el" href="classeo_es_stdev.html#a2">eoEsStdev< Fit ></a>, <a class="el" href="classeo_bit.html#a2">eoBit< FitT ></a>, <a class="el" href="classeo_parse_tree.html#a5">eoParseTree< FType, Node ></a>, <a class="el" href="classeo_external_e_o.html#a4">eoExternalEO< Fit, External ></a>, <a class="el" href="classeo_string.html#z24_1">eoString< fitnessT ></a>, <a class="el" href="struct_dummy.html#a1">Dummy</a>, <a class="el" href="struct_dummy.html#a2">Dummy</a>, <a class="el" href="struct_dummy.html#a3">Dummy</a>, <a class="el" href="struct_dummy.html#a4">Dummy</a>, <a class="el" href="classeo_vector.html#a4">eoVector< Fit, double ></a>, <a class="el" href="classeo_vector.html#a4">eoVector< FitT, double ></a>, and <a class="el" href="classeo_vector.html#a4">eoVector< FitT, bool ></a>.
|
||||
<p>
|
||||
Definition at line <a class="el" href="_e_o_8h-source.html#l00129">129</a> of file <a class="el" href="_e_o_8h-source.html">EO.h</a>.
|
||||
<p>
|
||||
Referenced by <a class="el" href="t-eo_gen_op_8cpp-source.html#l00041">Dummy::printOn()</a>, <a class="el" href="eo_vector_8h-source.html#l00096">eoVector< FitT, bool >::printOn()</a>, <a class="el" href="eo_string_8h-source.html#l00058">eoString< fitnessT >::printOn()</a>, <a class="el" href="eo_parse_tree_8h-source.html#l00114">eoParseTree< FType, Node >::printOn()</a>, <a class="el" href="eo_one_max_8h-source.html#l00052">eoOneMax< FitT >::printOn()</a>, <a class="el" href="eo_external_e_o_8h-source.html#l00069">eoExternalEO< Fit, External >::printOn()</a>, and <a class="el" href="eo_bit_8h-source.html#l00082">eoBit< FitT >::printOn()</a>. </td>
|
||||
</tr>
|
||||
</table>
|
||||
<hr>The documentation for this class was generated from the following files:<ul>
|
||||
<li><a class="el" href="_e_o_8h-source.html">EO.h</a><li><a class="el" href="fitness__traits_8cpp-source.html">fitness_traits.cpp</a></ul>
|
||||
<hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:47 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>
|
||||
BIN
trunk/paradiseo-eo/doc/html/class_e_o.png
Normal file
|
After Width: | Height: | Size: 615 B |
22
trunk/paradiseo-eo/doc/html/class_mem_pool-members.html
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
<!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: Member List</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>
|
||||
<h1>MemPool Member List</h1>This is the complete list of members for <a class="el" href="class_mem_pool.html">MemPool</a>, including all inherited members.<p><table>
|
||||
<tr bgcolor="#f0f0f0"><td><b>allocate</b>() (defined in <a class="el" href="class_mem_pool.html">MemPool</a>)</td><td><a class="el" href="class_mem_pool.html">MemPool</a></td><td><code> [inline]</code></td></tr>
|
||||
<tr bgcolor="#f0f0f0"><td><b>chunks</b> (defined in <a class="el" href="class_mem_pool.html">MemPool</a>)</td><td><a class="el" href="class_mem_pool.html">MemPool</a></td><td><code> [private]</code></td></tr>
|
||||
<tr bgcolor="#f0f0f0"><td><b>deallocate</b>(void *b) (defined in <a class="el" href="class_mem_pool.html">MemPool</a>)</td><td><a class="el" href="class_mem_pool.html">MemPool</a></td><td><code> [inline]</code></td></tr>
|
||||
<tr bgcolor="#f0f0f0"><td><b>esize</b> (defined in <a class="el" href="class_mem_pool.html">MemPool</a>)</td><td><a class="el" href="class_mem_pool.html">MemPool</a></td><td><code> [private]</code></td></tr>
|
||||
<tr bgcolor="#f0f0f0"><td><b>grow</b>() (defined in <a class="el" href="class_mem_pool.html">MemPool</a>)</td><td><a class="el" href="class_mem_pool.html">MemPool</a></td><td><code> [inline, private]</code></td></tr>
|
||||
<tr bgcolor="#f0f0f0"><td><b>head</b> (defined in <a class="el" href="class_mem_pool.html">MemPool</a>)</td><td><a class="el" href="class_mem_pool.html">MemPool</a></td><td><code> [private]</code></td></tr>
|
||||
<tr bgcolor="#f0f0f0"><td><b>MemPool</b>(unsigned int sz) (defined in <a class="el" href="class_mem_pool.html">MemPool</a>)</td><td><a class="el" href="class_mem_pool.html">MemPool</a></td><td><code> [inline]</code></td></tr>
|
||||
<tr bgcolor="#f0f0f0"><td><b>~MemPool</b>() (defined in <a class="el" href="class_mem_pool.html">MemPool</a>)</td><td><a class="el" href="class_mem_pool.html">MemPool</a></td><td><code> [inline]</code></td></tr>
|
||||
</table><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:50 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>
|
||||
55
trunk/paradiseo-eo/doc/html/class_mem_pool.html
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
<!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: MemPool Class Reference</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>
|
||||
<h1>MemPool Class Reference</h1>Pool allocator for the subtree and parse tree classes (homebrew and not compliant to ANSI allocator requirements) (c) copyright Maarten Keijzer 1999, 2000.
|
||||
<a href="#_details">More...</a>
|
||||
<p>
|
||||
<code>#include <<a class="el" href="node__pool_8h-source.html">node_pool.h</a>></code>
|
||||
<p>
|
||||
<a href="class_mem_pool-members.html">List of all members.</a><table border="0" cellpadding="0" cellspacing="0">
|
||||
<tr><td></td></tr>
|
||||
<tr><td colspan="2"><br><h2>Public Member Functions</h2></td></tr>
|
||||
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a0" doxytag="MemPool::MemPool"></a>
|
||||
</td><td class="memItemRight" valign="bottom"><b>MemPool</b> (unsigned int sz)</td></tr>
|
||||
|
||||
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a2" doxytag="MemPool::allocate"></a>
|
||||
void * </td><td class="memItemRight" valign="bottom"><b>allocate</b> ()</td></tr>
|
||||
|
||||
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a3" doxytag="MemPool::deallocate"></a>
|
||||
void </td><td class="memItemRight" valign="bottom"><b>deallocate</b> (void *b)</td></tr>
|
||||
|
||||
<tr><td colspan="2"><br><h2>Private Member Functions</h2></td></tr>
|
||||
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="d0" doxytag="MemPool::grow"></a>
|
||||
void </td><td class="memItemRight" valign="bottom"><b>grow</b> ()</td></tr>
|
||||
|
||||
<tr><td colspan="2"><br><h2>Private Attributes</h2></td></tr>
|
||||
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="r0" doxytag="MemPool::chunks"></a>
|
||||
Chunk * </td><td class="memItemRight" valign="bottom"><b>chunks</b></td></tr>
|
||||
|
||||
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="r1" doxytag="MemPool::esize"></a>
|
||||
const unsigned int </td><td class="memItemRight" valign="bottom"><b>esize</b></td></tr>
|
||||
|
||||
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="r2" doxytag="MemPool::head"></a>
|
||||
Link * </td><td class="memItemRight" valign="bottom"><b>head</b></td></tr>
|
||||
|
||||
</table>
|
||||
<hr><a name="_details"></a><h2>Detailed Description</h2>
|
||||
Pool allocator for the subtree and parse tree classes (homebrew and not compliant to ANSI allocator requirements) (c) copyright Maarten Keijzer 1999, 2000.
|
||||
<p>
|
||||
Permission to copy, use, modify, sell and distribute this software is granted provided this copyright notice appears in all copies. This software is provided "as is" without express or implied warranty, and with no claim as to its suitability for any purpose.<p>
|
||||
Permission to modify the code and to distribute modified code is granted, provided the above notices are retained, and a notice that the code was modified is included with the above copyright notice.
|
||||
<p>
|
||||
|
||||
<p>
|
||||
Definition at line <a class="el" href="node__pool_8h-source.html#l00021">21</a> of file <a class="el" href="node__pool_8h-source.html">node_pool.h</a>.<hr>The documentation for this class was generated from the following file:<ul>
|
||||
<li><a class="el" href="node__pool_8h-source.html">node_pool.h</a></ul>
|
||||
<hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:50 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>
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
<!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: Member List</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>
|
||||
<h1>MinimizingTraits Member List</h1>This is the complete list of members for <a class="el" href="class_minimizing_traits.html">MinimizingTraits</a>, including all inherited members.<p><table>
|
||||
<tr bgcolor="#f0f0f0"><td><b>maximizing</b>(int) (defined in <a class="el" href="class_minimizing_traits.html">MinimizingTraits</a>)</td><td><a class="el" href="class_minimizing_traits.html">MinimizingTraits</a></td><td><code> [inline, static]</code></td></tr>
|
||||
<tr bgcolor="#f0f0f0"><td><b>nObjectives</b>() (defined in <a class="el" href="classeo_pareto_fitness_traits.html">eoParetoFitnessTraits</a>)</td><td><a class="el" href="classeo_pareto_fitness_traits.html">eoParetoFitnessTraits</a></td><td><code> [inline, static]</code></td></tr>
|
||||
<tr bgcolor="#f0f0f0"><td><b>tol</b>() (defined in <a class="el" href="classeo_pareto_fitness_traits.html">eoParetoFitnessTraits</a>)</td><td><a class="el" href="classeo_pareto_fitness_traits.html">eoParetoFitnessTraits</a></td><td><code> [inline, static]</code></td></tr>
|
||||
</table><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:51 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>
|
||||
35
trunk/paradiseo-eo/doc/html/class_minimizing_traits.html
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
<!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: MinimizingTraits Class Reference</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>
|
||||
<h1>MinimizingTraits Class Reference</h1>test program for Pareto Fitness
|
||||
<a href="#_details">More...</a>
|
||||
<p>
|
||||
<p>Inheritance diagram for MinimizingTraits:
|
||||
<p><center><img src="class_minimizing_traits.png" usemap="#MinimizingTraits_map" border="0" alt=""></center>
|
||||
<map name="MinimizingTraits_map">
|
||||
<area href="classeo_pareto_fitness_traits.html" alt="eoParetoFitnessTraits" shape="rect" coords="0,0,134,24">
|
||||
</map>
|
||||
<a href="class_minimizing_traits-members.html">List of all members.</a><table border="0" cellpadding="0" cellspacing="0">
|
||||
<tr><td></td></tr>
|
||||
<tr><td colspan="2"><br><h2>Static Public Member Functions</h2></td></tr>
|
||||
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="e0" doxytag="MinimizingTraits::maximizing"></a>
|
||||
bool </td><td class="memItemRight" valign="bottom"><b>maximizing</b> (int)</td></tr>
|
||||
|
||||
</table>
|
||||
<hr><a name="_details"></a><h2>Detailed Description</h2>
|
||||
test program for Pareto Fitness
|
||||
<p>
|
||||
|
||||
<p>
|
||||
Definition at line <a class="el" href="t-eo_pareto_fitness_8cpp-source.html#l00036">36</a> of file <a class="el" href="t-eo_pareto_fitness_8cpp-source.html">t-eoParetoFitness.cpp</a>.<hr>The documentation for this class was generated from the following file:<ul>
|
||||
<li><a class="el" href="t-eo_pareto_fitness_8cpp-source.html">t-eoParetoFitness.cpp</a></ul>
|
||||
<hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:51 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>
|
||||
BIN
trunk/paradiseo-eo/doc/html/class_minimizing_traits.png
Normal file
|
After Width: | Height: | Size: 486 B |
16
trunk/paradiseo-eo/doc/html/class_node_selector-members.html
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
<!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: Member List</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>
|
||||
<h1>NodeSelector Member List</h1>This is the complete list of members for <a class="el" href="class_node_selector.html">NodeSelector</a>, including all inherited members.<p><table>
|
||||
<tr bgcolor="#f0f0f0"><td><b>select_node</b>(Sym sym) const =0 (defined in <a class="el" href="class_node_selector.html">NodeSelector</a>)</td><td><a class="el" href="class_node_selector.html">NodeSelector</a></td><td><code> [pure virtual]</code></td></tr>
|
||||
<tr bgcolor="#f0f0f0"><td><b>~NodeSelector</b>() (defined in <a class="el" href="class_node_selector.html">NodeSelector</a>)</td><td><a class="el" href="class_node_selector.html">NodeSelector</a></td><td><code> [inline, virtual]</code></td></tr>
|
||||
</table><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:51 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>
|
||||
38
trunk/paradiseo-eo/doc/html/class_node_selector.html
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
<!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: NodeSelector Class Reference</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>
|
||||
<h1>NodeSelector Class Reference</h1>Base class for selecting nodes.
|
||||
<a href="#_details">More...</a>
|
||||
<p>
|
||||
<code>#include <<a class="el" href="_node_selector_8h-source.html">NodeSelector.h</a>></code>
|
||||
<p>
|
||||
<p>Inheritance diagram for NodeSelector:
|
||||
<p><center><img src="class_node_selector.png" usemap="#NodeSelector_map" border="0" alt=""></center>
|
||||
<map name="NodeSelector_map">
|
||||
<area href="class_biased_node_selector.html" alt="BiasedNodeSelector" shape="rect" coords="0,56,134,80">
|
||||
<area href="class_random_node_selector.html" alt="RandomNodeSelector" shape="rect" coords="144,56,278,80">
|
||||
</map>
|
||||
<a href="class_node_selector-members.html">List of all members.</a><table border="0" cellpadding="0" cellspacing="0">
|
||||
<tr><td></td></tr>
|
||||
<tr><td colspan="2"><br><h2>Public Member Functions</h2></td></tr>
|
||||
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a1" doxytag="NodeSelector::select_node"></a>
|
||||
virtual NodeSelection </td><td class="memItemRight" valign="bottom"><b>select_node</b> (Sym sym) const =0</td></tr>
|
||||
|
||||
</table>
|
||||
<hr><a name="_details"></a><h2>Detailed Description</h2>
|
||||
Base class for selecting nodes.
|
||||
<p>
|
||||
|
||||
<p>
|
||||
Definition at line <a class="el" href="_node_selector_8h-source.html#l00024">24</a> of file <a class="el" href="_node_selector_8h-source.html">NodeSelector.h</a>.<hr>The documentation for this class was generated from the following file:<ul>
|
||||
<li><a class="el" href="_node_selector_8h-source.html">NodeSelector.h</a></ul>
|
||||
<hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:51 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>
|
||||
BIN
trunk/paradiseo-eo/doc/html/class_node_selector.png
Normal file
|
After Width: | Height: | Size: 629 B |
|
|
@ -0,0 +1,16 @@
|
|||
<!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: Member List</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>
|
||||
<h1>RandomNodeSelector Member List</h1>This is the complete list of members for <a class="el" href="class_random_node_selector.html">RandomNodeSelector</a>, including all inherited members.<p><table>
|
||||
<tr bgcolor="#f0f0f0"><td><b>select_node</b>(Sym sym) const (defined in <a class="el" href="class_random_node_selector.html">RandomNodeSelector</a>)</td><td><a class="el" href="class_random_node_selector.html">RandomNodeSelector</a></td><td><code> [virtual]</code></td></tr>
|
||||
<tr bgcolor="#f0f0f0"><td><b>~NodeSelector</b>() (defined in <a class="el" href="class_node_selector.html">NodeSelector</a>)</td><td><a class="el" href="class_node_selector.html">NodeSelector</a></td><td><code> [inline, virtual]</code></td></tr>
|
||||
</table><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:54 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>
|
||||
37
trunk/paradiseo-eo/doc/html/class_random_node_selector.html
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
<!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: RandomNodeSelector Class Reference</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>
|
||||
<h1>RandomNodeSelector Class Reference</h1>Select nodes uniformly.
|
||||
<a href="#_details">More...</a>
|
||||
<p>
|
||||
<code>#include <<a class="el" href="_node_selector_8h-source.html">NodeSelector.h</a>></code>
|
||||
<p>
|
||||
<p>Inheritance diagram for RandomNodeSelector:
|
||||
<p><center><img src="class_random_node_selector.png" usemap="#RandomNodeSelector_map" border="0" alt=""></center>
|
||||
<map name="RandomNodeSelector_map">
|
||||
<area href="class_node_selector.html" alt="NodeSelector" shape="rect" coords="0,0,134,24">
|
||||
</map>
|
||||
<a href="class_random_node_selector-members.html">List of all members.</a><table border="0" cellpadding="0" cellspacing="0">
|
||||
<tr><td></td></tr>
|
||||
<tr><td colspan="2"><br><h2>Public Member Functions</h2></td></tr>
|
||||
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a0" doxytag="RandomNodeSelector::select_node"></a>
|
||||
NodeSelection </td><td class="memItemRight" valign="bottom"><b>select_node</b> (Sym sym) const </td></tr>
|
||||
|
||||
</table>
|
||||
<hr><a name="_details"></a><h2>Detailed Description</h2>
|
||||
Select nodes uniformly.
|
||||
<p>
|
||||
|
||||
<p>
|
||||
Definition at line <a class="el" href="_node_selector_8h-source.html#l00049">49</a> of file <a class="el" href="_node_selector_8h-source.html">NodeSelector.h</a>.<hr>The documentation for this class was generated from the following files:<ul>
|
||||
<li><a class="el" href="_node_selector_8h-source.html">NodeSelector.h</a><li><a class="el" href="_node_selector_8cpp-source.html">NodeSelector.cpp</a></ul>
|
||||
<hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:54 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>
|
||||
BIN
trunk/paradiseo-eo/doc/html/class_random_node_selector.png
Normal file
|
After Width: | Height: | Size: 454 B |
|
|
@ -0,0 +1,17 @@
|
|||
<!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: Member List</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>
|
||||
<h1>UF_random_generator< T > Member List</h1>This is the complete list of members for <a class="el" href="class_u_f__random__generator.html">UF_random_generator< T ></a>, including all inherited members.<p><table>
|
||||
<tr bgcolor="#f0f0f0"><td><b>operator()</b>(T _t) (defined in <a class="el" href="class_u_f__random__generator.html">UF_random_generator< T ></a>)</td><td><a class="el" href="class_u_f__random__generator.html">UF_random_generator< T ></a></td><td><code> [inline]</code></td></tr>
|
||||
<tr bgcolor="#f0f0f0"><td><b>random</b> (defined in <a class="el" href="class_u_f__random__generator.html">UF_random_generator< T ></a>)</td><td><a class="el" href="class_u_f__random__generator.html">UF_random_generator< T ></a></td><td><code> [private]</code></td></tr>
|
||||
<tr bgcolor="#f0f0f0"><td><b>UF_random_generator</b>(eoRng &_rng=rng) (defined in <a class="el" href="class_u_f__random__generator.html">UF_random_generator< T ></a>)</td><td><a class="el" href="class_u_f__random__generator.html">UF_random_generator< T ></a></td><td><code> [inline]</code></td></tr>
|
||||
</table><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:57 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>
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
<!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: UF_random_generator< T > Class Template Reference</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>
|
||||
<h1>UF_random_generator< T > Class Template Reference</h1>Another class <a class="el" href="classrandom__generator.html">random_generator</a> that can be used in the STL random_shuffle function (see <a class="el" href="classeo_pop.html#a7">eoPop::shuffle</a>): its operator() takes an unsigned argument m and must return an unsigned uniformly distributed in [0,m}.
|
||||
<a href="#_details">More...</a>
|
||||
<p>
|
||||
<code>#include <<a class="el" href="rnd__generators_8h-source.html">rnd_generators.h</a>></code>
|
||||
<p>
|
||||
<a href="class_u_f__random__generator-members.html">List of all members.</a><table border="0" cellpadding="0" cellspacing="0">
|
||||
<tr><td></td></tr>
|
||||
<tr><td colspan="2"><br><h2>Public Member Functions</h2></td></tr>
|
||||
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a0" doxytag="UF_random_generator::UF_random_generator"></a>
|
||||
</td><td class="memItemRight" valign="bottom"><b>UF_random_generator</b> (<a class="el" href="classeo_rng.html">eoRng</a> &_rng=rng)</td></tr>
|
||||
|
||||
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a1" doxytag="UF_random_generator::operator()"></a>
|
||||
T </td><td class="memItemRight" valign="bottom"><b>operator()</b> (T _t)</td></tr>
|
||||
|
||||
<tr><td colspan="2"><br><h2>Private Attributes</h2></td></tr>
|
||||
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="r0" doxytag="UF_random_generator::random"></a>
|
||||
<a class="el" href="classeo_rng.html">eoRng</a> & </td><td class="memItemRight" valign="bottom"><b>random</b></td></tr>
|
||||
|
||||
</table>
|
||||
<hr><a name="_details"></a><h2>Detailed Description</h2>
|
||||
<h3>template<class T = uint32_t><br>
|
||||
class UF_random_generator< T ></h3>
|
||||
|
||||
Another class <a class="el" href="classrandom__generator.html">random_generator</a> that can be used in the STL random_shuffle function (see <a class="el" href="classeo_pop.html#a7">eoPop::shuffle</a>): its operator() takes an unsigned argument m and must return an unsigned uniformly distributed in [0,m}.
|
||||
<p>
|
||||
|
||||
<p>
|
||||
Definition at line <a class="el" href="rnd__generators_8h-source.html#l00121">121</a> of file <a class="el" href="rnd__generators_8h-source.html">rnd_generators.h</a>.<hr>The documentation for this class was generated from the following file:<ul>
|
||||
<li><a class="el" href="rnd__generators_8h-source.html">rnd_generators.h</a></ul>
|
||||
<hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:57 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>
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
<!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: Member List</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>
|
||||
<h1>VirusBitFlip< FitT > Member List</h1>This is the complete list of members for <a class="el" href="class_virus_bit_flip.html">VirusBitFlip< FitT ></a>, including all inherited members.<p><table>
|
||||
<tr bgcolor="#f0f0f0"><td><b>binary</b> enum value (defined in <a class="el" href="classeo_op.html">eoOp< eoVirus< FitT > ></a>)</td><td><a class="el" href="classeo_op.html">eoOp< eoVirus< FitT > ></a></td><td></td></tr>
|
||||
<tr class="memlist"><td><a class="el" href="class_virus_bit_flip.html#a0">className</a>() const </td><td><a class="el" href="class_virus_bit_flip.html">VirusBitFlip< FitT ></a></td><td><code> [inline, virtual]</code></td></tr>
|
||||
<tr class="memlist"><td><a class="el" href="classeo_mon_op.html#a0">eoMonOp</a>()</td><td><a class="el" href="classeo_mon_op.html">eoMonOp< eoVirus< FitT > ></a></td><td><code> [inline]</code></td></tr>
|
||||
<tr class="memlist"><td><a class="el" href="classeo_op.html#z14_1">eoOp</a>(OpType _type)</td><td><a class="el" href="classeo_op.html">eoOp< eoVirus< FitT > ></a></td><td><code> [inline]</code></td></tr>
|
||||
<tr class="memlist"><td><a class="el" href="classeo_op.html#z14_2">eoOp</a>(const eoOp &_eop)</td><td><a class="el" href="classeo_op.html">eoOp< eoVirus< FitT > ></a></td><td><code> [inline]</code></td></tr>
|
||||
<tr class="memlist"><td><a class="el" href="classeo_u_f.html#e0">functor_category</a>()</td><td><a class="el" href="classeo_u_f.html">eoUF< eoVirus< FitT > &, bool ></a></td><td><code> [inline, static]</code></td></tr>
|
||||
<tr bgcolor="#f0f0f0"><td><b>general</b> enum value (defined in <a class="el" href="classeo_op.html">eoOp< eoVirus< FitT > ></a>)</td><td><a class="el" href="classeo_op.html">eoOp< eoVirus< FitT > ></a></td><td></td></tr>
|
||||
<tr class="memlist"><td><a class="el" href="classeo_op.html#z14_4">getType</a>() const </td><td><a class="el" href="classeo_op.html">eoOp< eoVirus< FitT > ></a></td><td><code> [inline]</code></td></tr>
|
||||
<tr class="memlist"><td><a class="el" href="class_virus_bit_flip.html#a1">operator()</a>(eoVirus< FitT > &_chrom)</td><td><a class="el" href="class_virus_bit_flip.html">VirusBitFlip< FitT ></a></td><td><code> [inline, virtual]</code></td></tr>
|
||||
<tr bgcolor="#f0f0f0"><td><b>quadratic</b> enum value (defined in <a class="el" href="classeo_op.html">eoOp< eoVirus< FitT > ></a>)</td><td><a class="el" href="classeo_op.html">eoOp< eoVirus< FitT > ></a></td><td></td></tr>
|
||||
<tr bgcolor="#f0f0f0"><td><b>unary</b> enum value (defined in <a class="el" href="classeo_op.html">eoOp< eoVirus< FitT > ></a>)</td><td><a class="el" href="classeo_op.html">eoOp< eoVirus< FitT > ></a></td><td></td></tr>
|
||||
<tr class="memlist"><td><a class="el" href="classeo_functor_base.html#a0">~eoFunctorBase</a>()</td><td><a class="el" href="classeo_functor_base.html">eoFunctorBase</a></td><td><code> [inline, virtual]</code></td></tr>
|
||||
<tr class="memlist"><td><a class="el" href="classeo_op.html#z14_3">~eoOp</a>()</td><td><a class="el" href="classeo_op.html">eoOp< eoVirus< FitT > ></a></td><td><code> [inline, virtual]</code></td></tr>
|
||||
<tr class="memlist"><td><a class="el" href="classeo_u_f.html#a0">~eoUF</a>()</td><td><a class="el" href="classeo_u_f.html">eoUF< eoVirus< FitT > &, bool ></a></td><td><code> [inline, virtual]</code></td></tr>
|
||||
</table><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:59 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>
|
||||
91
trunk/paradiseo-eo/doc/html/class_virus_bit_flip.html
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
<!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: VirusBitFlip< FitT > Class Template Reference</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>
|
||||
<h1>VirusBitFlip< FitT > Class Template Reference</h1>VirusBitFlip --> changes 1 bit.
|
||||
<a href="#_details">More...</a>
|
||||
<p>
|
||||
<code>#include <<a class="el" href="_virus_op_8h-source.html">VirusOp.h</a>></code>
|
||||
<p>
|
||||
<p>Inheritance diagram for VirusBitFlip< FitT >:
|
||||
<p><center><img src="class_virus_bit_flip.png" usemap="#VirusBitFlip< FitT >_map" border="0" alt=""></center>
|
||||
<map name="VirusBitFlip< FitT >_map">
|
||||
<area href="classeo_mon_op.html" alt="eoMonOp< eoVirus< FitT > >" shape="rect" coords="133,112,390,136">
|
||||
<area href="classeo_op.html" alt="eoOp< eoVirus< FitT > >" shape="rect" coords="0,56,257,80">
|
||||
<area href="classeo_u_f.html" alt="eoUF< eoVirus< FitT > &, bool >" shape="rect" coords="267,56,524,80">
|
||||
<area href="classeo_functor_base.html" alt="eoFunctorBase" shape="rect" coords="133,0,390,24">
|
||||
</map>
|
||||
<a href="class_virus_bit_flip-members.html">List of all members.</a><table border="0" cellpadding="0" cellspacing="0">
|
||||
<tr><td></td></tr>
|
||||
<tr><td colspan="2"><br><h2>Public Member Functions</h2></td></tr>
|
||||
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a0" doxytag="VirusBitFlip::className"></a>
|
||||
virtual std::string </td><td class="memItemRight" valign="bottom"><a class="el" href="class_virus_bit_flip.html#a0">className</a> () const </td></tr>
|
||||
|
||||
<tr><td class="mdescLeft"> </td><td class="mdescRight">The class name. <br></td></tr>
|
||||
<tr><td class="memItemLeft" nowrap align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="class_virus_bit_flip.html#a1">operator()</a> (eoVirus< <a class="el" href="classeo_scalar_fitness.html">FitT</a> > &_chrom)</td></tr>
|
||||
|
||||
<tr><td class="mdescLeft"> </td><td class="mdescRight">Change one bit. <a href="#a1"></a><br></td></tr>
|
||||
</table>
|
||||
<hr><a name="_details"></a><h2>Detailed Description</h2>
|
||||
<h3>template<class FitT><br>
|
||||
class VirusBitFlip< FitT ></h3>
|
||||
|
||||
VirusBitFlip --> changes 1 bit.
|
||||
<p>
|
||||
|
||||
<p>
|
||||
Definition at line <a class="el" href="_virus_op_8h-source.html#l00040">40</a> of file <a class="el" href="_virus_op_8h-source.html">VirusOp.h</a>.<hr><h2>Member Function Documentation</h2>
|
||||
<a class="anchor" name="a1" doxytag="VirusBitFlip::operator()"></a><p>
|
||||
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
|
||||
<tr>
|
||||
<td class="mdRow">
|
||||
<table cellpadding="0" cellspacing="0" border="0">
|
||||
<tr>
|
||||
<td class="md" colspan="4">
|
||||
template<class FitT> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="md" nowrap valign="top">bool <a class="el" href="class_virus_bit_flip.html">VirusBitFlip</a>< <a class="el" href="classeo_scalar_fitness.html">FitT</a> >::operator() </td>
|
||||
<td class="md" valign="top">( </td>
|
||||
<td class="md" nowrap valign="top">eoVirus< <a class="el" href="classeo_scalar_fitness.html">FitT</a> > & </td>
|
||||
<td class="mdname1" valign="top" nowrap> <em>_chrom</em> </td>
|
||||
<td class="md" valign="top"> ) </td>
|
||||
<td class="md" nowrap><code> [inline, virtual]</code></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<table cellspacing="5" cellpadding="0" border="0">
|
||||
<tr>
|
||||
<td>
|
||||
|
||||
</td>
|
||||
<td>
|
||||
|
||||
<p>
|
||||
Change one bit.
|
||||
<p>
|
||||
<dl compact><dt><b>Parameters:</b></dt><dd>
|
||||
<table border="0" cellspacing="2" cellpadding="0">
|
||||
<tr><td valign="top"></td><td valign="top"><em>chrom</em> </td><td>The cromosome which one bit is going to be changed. </td></tr>
|
||||
</table>
|
||||
</dl>
|
||||
|
||||
<p>
|
||||
Implements <a class="el" href="classeo_u_f.html#a1">eoUF< eoVirus< FitT > &, bool ></a>.
|
||||
<p>
|
||||
Definition at line <a class="el" href="_virus_op_8h-source.html#l00049">49</a> of file <a class="el" href="_virus_op_8h-source.html">VirusOp.h</a>. </td>
|
||||
</tr>
|
||||
</table>
|
||||
<hr>The documentation for this class was generated from the following file:<ul>
|
||||
<li><a class="el" href="_virus_op_8h-source.html">VirusOp.h</a></ul>
|
||||
<hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:59 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>
|
||||
BIN
trunk/paradiseo-eo/doc/html/class_virus_bit_flip.png
Normal file
|
After Width: | Height: | Size: 1.7 KiB |
|
|
@ -0,0 +1,29 @@
|
|||
<!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: Member List</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>
|
||||
<h1>VirusShiftMutation< FitT > Member List</h1>This is the complete list of members for <a class="el" href="class_virus_shift_mutation.html">VirusShiftMutation< FitT ></a>, including all inherited members.<p><table>
|
||||
<tr bgcolor="#f0f0f0"><td><b>binary</b> enum value (defined in <a class="el" href="classeo_op.html">eoOp< eoVirus< FitT > ></a>)</td><td><a class="el" href="classeo_op.html">eoOp< eoVirus< FitT > ></a></td><td></td></tr>
|
||||
<tr class="memlist"><td><a class="el" href="class_virus_shift_mutation.html#a1">className</a>() const </td><td><a class="el" href="class_virus_shift_mutation.html">VirusShiftMutation< FitT ></a></td><td><code> [inline, virtual]</code></td></tr>
|
||||
<tr class="memlist"><td><a class="el" href="classeo_mon_op.html#a0">eoMonOp</a>()</td><td><a class="el" href="classeo_mon_op.html">eoMonOp< eoVirus< FitT > ></a></td><td><code> [inline]</code></td></tr>
|
||||
<tr class="memlist"><td><a class="el" href="classeo_op.html#z14_1">eoOp</a>(OpType _type)</td><td><a class="el" href="classeo_op.html">eoOp< eoVirus< FitT > ></a></td><td><code> [inline]</code></td></tr>
|
||||
<tr class="memlist"><td><a class="el" href="classeo_op.html#z14_2">eoOp</a>(const eoOp &_eop)</td><td><a class="el" href="classeo_op.html">eoOp< eoVirus< FitT > ></a></td><td><code> [inline]</code></td></tr>
|
||||
<tr class="memlist"><td><a class="el" href="classeo_u_f.html#e0">functor_category</a>()</td><td><a class="el" href="classeo_u_f.html">eoUF< eoVirus< FitT > &, bool ></a></td><td><code> [inline, static]</code></td></tr>
|
||||
<tr bgcolor="#f0f0f0"><td><b>general</b> enum value (defined in <a class="el" href="classeo_op.html">eoOp< eoVirus< FitT > ></a>)</td><td><a class="el" href="classeo_op.html">eoOp< eoVirus< FitT > ></a></td><td></td></tr>
|
||||
<tr class="memlist"><td><a class="el" href="classeo_op.html#z14_4">getType</a>() const </td><td><a class="el" href="classeo_op.html">eoOp< eoVirus< FitT > ></a></td><td><code> [inline]</code></td></tr>
|
||||
<tr class="memlist"><td><a class="el" href="class_virus_shift_mutation.html#a2">operator()</a>(eoVirus< FitT > &_chrom)</td><td><a class="el" href="class_virus_shift_mutation.html">VirusShiftMutation< FitT ></a></td><td><code> [inline, virtual]</code></td></tr>
|
||||
<tr bgcolor="#f0f0f0"><td><b>quadratic</b> enum value (defined in <a class="el" href="classeo_op.html">eoOp< eoVirus< FitT > ></a>)</td><td><a class="el" href="classeo_op.html">eoOp< eoVirus< FitT > ></a></td><td></td></tr>
|
||||
<tr bgcolor="#f0f0f0"><td><b>unary</b> enum value (defined in <a class="el" href="classeo_op.html">eoOp< eoVirus< FitT > ></a>)</td><td><a class="el" href="classeo_op.html">eoOp< eoVirus< FitT > ></a></td><td></td></tr>
|
||||
<tr class="memlist"><td><a class="el" href="class_virus_shift_mutation.html#a0">VirusShiftMutation</a>()</td><td><a class="el" href="class_virus_shift_mutation.html">VirusShiftMutation< FitT ></a></td><td><code> [inline]</code></td></tr>
|
||||
<tr class="memlist"><td><a class="el" href="classeo_functor_base.html#a0">~eoFunctorBase</a>()</td><td><a class="el" href="classeo_functor_base.html">eoFunctorBase</a></td><td><code> [inline, virtual]</code></td></tr>
|
||||
<tr class="memlist"><td><a class="el" href="classeo_op.html#z14_3">~eoOp</a>()</td><td><a class="el" href="classeo_op.html">eoOp< eoVirus< FitT > ></a></td><td><code> [inline, virtual]</code></td></tr>
|
||||
<tr class="memlist"><td><a class="el" href="classeo_u_f.html#a0">~eoUF</a>()</td><td><a class="el" href="classeo_u_f.html">eoUF< eoVirus< FitT > &, bool ></a></td><td><code> [inline, virtual]</code></td></tr>
|
||||
</table><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:07:00 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>
|
||||
95
trunk/paradiseo-eo/doc/html/class_virus_shift_mutation.html
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
<!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: VirusShiftMutation< FitT > Class Template Reference</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>
|
||||
<h1>VirusShiftMutation< FitT > Class Template Reference</h1>Works for 1-bit virus; shifts the one to the right or left.
|
||||
<a href="#_details">More...</a>
|
||||
<p>
|
||||
<code>#include <<a class="el" href="_virus_op_8h-source.html">VirusOp.h</a>></code>
|
||||
<p>
|
||||
<p>Inheritance diagram for VirusShiftMutation< FitT >:
|
||||
<p><center><img src="class_virus_shift_mutation.png" usemap="#VirusShiftMutation< FitT >_map" border="0" alt=""></center>
|
||||
<map name="VirusShiftMutation< FitT >_map">
|
||||
<area href="classeo_mon_op.html" alt="eoMonOp< eoVirus< FitT > >" shape="rect" coords="133,112,390,136">
|
||||
<area href="classeo_op.html" alt="eoOp< eoVirus< FitT > >" shape="rect" coords="0,56,257,80">
|
||||
<area href="classeo_u_f.html" alt="eoUF< eoVirus< FitT > &, bool >" shape="rect" coords="267,56,524,80">
|
||||
<area href="classeo_functor_base.html" alt="eoFunctorBase" shape="rect" coords="133,0,390,24">
|
||||
</map>
|
||||
<a href="class_virus_shift_mutation-members.html">List of all members.</a><table border="0" cellpadding="0" cellspacing="0">
|
||||
<tr><td></td></tr>
|
||||
<tr><td colspan="2"><br><h2>Public Member Functions</h2></td></tr>
|
||||
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a0" doxytag="VirusShiftMutation::VirusShiftMutation"></a>
|
||||
</td><td class="memItemRight" valign="bottom"><a class="el" href="class_virus_shift_mutation.html#a0">VirusShiftMutation</a> ()</td></tr>
|
||||
|
||||
<tr><td class="mdescLeft"> </td><td class="mdescRight">Ctor. <br></td></tr>
|
||||
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a1" doxytag="VirusShiftMutation::className"></a>
|
||||
virtual std::string </td><td class="memItemRight" valign="bottom"><a class="el" href="class_virus_shift_mutation.html#a1">className</a> () const </td></tr>
|
||||
|
||||
<tr><td class="mdescLeft"> </td><td class="mdescRight">The class name. <br></td></tr>
|
||||
<tr><td class="memItemLeft" nowrap align="right" valign="top">bool </td><td class="memItemRight" valign="bottom"><a class="el" href="class_virus_shift_mutation.html#a2">operator()</a> (eoVirus< <a class="el" href="classeo_scalar_fitness.html">FitT</a> > &_chrom)</td></tr>
|
||||
|
||||
<tr><td class="mdescLeft"> </td><td class="mdescRight">Change one bit. <a href="#a2"></a><br></td></tr>
|
||||
</table>
|
||||
<hr><a name="_details"></a><h2>Detailed Description</h2>
|
||||
<h3>template<class FitT><br>
|
||||
class VirusShiftMutation< FitT ></h3>
|
||||
|
||||
Works for 1-bit virus; shifts the one to the right or left.
|
||||
<p>
|
||||
|
||||
<p>
|
||||
Definition at line <a class="el" href="_virus_op_8h-source.html#l00086">86</a> of file <a class="el" href="_virus_op_8h-source.html">VirusOp.h</a>.<hr><h2>Member Function Documentation</h2>
|
||||
<a class="anchor" name="a2" doxytag="VirusShiftMutation::operator()"></a><p>
|
||||
<table class="mdTable" width="100%" cellpadding="2" cellspacing="0">
|
||||
<tr>
|
||||
<td class="mdRow">
|
||||
<table cellpadding="0" cellspacing="0" border="0">
|
||||
<tr>
|
||||
<td class="md" colspan="4">
|
||||
template<class FitT> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="md" nowrap valign="top">bool <a class="el" href="class_virus_shift_mutation.html">VirusShiftMutation</a>< <a class="el" href="classeo_scalar_fitness.html">FitT</a> >::operator() </td>
|
||||
<td class="md" valign="top">( </td>
|
||||
<td class="md" nowrap valign="top">eoVirus< <a class="el" href="classeo_scalar_fitness.html">FitT</a> > & </td>
|
||||
<td class="mdname1" valign="top" nowrap> <em>_chrom</em> </td>
|
||||
<td class="md" valign="top"> ) </td>
|
||||
<td class="md" nowrap><code> [inline, virtual]</code></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<table cellspacing="5" cellpadding="0" border="0">
|
||||
<tr>
|
||||
<td>
|
||||
|
||||
</td>
|
||||
<td>
|
||||
|
||||
<p>
|
||||
Change one bit.
|
||||
<p>
|
||||
<dl compact><dt><b>Parameters:</b></dt><dd>
|
||||
<table border="0" cellspacing="2" cellpadding="0">
|
||||
<tr><td valign="top"></td><td valign="top"><em>chrom</em> </td><td>The cromosome which one bit is going to be changed. </td></tr>
|
||||
</table>
|
||||
</dl>
|
||||
|
||||
<p>
|
||||
Implements <a class="el" href="classeo_u_f.html#a1">eoUF< eoVirus< FitT > &, bool ></a>.
|
||||
<p>
|
||||
Definition at line <a class="el" href="_virus_op_8h-source.html#l00099">99</a> of file <a class="el" href="_virus_op_8h-source.html">VirusOp.h</a>. </td>
|
||||
</tr>
|
||||
</table>
|
||||
<hr>The documentation for this class was generated from the following file:<ul>
|
||||
<li><a class="el" href="_virus_op_8h-source.html">VirusOp.h</a></ul>
|
||||
<hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:07:00 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>
|
||||
BIN
trunk/paradiseo-eo/doc/html/class_virus_shift_mutation.png
Normal file
|
After Width: | Height: | Size: 1.8 KiB |
|
|
@ -0,0 +1,18 @@
|
|||
<!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: Member List</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>
|
||||
<h1>boolean_generator Member List</h1>This is the complete list of members for <a class="el" href="classboolean__generator.html">boolean_generator</a>, including all inherited members.<p><table>
|
||||
<tr bgcolor="#f0f0f0"><td><b>bias</b> (defined in <a class="el" href="classboolean__generator.html">boolean_generator</a>)</td><td><a class="el" href="classboolean__generator.html">boolean_generator</a></td><td><code> [private]</code></td></tr>
|
||||
<tr bgcolor="#f0f0f0"><td><b>boolean_generator</b>(float _bias=0.5, eoRng &_rng=rng) (defined in <a class="el" href="classboolean__generator.html">boolean_generator</a>)</td><td><a class="el" href="classboolean__generator.html">boolean_generator</a></td><td><code> [inline]</code></td></tr>
|
||||
<tr bgcolor="#f0f0f0"><td><b>gen</b> (defined in <a class="el" href="classboolean__generator.html">boolean_generator</a>)</td><td><a class="el" href="classboolean__generator.html">boolean_generator</a></td><td><code> [private]</code></td></tr>
|
||||
<tr bgcolor="#f0f0f0"><td><b>operator()</b>(void) (defined in <a class="el" href="classboolean__generator.html">boolean_generator</a>)</td><td><a class="el" href="classboolean__generator.html">boolean_generator</a></td><td><code> [inline]</code></td></tr>
|
||||
</table><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:45 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>
|
||||
42
trunk/paradiseo-eo/doc/html/classboolean__generator.html
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
<!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: boolean_generator Class Reference</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>
|
||||
<h1>boolean_generator Class Reference</h1>The class boolean_generator can be used in the STL generate function to easily generate random booleans with a specified bias.
|
||||
<a href="#_details">More...</a>
|
||||
<p>
|
||||
<code>#include <<a class="el" href="rnd__generators_8h-source.html">rnd_generators.h</a>></code>
|
||||
<p>
|
||||
<a href="classboolean__generator-members.html">List of all members.</a><table border="0" cellpadding="0" cellspacing="0">
|
||||
<tr><td></td></tr>
|
||||
<tr><td colspan="2"><br><h2>Public Member Functions</h2></td></tr>
|
||||
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a0" doxytag="boolean_generator::boolean_generator"></a>
|
||||
</td><td class="memItemRight" valign="bottom"><b>boolean_generator</b> (float _bias=0.5, <a class="el" href="classeo_rng.html">eoRng</a> &_rng=rng)</td></tr>
|
||||
|
||||
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a1" doxytag="boolean_generator::operator()"></a>
|
||||
bool </td><td class="memItemRight" valign="bottom"><b>operator()</b> (void)</td></tr>
|
||||
|
||||
<tr><td colspan="2"><br><h2>Private Attributes</h2></td></tr>
|
||||
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="r0" doxytag="boolean_generator::bias"></a>
|
||||
float </td><td class="memItemRight" valign="bottom"><b>bias</b></td></tr>
|
||||
|
||||
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="r1" doxytag="boolean_generator::gen"></a>
|
||||
<a class="el" href="classeo_rng.html">eoRng</a> & </td><td class="memItemRight" valign="bottom"><b>gen</b></td></tr>
|
||||
|
||||
</table>
|
||||
<hr><a name="_details"></a><h2>Detailed Description</h2>
|
||||
The class boolean_generator can be used in the STL generate function to easily generate random booleans with a specified bias.
|
||||
<p>
|
||||
|
||||
<p>
|
||||
Definition at line <a class="el" href="rnd__generators_8h-source.html#l00070">70</a> of file <a class="el" href="rnd__generators_8h-source.html">rnd_generators.h</a>.<hr>The documentation for this class was generated from the following file:<ul>
|
||||
<li><a class="el" href="rnd__generators_8h-source.html">rnd_generators.h</a></ul>
|
||||
<hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:45 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>
|
||||
19
trunk/paradiseo-eo/doc/html/classd_matrix-members.html
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
<!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: Member List</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>
|
||||
<h1>dMatrix Member List</h1>This is the complete list of members for <a class="el" href="classd_matrix.html">dMatrix</a>, including all inherited members.<p><table>
|
||||
<tr bgcolor="#f0f0f0"><td><b>dMatrix</b>(unsigned _s) (defined in <a class="el" href="classd_matrix.html">dMatrix</a>)</td><td><a class="el" href="classd_matrix.html">dMatrix</a></td><td><code> [inline]</code></td></tr>
|
||||
<tr class="memlist"><td><a class="el" href="classd_matrix.html#a1">operator()</a>(unsigned _i, unsigned _j) const </td><td><a class="el" href="classd_matrix.html">dMatrix</a></td><td><code> [inline]</code></td></tr>
|
||||
<tr class="memlist"><td><a class="el" href="classd_matrix.html#a2">operator()</a>(unsigned _i, unsigned _j)</td><td><a class="el" href="classd_matrix.html">dMatrix</a></td><td><code> [inline]</code></td></tr>
|
||||
<tr class="memlist"><td><a class="el" href="classd_matrix.html#a3">printOn</a>(std::ostream &_os)</td><td><a class="el" href="classd_matrix.html">dMatrix</a></td><td><code> [inline]</code></td></tr>
|
||||
<tr bgcolor="#f0f0f0"><td><b>rSize</b> (defined in <a class="el" href="classd_matrix.html">dMatrix</a>)</td><td><a class="el" href="classd_matrix.html">dMatrix</a></td><td><code> [private]</code></td></tr>
|
||||
</table><hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:46 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>
|
||||
48
trunk/paradiseo-eo/doc/html/classd_matrix.html
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
<!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: dMatrix Class Reference</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>
|
||||
<h1>dMatrix Class Reference</h1>A helper class for Sharing - to hold distances.
|
||||
<a href="#_details">More...</a>
|
||||
<p>
|
||||
<code>#include <<a class="el" href="eo_sharing_8h-source.html">eoSharing.h</a>></code>
|
||||
<p>
|
||||
<a href="classd_matrix-members.html">List of all members.</a><table border="0" cellpadding="0" cellspacing="0">
|
||||
<tr><td></td></tr>
|
||||
<tr><td colspan="2"><br><h2>Public Member Functions</h2></td></tr>
|
||||
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a0" doxytag="dMatrix::dMatrix"></a>
|
||||
</td><td class="memItemRight" valign="bottom"><b>dMatrix</b> (unsigned _s)</td></tr>
|
||||
|
||||
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a1" doxytag="dMatrix::operator()"></a>
|
||||
double </td><td class="memItemRight" valign="bottom"><a class="el" href="classd_matrix.html#a1">operator()</a> (unsigned _i, unsigned _j) const </td></tr>
|
||||
|
||||
<tr><td class="mdescLeft"> </td><td class="mdescRight">simple accessor <br></td></tr>
|
||||
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a2" doxytag="dMatrix::operator()"></a>
|
||||
double & </td><td class="memItemRight" valign="bottom"><a class="el" href="classd_matrix.html#a2">operator()</a> (unsigned _i, unsigned _j)</td></tr>
|
||||
|
||||
<tr><td class="mdescLeft"> </td><td class="mdescRight">reference - to set values <br></td></tr>
|
||||
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a3" doxytag="dMatrix::printOn"></a>
|
||||
void </td><td class="memItemRight" valign="bottom"><a class="el" href="classd_matrix.html#a3">printOn</a> (std::ostream &_os)</td></tr>
|
||||
|
||||
<tr><td class="mdescLeft"> </td><td class="mdescRight">just in case <br></td></tr>
|
||||
<tr><td colspan="2"><br><h2>Private Attributes</h2></td></tr>
|
||||
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="r0" doxytag="dMatrix::rSize"></a>
|
||||
unsigned </td><td class="memItemRight" valign="bottom"><b>rSize</b></td></tr>
|
||||
|
||||
</table>
|
||||
<hr><a name="_details"></a><h2>Detailed Description</h2>
|
||||
A helper class for Sharing - to hold distances.
|
||||
<p>
|
||||
|
||||
<p>
|
||||
Definition at line <a class="el" href="eo_sharing_8h-source.html#l00037">37</a> of file <a class="el" href="eo_sharing_8h-source.html">eoSharing.h</a>.<hr>The documentation for this class was generated from the following file:<ul>
|
||||
<li><a class="el" href="eo_sharing_8h-source.html">eoSharing.h</a></ul>
|
||||
<hr size="1"><address style="align: right;"><small>Generated on Thu Oct 19 05:06:46 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>
|
||||
29
trunk/paradiseo-eo/doc/html/classeo1_pt_bit_crossover.html
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
<!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: eo1PtBitCrossover Class Reference</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>
|
||||
<h1>eo1PtBitCrossover Class Reference<br>
|
||||
<small>
|
||||
[<a class="el" href="group__bitstring.html">Bitstring</a>]</small>
|
||||
</h1>eo1PtBitXover --> classic 1-point crossover
|
||||
<a href="#_details">More...</a>
|
||||
<p>
|
||||
<code>#include <<a class="el" href="eo_bit_op_8h-source.html">ga/eoBitOp.h</a>></code>
|
||||
<p>
|
||||
<table border="0" cellpadding="0" cellspacing="0">
|
||||
<tr><td></td></tr>
|
||||
</table>
|
||||
<hr><a name="_details"></a><h2>Detailed Description</h2>
|
||||
eo1PtBitXover --> classic 1-point crossover
|
||||
<p>
|
||||
<hr>The documentation for this class was generated from the following file:<ul>
|
||||
<li><a class="el" href="eo_bit_op_8h-source.html">eoBitOp.h</a></ul>
|
||||
<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>
|
||||