1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
---|
2 | <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> |
---|
3 | <title>geno_fx.cpp Source File</title> |
---|
4 | <link href="doxygen.css" rel="stylesheet" type="text/css"> |
---|
5 | </head><body> |
---|
6 | <!-- Generated by Doxygen 1.2.17 --> |
---|
7 | <center> |
---|
8 | <a class="qindex" href="index.html">Main Page</a> <a class="qindex" href="hierarchy.html">Class Hierarchy</a> <a class="qindex" href="annotated.html">Compound List</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="functions.html">Compound Members</a> <a class="qindex" href="globals.html">File Members</a> </center> |
---|
9 | <hr><h1>geno_fx.cpp</h1><div class="fragment"><pre>00001 <span class="preprocessor">#include <ctype.h></span> <span class="comment">// isupper()</span> |
---|
10 | 00002 <span class="preprocessor">#include "<a class="code" href="geno__fx_8h.html">geno_fx.h</a>"</span> |
---|
11 | 00003 <span class="preprocessor">#include "framsg.h"</span> |
---|
12 | 00004 |
---|
13 | <a name="l00005"></a><a class="code" href="classGeno__fx.html#z7_0">00005</a> <span class="keywordtype">int</span> <a class="code" href="classGeno__fx.html#z7_0">Geno_fx::roulette</a>(<span class="keyword">const</span> <span class="keywordtype">double</span> *probtab,<span class="keywordtype">int</span> count) |
---|
14 | 00006 { |
---|
15 | 00007 <span class="keywordtype">double</span> sum=0; |
---|
16 | 00008 <span class="keywordtype">int</span> i; |
---|
17 | 00009 <span class="keywordflow">for</span> (i=0;i<count;i++) sum+=probtab[i]; |
---|
18 | 00010 <span class="keywordtype">double</span> sel=rnd01*sum; |
---|
19 | 00011 <span class="keywordflow">for</span> (sum=0,i=0;i<count;i++) {sum+=probtab[i]; <span class="keywordflow">if</span> (sel<sum) <span class="keywordflow">return</span> i;} |
---|
20 | 00012 <span class="keywordflow">return</span> -1; |
---|
21 | 00013 } |
---|
22 | 00014 |
---|
23 | <a name="l00015"></a><a class="code" href="classGeno__fx.html#z7_1">00015</a> <span class="keywordtype">int</span> <a class="code" href="classGeno__fx.html#z7_1">Geno_fx::getRandomNeuroClass</a>() |
---|
24 | 00016 { |
---|
25 | 00017 <span class="keywordtype">int</span> ileakt=0; |
---|
26 | 00018 <span class="keywordflow">for</span>(<span class="keywordtype">int</span> i=0;i<Neuro::getClassCount();i++) ileakt+=(Neuro::getClass(i)->active==<span class="keyword">true</span>); |
---|
27 | 00019 <span class="keywordflow">if</span> (ileakt==0) <span class="keywordflow">return</span> -1; |
---|
28 | 00020 <span class="keywordtype">int</span> los=randomN(ileakt)+1; |
---|
29 | 00021 ileakt=0; |
---|
30 | 00022 <span class="keywordflow">for</span>(<span class="keywordtype">int</span> i=0;i<Neuro::getClassCount();i++) |
---|
31 | 00023 {ileakt+=(Neuro::getClass(i)->active==<span class="keyword">true</span>); <span class="keywordflow">if</span> (ileakt==los) <span class="keywordflow">return</span> i;} |
---|
32 | 00024 <span class="keywordflow">return</span> -1; <span class="comment">//never happens </span> |
---|
33 | 00025 } |
---|
34 | 00026 |
---|
35 | <a name="l00027"></a><a class="code" href="classGeno__fx.html#z7_2">00027</a> <span class="keywordtype">int</span> <a class="code" href="classGeno__fx.html#z7_2">Geno_fx::parseNeuroClass</a>(<span class="keywordtype">char</span>*& s) |
---|
36 | 00028 { |
---|
37 | 00029 <span class="keywordtype">int</span> len=strlen(s); |
---|
38 | 00030 <span class="keywordtype">int</span> Len=0,I=-1; |
---|
39 | 00031 <span class="keywordflow">for</span>(<span class="keywordtype">int</span> i=0;i<Neuro::getClassCount();i++) |
---|
40 | 00032 { |
---|
41 | 00033 <span class="keyword">const</span> <span class="keywordtype">char</span> *n=Neuro::getClass(i)->name; |
---|
42 | 00034 <span class="keywordtype">int</span> l=strlen(n); |
---|
43 | 00035 <span class="keywordflow">if</span> (len>=l && l>Len && (strncmp(s,n,l)==0)) {I=i; Len=l;} |
---|
44 | 00036 } |
---|
45 | 00037 s+=Len; |
---|
46 | 00038 <span class="keywordflow">return</span> I; |
---|
47 | 00039 } |
---|
48 | 00040 |
---|
49 | <a name="l00041"></a><a class="code" href="classGeno__fx.html#z7_3">00041</a> <span class="keywordtype">int</span> <a class="code" href="classGeno__fx.html#z7_3">Geno_fx::getNeuroClass</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* s) |
---|
50 | 00042 { |
---|
51 | 00043 <span class="keywordtype">char</span> *p=(<span class="keywordtype">char</span>*)s; |
---|
52 | 00044 <span class="keywordflow">return</span> <a class="code" href="classGeno__fx.html#z7_2">parseNeuroClass</a>(p); |
---|
53 | 00045 } |
---|
54 | 00046 |
---|
55 | <a name="l00047"></a><a class="code" href="classGeno__fx.html#z7_4">00047</a> <span class="keywordtype">int</span> <a class="code" href="classGeno__fx.html#z7_4">Geno_fx::neuroClassProp</a>(<span class="keywordtype">char</span>*& s,<span class="keywordtype">int</span> neuroclass,<span class="keywordtype">bool</span> also_v1_N_props) |
---|
56 | 00048 { |
---|
57 | 00049 <span class="keywordtype">int</span> len=strlen(s); |
---|
58 | 00050 <span class="keywordtype">int</span> Len=0,I=-1; |
---|
59 | 00051 Param p=Neuro::getClass(neuroclass)->getProperties(); |
---|
60 | 00052 <span class="comment">/* if (p.type(i)[0]=='f') do mutowania...</span> |
---|
61 | 00053 <span class="comment"> {</span> |
---|
62 | 00054 <span class="comment"> double mn=0,mx=1,df=0.5,c=p.getDouble(i);</span> |
---|
63 | 00055 <span class="comment"> p.getMinMax(i,mn,mx,df);</span> |
---|
64 | 00056 <span class="comment"> p.setDouble(i,RandMutValue(c,mn,mx));</span> |
---|
65 | 00057 <span class="comment"> changed++;</span> |
---|
66 | 00058 <span class="comment"> break;</span> |
---|
67 | 00059 <span class="comment"> }*/</span> |
---|
68 | 00060 <span class="keywordflow">for</span>(<span class="keywordtype">int</span> i=0;i<p.getPropCount();i++) |
---|
69 | 00061 { |
---|
70 | 00062 <span class="keyword">const</span> <span class="keywordtype">char</span> *n=p.id(i); |
---|
71 | 00063 <span class="keywordtype">int</span> l=strlen(n); |
---|
72 | 00064 <span class="keywordflow">if</span> (len>=l && l>Len && (strncmp(s,n,l)==0)) {I=i; Len=l;} |
---|
73 | 00065 <span class="keywordflow">if</span> (also_v1_N_props) <span class="comment">//recognize old properties symbols /=!</span> |
---|
74 | 00066 { |
---|
75 | 00067 <span class="keywordflow">if</span> (strcmp(n,<span class="stringliteral">"si"</span>)==0) n=<span class="stringliteral">"/"</span>; <span class="keywordflow">else</span> |
---|
76 | 00068 <span class="keywordflow">if</span> (strcmp(n,<span class="stringliteral">"in"</span>)==0) n=<span class="stringliteral">"="</span>; <span class="keywordflow">else</span> |
---|
77 | 00069 <span class="keywordflow">if</span> (strcmp(n,<span class="stringliteral">"fo"</span>)==0) n=<span class="stringliteral">"!"</span>; |
---|
78 | 00070 l=strlen(n); |
---|
79 | 00071 <span class="keywordflow">if</span> (len>=l && l>Len && (strncmp(s,n,l)==0)) {I=i; Len=l;} |
---|
80 | 00072 } |
---|
81 | 00073 } |
---|
82 | 00074 s+=Len; |
---|
83 | 00075 <span class="keywordflow">return</span> I; |
---|
84 | 00076 } |
---|
85 | 00077 |
---|
86 | <a name="l00078"></a><a class="code" href="classGeno__fx.html#z7_5">00078</a> <span class="keywordtype">bool</span> <a class="code" href="classGeno__fx.html#z7_5">Geno_fx::isWS</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> c) |
---|
87 | 00079 {<span class="keywordflow">return</span> c==<span class="charliteral">' '</span> || c==<span class="charliteral">'\n'</span> || c==<span class="charliteral">'\t'</span> || c==<span class="charliteral">'\r'</span>;} |
---|
88 | 00080 |
---|
89 | <a name="l00081"></a><a class="code" href="classGeno__fx.html#z7_6">00081</a> <span class="keywordtype">void</span> <a class="code" href="classGeno__fx.html#z7_6">Geno_fx::skipWS</a>(<span class="keywordtype">char</span> *&s) |
---|
90 | 00082 { <span class="keywordflow">if</span> (!s) FramMessage(<span class="stringliteral">"Geno_fx"</span>,<span class="stringliteral">"skipWS"</span>,<span class="stringliteral">"NULL reference!"</span>,1); <span class="keywordflow">else</span> |
---|
91 | 00083 <span class="keywordflow">while</span> (<a class="code" href="classGeno__fx.html#z7_5">isWS</a>(*s)) s++; |
---|
92 | 00084 } |
---|
93 | 00085 |
---|
94 | <a name="l00086"></a><a class="code" href="classGeno__fx.html#z7_7">00086</a> <span class="keywordtype">char</span>* <a class="code" href="classGeno__fx.html#z7_7">Geno_fx::strchrn0</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *str,<span class="keywordtype">char</span> ch) |
---|
95 | 00087 { <span class="keywordflow">return</span> ch==0?NULL:strchr((<span class="keywordtype">char</span>*)str,ch); } |
---|
96 | 00088 |
---|
97 | <a name="l00089"></a><a class="code" href="classGeno__fx.html#z7_8">00089</a> <span class="keywordtype">bool</span> <a class="code" href="classGeno__fx.html#z7_8">Geno_fx::isNeuroClassName</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> firstchar) |
---|
98 | 00090 { |
---|
99 | 00091 <span class="keywordflow">return</span> isupper(firstchar) || firstchar==<span class="charliteral">'|'</span> || firstchar==<span class="charliteral">'@'</span>; |
---|
100 | 00092 } |
---|
101 | 00093 |
---|
102 | 00094 <span class="comment">//class TGeno_f2 : public Geno_fx {}; //przyklad</span> |
---|
103 | 00095 |
---|
104 | </pre></div><hr><address style="align: right;"><small>Generated on Tue Jul 30 23:21:19 2002 for Framsticks GenoFX by |
---|
105 | <a href="http://www.doxygen.org/index.html"> |
---|
106 | <img src="doxygen.png" alt="doxygen" align="middle" border=0 |
---|
107 | width=110 height=53></a>1.2.17 </small></address> |
---|
108 | </body> |
---|
109 | </html> |
---|