git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@40 331e1502-861f-0410-8da2-ba01fb791d7f
134 lines
8.1 KiB
HTML
134 lines
8.1 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
|
|
<title>EO: testeo.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_000029.html">test</a></div>
|
|
<h1>testeo.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 <TreeBuilder.h></span>
|
|
00021 <span class="preprocessor">#include <FunDef.h></span>
|
|
00022 <span class="preprocessor">#include <Dataset.h></span>
|
|
00023
|
|
00024 <span class="preprocessor">#include <eoSymInit.h></span>
|
|
00025 <span class="preprocessor">#include <eoSym.h></span>
|
|
00026 <span class="preprocessor">#include <eoPop.h></span>
|
|
00027 <span class="preprocessor">#include <eoSymMutate.h></span>
|
|
00028 <span class="preprocessor">#include <eoSymCrossover.h></span>
|
|
00029 <span class="preprocessor">#include <eoSymEval.h></span>
|
|
00030
|
|
00031 <span class="keyword">typedef</span> EoSym<double> <a class="code" href="classeo_parse_tree.html">EoType</a>;
|
|
00032
|
|
00033 <span class="keywordtype">int</span> main() {
|
|
00034
|
|
00035 LanguageTable table;
|
|
00036 table.add_function(sum_token, 2);
|
|
00037 table.add_function(prod_token, 2);
|
|
00038 table.add_function(inv_token, 1);
|
|
00039 table.add_function(min_token, 1);
|
|
00040 table.add_function( SymVar(0).token(), 0);
|
|
00041
|
|
00042 table.add_function(tan_token, 1);
|
|
00043
|
|
00044 table.add_function(sum_token, 0);
|
|
00045 table.add_function(prod_token, 0);
|
|
00046
|
|
00047 TreeBuilder builder(table);
|
|
00048
|
|
00049 <a class="code" href="classeo_sym_init.html">eoSymInit<EoType></a> init(builder);
|
|
00050
|
|
00051 <a class="code" href="classeo_pop.html">eoPop<EoType></a> pop(10, init);
|
|
00052
|
|
00053 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < pop.size(); ++i) {
|
|
00054 <span class="comment">// write out pretty printed</span>
|
|
00055 cout << (Sym) pop[i] << endl;
|
|
00056 }
|
|
00057
|
|
00058 <a class="code" href="class_biased_node_selector.html">BiasedNodeSelector</a> node_selector;
|
|
00059 eoSymSubtreeMutate<EoType> mutate1(builder, node_selector);
|
|
00060 eoSymNodeMutate<EoType> mutate2(table);
|
|
00061
|
|
00062 cout << <span class="stringliteral">"****** MUTATION ************"</span> << endl;
|
|
00063
|
|
00064 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < pop.size(); ++i) {
|
|
00065
|
|
00066 cout << <span class="stringliteral">"Before "</span> << (Sym) pop[i] << endl;
|
|
00067 mutate1(pop[i]);
|
|
00068 cout << <span class="stringliteral">"After 1 "</span> << (Sym) pop[i] << endl;
|
|
00069 mutate2(pop[i]);
|
|
00070 cout << <span class="stringliteral">"After 2 "</span> << (Sym) pop[i] << endl;
|
|
00071 }
|
|
00072
|
|
00073 cout << <span class="stringliteral">"****** CROSSOVER ***********"</span> << endl;
|
|
00074
|
|
00075 eoQuadSubtreeCrossover<EoType> quad(node_selector);
|
|
00076 eoBinSubtreeCrossover<EoType> bin(node_selector);
|
|
00077 eoBinHomologousCrossover<EoType> hom;
|
|
00078
|
|
00079 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < pop.size()-1; ++i) {
|
|
00080 cout << <span class="stringliteral">"Before "</span> << (Sym) pop[i] << endl;
|
|
00081 cout << <span class="stringliteral">"Before "</span> << (Sym) pop[i+1] << endl;
|
|
00082
|
|
00083 hom(pop[i], pop[i+1]);
|
|
00084
|
|
00085 cout << <span class="stringliteral">"After hom "</span> << (Sym) pop[i] << endl;
|
|
00086 cout << <span class="stringliteral">"After hom "</span> << (Sym) pop[i+1] << endl;
|
|
00087
|
|
00088
|
|
00089 quad(pop[i], pop[i+1]);
|
|
00090
|
|
00091 cout << <span class="stringliteral">"After quad "</span> << (Sym) pop[i] << endl;
|
|
00092 cout << <span class="stringliteral">"After quad "</span> << (Sym) pop[i+1] << endl;
|
|
00093
|
|
00094 bin(pop[i], pop[i+1]);
|
|
00095
|
|
00096 cout << <span class="stringliteral">"After bin "</span> << (Sym) pop[i] << endl;
|
|
00097 cout << <span class="stringliteral">"After bin "</span> << (Sym) pop[i+1] << endl;
|
|
00098
|
|
00099 cout << endl;
|
|
00100 }
|
|
00101
|
|
00102 cout << <span class="stringliteral">"****** Evaluation **********"</span> << endl;
|
|
00103
|
|
00104 Dataset dataset;
|
|
00105 dataset.load_data(<span class="stringliteral">"test_data.txt"</span>);
|
|
00106 IntervalBoundsCheck check(dataset.input_minima(), dataset.input_maxima());
|
|
00107 ErrorMeasure measure(dataset, 0.90, ErrorMeasure::mean_squared_scaled);
|
|
00108
|
|
00109 eoSymPopEval<EoType> evaluator(check, measure, 20000);
|
|
00110
|
|
00111 <a class="code" href="classeo_pop.html">eoPop<EoType></a> dummy;
|
|
00112 evaluator(pop, dummy);
|
|
00113
|
|
00114 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i = 0; i < pop.size(); ++i) {
|
|
00115 cout << pop[i] << endl;
|
|
00116 }
|
|
00117
|
|
00118 }
|
|
00119
|
|
</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>
|