[3] | 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 class Reference</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 Class Reference</h1>Base class for genetic operations on genotypes of some genetic format. |
---|
| 10 | <a href="#_details">More...</a> |
---|
| 11 | <p> |
---|
| 12 | <p>Inheritance diagram for Geno_fx: |
---|
| 13 | <p><center><img src="classGeno__fx.png" usemap="#Geno_fx_map" border="0" alt=""></center> |
---|
| 14 | <map name="Geno_fx_map"> |
---|
| 15 | <area href="classGeno__ftest.html" alt="Geno_ftest" shape="rect" coords="0,56,72,80"> |
---|
| 16 | </map> |
---|
| 17 | <a href="classGeno__fx-members.html">List of all members.</a><table border=0 cellpadding=0 cellspacing=0> |
---|
| 18 | <tr><td></td></tr> |
---|
| 19 | <tr><td colspan=2><br><h2>Public Methods</h2></td></tr> |
---|
| 20 | <tr><td nowrap align=right valign=top><a name="a0" doxytag="Geno_fx::Geno_fx"></a> |
---|
| 21 | </td><td valign=bottom><b>Geno_fx</b> ()</td></tr> |
---|
| 22 | <tr><td nowrap align=right valign=top>virtual int </td><td valign=bottom><a class="el" href="classGeno__fx.html#a1">checkValidity</a> (const char *geno)</td></tr> |
---|
| 23 | <tr><td nowrap align=right valign=top>virtual int </td><td valign=bottom><a class="el" href="classGeno__fx.html#a2">validate</a> (char *&geno)</td></tr> |
---|
| 24 | <tr><td nowrap align=right valign=top>virtual int </td><td valign=bottom><a class="el" href="classGeno__fx.html#a3">mutate</a> (char *&geno, float &chg)</td></tr> |
---|
| 25 | <tr><td nowrap align=right valign=top>virtual int </td><td valign=bottom><a class="el" href="classGeno__fx.html#a4">crossOver</a> (char *&g1, char *&g2, float &chg1, float &chg2)</td></tr> |
---|
| 26 | <tr><td nowrap align=right valign=top>virtual char * </td><td valign=bottom><a class="el" href="classGeno__fx.html#a5">getSimplest</a> ()</td></tr> |
---|
| 27 | <tr><td nowrap align=right valign=top>virtual unsigned long </td><td valign=bottom><a class="el" href="classGeno__fx.html#a6">style</a> (const char *geno, int pos)</td></tr> |
---|
| 28 | <tr><td nowrap align=right valign=top><a name="a7" doxytag="Geno_fx::similarity"></a> |
---|
| 29 | virtual float </td><td valign=bottom><a class="el" href="classGeno__fx.html#a7">similarity</a> (const char *, const char *)</td></tr> |
---|
| 30 | <tr><td> </td><td><font size=-1><em>currently not used (similarity of two genotypes)</em></font><br><br></td></tr> |
---|
| 31 | <tr><td nowrap align=right valign=top><a name="a8" doxytag="Geno_fx::~Geno_fx"></a> |
---|
| 32 | virtual </td><td valign=bottom><b>~Geno_fx</b> ()</td></tr> |
---|
| 33 | <tr><td colspan=2><br><h2>Static Public Methods</h2></td></tr> |
---|
| 34 | <tr><td colspan="2"><div class="groupHeader">Some helpful methods for you</div></td></tr> |
---|
| 35 | <tr><td nowrap align=right valign=top><a name="z7_0" doxytag="Geno_fx::roulette"></a> |
---|
| 36 | int </td><td valign=bottom><a class="el" href="classGeno__fx.html#z7_0">roulette</a> (const double *probtab, int count)</td></tr> |
---|
| 37 | <tr><td> </td><td><font size=-1><em>returns random index according to probabilities in the <em>probtab</em> table or -1 if all probs are zero. <em>count</em> is the number of elements in <em>probtab</em>.</em></font><br><br></td></tr> |
---|
| 38 | <tr><td nowrap align=right valign=top><a name="z7_1" doxytag="Geno_fx::getMinMaxDef"></a> |
---|
| 39 | bool </td><td valign=bottom><a class="el" href="classGeno__fx.html#z7_1">getMinMaxDef</a> (ParamInterface *p, int propindex, double &mn, double &mx, double &def)</td></tr> |
---|
| 40 | <tr><td> </td><td><font size=-1><em>perhaps a more useful (higher-level) way to obtain min/max/def info for integer and double properties. Returns true if min/max/def was really available (otherwise it is just invented).</em></font><br><br></td></tr> |
---|
| 41 | <tr><td nowrap align=right valign=top><a name="z7_2" doxytag="Geno_fx::selectRandomProperty"></a> |
---|
| 42 | int </td><td valign=bottom><a class="el" href="classGeno__fx.html#z7_2">selectRandomProperty</a> (Neuro *n)</td></tr> |
---|
| 43 | <tr><td> </td><td><font size=-1><em>selects random property (either 0-based extraproperty of Neuro or 100-based property of its NeuroClass).</em></font><br><br></td></tr> |
---|
| 44 | <tr><td nowrap align=right valign=top><a name="z7_3" doxytag="Geno_fx::mutateNeuProperty"></a> |
---|
| 45 | double </td><td valign=bottom><a class="el" href="classGeno__fx.html#z7_3">mutateNeuProperty</a> (double current, Neuro *n, int propindex)</td></tr> |
---|
| 46 | <tr><td> </td><td><font size=-1><em>returns value <em>current</em> mutated for the property <em>propindex</em> of NeuroClass <em>nc</em> or for extraproperty (<em>propindex</em> - 100) of Neuro. Give <em>propindex</em> == -1 to mutate connection weight (<em>nc</em> is then ignored).</em></font><br><br></td></tr> |
---|
| 47 | <tr><td nowrap align=right valign=top><a name="z7_4" doxytag="Geno_fx::mutateProperty"></a> |
---|
| 48 | bool </td><td valign=bottom><a class="el" href="classGeno__fx.html#z7_4">mutateProperty</a> (ParamInterface &p, int propindex)</td></tr> |
---|
| 49 | <tr><td> </td><td><font size=-1><em>mutate selected property. Returns true when success.</em></font><br><br></td></tr> |
---|
| 50 | <tr><td nowrap align=right valign=top><a name="z7_5" doxytag="Geno_fx::mutateValue"></a> |
---|
| 51 | double </td><td valign=bottom><a class="el" href="classGeno__fx.html#z7_5">mutateValue</a> (double current, double vmin, double vmax)</td></tr> |
---|
| 52 | <tr><td> </td><td><font size=-1><em>returns <em>current</em> value "creep"-mutated with Gaussian distribution within [ <em>vmin</em> , <em>vmax</em> ] interval. 3 digits after comma.</em></font><br><br></td></tr> |
---|
| 53 | <tr><td nowrap align=right valign=top><a name="z7_6" doxytag="Geno_fx::getRandomNeuroClass"></a> |
---|
| 54 | NeuroClass * </td><td valign=bottom><a class="el" href="classGeno__fx.html#z7_6">getRandomNeuroClass</a> ()</td></tr> |
---|
| 55 | <tr><td> </td><td><font size=-1><em>returns random neuroclass or NULL when no active classes.</em></font><br><br></td></tr> |
---|
| 56 | <tr><td nowrap align=right valign=top><a name="z7_7" doxytag="Geno_fx::parseNeuroClass"></a> |
---|
| 57 | NeuroClass * </td><td valign=bottom><a class="el" href="classGeno__fx.html#z7_7">parseNeuroClass</a> (char *&s)</td></tr> |
---|
| 58 | <tr><td> </td><td><font size=-1><em>returns neuroclass or NULL if the string does not begin with a valid name. Advance <em>s</em> pointer.</em></font><br><br></td></tr> |
---|
| 59 | <tr><td nowrap align=right valign=top><a name="z7_8" doxytag="Geno_fx::neuroClassProp"></a> |
---|
| 60 | int </td><td valign=bottom><a class="el" href="classGeno__fx.html#z7_8">neuroClassProp</a> (char *&s, NeuroClass *nc, bool also_v1_N_props=false)</td></tr> |
---|
| 61 | <tr><td> </td><td><font size=-1><em>returns 0-based property number for <em>neuroclass</em>, 100-based extraproperty number for Neuro, or -1 if the string does not begin with a valid property name. Advance <em>s</em> pointer if success.</em></font><br><br></td></tr> |
---|
| 62 | <tr><td nowrap align=right valign=top><a name="z7_9" doxytag="Geno_fx::isWS"></a> |
---|
| 63 | bool </td><td valign=bottom><a class="el" href="classGeno__fx.html#z7_9">isWS</a> (const char c)</td></tr> |
---|
| 64 | <tr><td> </td><td><font size=-1><em>is <em>c</em> a whitespace char?</em></font><br><br></td></tr> |
---|
| 65 | <tr><td nowrap align=right valign=top><a name="z7_10" doxytag="Geno_fx::skipWS"></a> |
---|
| 66 | void </td><td valign=bottom><a class="el" href="classGeno__fx.html#z7_10">skipWS</a> (char *&s)</td></tr> |
---|
| 67 | <tr><td> </td><td><font size=-1><em>advances pointer <em>s</em> skipping whitespaces.</em></font><br><br></td></tr> |
---|
| 68 | <tr><td nowrap align=right valign=top><a name="z7_11" doxytag="Geno_fx::areAlike"></a> |
---|
| 69 | bool </td><td valign=bottom><a class="el" href="classGeno__fx.html#z7_11">areAlike</a> (char *, char *)</td></tr> |
---|
| 70 | <tr><td> </td><td><font size=-1><em>compares two text strings skipping whitespaces. Returns 1 when equal, 0 when different.</em></font><br><br></td></tr> |
---|
| 71 | <tr><td nowrap align=right valign=top><a name="z7_12" doxytag="Geno_fx::strchrn0"></a> |
---|
| 72 | char * </td><td valign=bottom><a class="el" href="classGeno__fx.html#z7_12">strchrn0</a> (const char *str, char ch)</td></tr> |
---|
| 73 | <tr><td> </td><td><font size=-1><em>like strchr, but does not find zero char in <em>str</em>.</em></font><br><br></td></tr> |
---|
| 74 | <tr><td nowrap align=right valign=top><a name="z7_13" doxytag="Geno_fx::isNeuroClassName"></a> |
---|
| 75 | bool </td><td valign=bottom><a class="el" href="classGeno__fx.html#z7_13">isNeuroClassName</a> (const char firstchar)</td></tr> |
---|
| 76 | <tr><td> </td><td><font size=-1><em>determines if <em>firstchar</em> may start NeuroClass name. If not, it may start NeuroClass' (or Neuro's) property name.</em></font><br><br></td></tr> |
---|
| 77 | <tr><td colspan=2><br><h2>Public Attributes</h2></td></tr> |
---|
| 78 | <tr><td nowrap align=right valign=top><a name="m0" doxytag="Geno_fx::par"></a> |
---|
| 79 | Param </td><td valign=bottom><b>par</b></td></tr> |
---|
| 80 | <tr><td nowrap align=right valign=top><a name="m1" doxytag="Geno_fx::supported_format"></a> |
---|
| 81 | char </td><td valign=bottom><a class="el" href="classGeno__fx.html#m1">supported_format</a></td></tr> |
---|
| 82 | <tr><td> </td><td><font size=-1><em>genotype format which is supported by this class ('6' for Geno_f6, etc.). Must be initialized in constructor</em></font><br><br></td></tr> |
---|
| 83 | <tr><td nowrap align=right valign=top><a name="m2" doxytag="Geno_fx::name"></a> |
---|
| 84 | SString </td><td valign=bottom><a class="el" href="classGeno__fx.html#m2">name</a></td></tr> |
---|
| 85 | <tr><td> </td><td><font size=-1><em>name of this set of genetic operators</em></font><br><br></td></tr> |
---|
| 86 | </table> |
---|
| 87 | <hr><a name="_details"></a><h2>Detailed Description</h2> |
---|
| 88 | Base class for genetic operations on genotypes of some genetic format. |
---|
| 89 | <p> |
---|
| 90 | <dl compact><dt><b>Author: </b></dt><dd> |
---|
| 91 | Maciej Komosinski</dl>When designing your genetic representation, inherit your class (for example Geno_fMy) from Geno_fx. Define some methods, like <a class="el" href="classGeno__fx.html#a3">mutate</a>() and validite(), in your class, to allow for evolution. Ensure they have the same names and arguments as the corresponding virtual methods in Geno_fx. Whenever arguments are genotypes, they are without trailing characters which describe genetic format (for example, "p:", not "//0\np:"). When allocating/reallocating char* parameters, use malloc, free, realloc, strdup, etc. Do not use new and delete. |
---|
| 92 | <p> |
---|
| 93 | All the methods you might define are:<ul> |
---|
| 94 | <li><a class="el" href="classGeno__fx.html#a1">checkValidity</a>()<li><a class="el" href="classGeno__fx.html#a2">validate</a>()<li><a class="el" href="classGeno__fx.html#a3">mutate</a>()<li><a class="el" href="classGeno__fx.html#a4">crossOver</a>()<li><a class="el" href="classGeno__fx.html#a5">getSimplest</a>()<li><a class="el" href="classGeno__fx.html#a6">style</a>()</ul> |
---|
| 95 | Your code must not cause errors (like invalid memory access, memory leaks) on any arguments, even 'random' ones. GENOPER_OPFAIL should be returned when an operator cannot cope with its argument genotype. |
---|
| 96 | <p> |
---|
| 97 | To compile your code, you may also need some GDK files. A simple example is <a class="el" href="classGeno__ftest.html">Geno_ftest</a> class (see <a class="el" href="geno__ftest_8cpp.html#geno_ftest_example">C++ code</a> for details). A more realistic example is Geno_f4 derived from Geno_fx: refer to the available source on developmental encoding and f4 genotype format. |
---|
| 98 | <p> |
---|
| 99 | <hr><h2>Member Function Documentation</h2> |
---|
| 100 | <a name="a1" doxytag="Geno_fx::checkValidity"></a><p> |
---|
| 101 | <table width="100%" cellpadding="2" cellspacing="0" border="0"> |
---|
| 102 | <tr> |
---|
| 103 | <td class="md"> |
---|
| 104 | <table cellpadding="0" cellspacing="0" border="0"> |
---|
| 105 | <tr> |
---|
| 106 | <td class="md" nowrap valign="top"> virtual int Geno_fx::checkValidity </td> |
---|
| 107 | <td class="md" valign="top">( </td> |
---|
| 108 | <td class="md" nowrap valign="top">const char * </td> |
---|
| 109 | <td class="mdname1" valign="top" nowrap> <em>geno</em> </td> |
---|
| 110 | <td class="md" valign="top">) </td> |
---|
| 111 | <td class="md" nowrap><code> [virtual]</code></td> |
---|
| 112 | </tr> |
---|
| 113 | |
---|
| 114 | </table> |
---|
| 115 | </td> |
---|
| 116 | </tr> |
---|
| 117 | </table> |
---|
| 118 | <table cellspacing=5 cellpadding=0 border=0> |
---|
| 119 | <tr> |
---|
| 120 | <td> |
---|
| 121 | |
---|
| 122 | </td> |
---|
| 123 | <td> |
---|
| 124 | |
---|
| 125 | <p> |
---|
| 126 | Checks a genotype for minor mistakes and major errors. <dl compact><dt><b>Parameters: </b></dt><dd> |
---|
| 127 | <table border=0 cellspacing=2 cellpadding=0> |
---|
| 128 | <tr><td valign=top><em>geno</em> </td><td> |
---|
| 129 | genotype to be checked </td></tr> |
---|
| 130 | </table> |
---|
| 131 | </dl><dl compact><dt><b>Return values: </b></dt><dd> |
---|
| 132 | <table border=0 cellspacing=2 cellpadding=0> |
---|
| 133 | <tr><td valign=top><em>error_position</em> </td><td> |
---|
| 134 | 1-based (or 1 if no exact error position known) </td></tr> |
---|
| 135 | <tr><td valign=top><em>GENOPER_OK</em> </td><td> |
---|
| 136 | when the genotype is fully valid, and can be translated by the converter with <b>no</b> modifications nor tweaks </td></tr> |
---|
| 137 | </table> |
---|
| 138 | </dl> |
---|
| 139 | <p> |
---|
| 140 | Reimplemented in <a class="el" href="classGeno__ftest.html#a1">Geno_ftest</a>. </td> |
---|
| 141 | </tr> |
---|
| 142 | </table> |
---|
| 143 | <a name="a4" doxytag="Geno_fx::crossOver"></a><p> |
---|
| 144 | <table width="100%" cellpadding="2" cellspacing="0" border="0"> |
---|
| 145 | <tr> |
---|
| 146 | <td class="md"> |
---|
| 147 | <table cellpadding="0" cellspacing="0" border="0"> |
---|
| 148 | <tr> |
---|
| 149 | <td class="md" nowrap valign="top"> virtual int Geno_fx::crossOver </td> |
---|
| 150 | <td class="md" valign="top">( </td> |
---|
| 151 | <td class="md" nowrap valign="top">char *& </td> |
---|
| 152 | <td class="mdname" nowrap> <em>g1</em>, </td> |
---|
| 153 | </tr> |
---|
| 154 | <tr> |
---|
| 155 | <td></td> |
---|
| 156 | <td></td> |
---|
| 157 | <td class="md" nowrap>char *& </td> |
---|
| 158 | <td class="mdname" nowrap> <em>g2</em>, </td> |
---|
| 159 | </tr> |
---|
| 160 | <tr> |
---|
| 161 | <td></td> |
---|
| 162 | <td></td> |
---|
| 163 | <td class="md" nowrap>float & </td> |
---|
| 164 | <td class="mdname" nowrap> <em>chg1</em>, </td> |
---|
| 165 | </tr> |
---|
| 166 | <tr> |
---|
| 167 | <td></td> |
---|
| 168 | <td></td> |
---|
| 169 | <td class="md" nowrap>float & </td> |
---|
| 170 | <td class="mdname" nowrap> <em>chg2</em></td> |
---|
| 171 | </tr> |
---|
| 172 | <tr> |
---|
| 173 | <td></td> |
---|
| 174 | <td class="md">) </td> |
---|
| 175 | <td class="md" colspan="2"><code> [virtual]</code></td> |
---|
| 176 | </tr> |
---|
| 177 | |
---|
| 178 | </table> |
---|
| 179 | </td> |
---|
| 180 | </tr> |
---|
| 181 | </table> |
---|
| 182 | <table cellspacing=5 cellpadding=0 border=0> |
---|
| 183 | <tr> |
---|
| 184 | <td> |
---|
| 185 | |
---|
| 186 | </td> |
---|
| 187 | <td> |
---|
| 188 | |
---|
| 189 | <p> |
---|
| 190 | Crosses over two genotypes. It is sufficient to return only one child (in <em>g1)</em> and set <em>chg1</em> only, then <em>g2</em> must equal "". |
---|
| 191 | <p> |
---|
| 192 | Avoid unnecessary calls in your code. Every genotype argument passed to this function is first checked, and validated if <a class="el" href="classGeno__fx.html#a1">checkValidity</a>() reported an error (or if there is no <a class="el" href="classGeno__fx.html#a1">checkValidity</a>() implemented). Every resulting genotype is subject to the same procedure, unless GENOPER_OPFAIL was returned. Thus you do not have to call these functions on input and output genotypes, because they are validated if needed. <dl compact><dt><b>Parameters: </b></dt><dd> |
---|
| 193 | <table border=0 cellspacing=2 cellpadding=0> |
---|
| 194 | <tr><td valign=top><em>g1</em> </td><td> |
---|
| 195 | input/output: parent1 genotype, initialize with child1 </td></tr> |
---|
| 196 | <tr><td valign=top><em>g2</em> </td><td> |
---|
| 197 | input/output: parent2 genotype, initialize with child2 if both children are available </td></tr> |
---|
| 198 | <tr><td valign=top><em>chg1</em> </td><td> |
---|
| 199 | output: initialize with the fraction of parent1 genes in child1 (parent2 has the rest) </td></tr> |
---|
| 200 | <tr><td valign=top><em>chg2</em> </td><td> |
---|
| 201 | output: initialize with the fraction of parent2 genes in child2 (parent1 has the rest) </td></tr> |
---|
| 202 | </table> |
---|
| 203 | </dl><dl compact><dt><b>Return values: </b></dt><dd> |
---|
| 204 | <table border=0 cellspacing=2 cellpadding=0> |
---|
| 205 | <tr><td valign=top><em>GENOPER_OK</em> </td><td> |
---|
| 206 | </td></tr> |
---|
| 207 | <tr><td valign=top><em>GENOPER_OPFAIL</em> </td><td> |
---|
| 208 | </td></tr> |
---|
| 209 | </table> |
---|
| 210 | </dl><dl compact><dt><b>See also: </b></dt><dd> |
---|
| 211 | <a class="el" href="classGeno__fx.html#a3">mutate</a>() for an example </dl> |
---|
| 212 | <p> |
---|
| 213 | Reimplemented in <a class="el" href="classGeno__ftest.html#a4">Geno_ftest</a>. </td> |
---|
| 214 | </tr> |
---|
| 215 | </table> |
---|
| 216 | <a name="a5" doxytag="Geno_fx::getSimplest"></a><p> |
---|
| 217 | <table width="100%" cellpadding="2" cellspacing="0" border="0"> |
---|
| 218 | <tr> |
---|
| 219 | <td class="md"> |
---|
| 220 | <table cellpadding="0" cellspacing="0" border="0"> |
---|
| 221 | <tr> |
---|
| 222 | <td class="md" nowrap valign="top"> virtual char* Geno_fx::getSimplest </td> |
---|
| 223 | <td class="md" valign="top">( </td> |
---|
| 224 | <td class="mdname1" valign="top" nowrap> </td> |
---|
| 225 | <td class="md" valign="top">) </td> |
---|
| 226 | <td class="md" nowrap><code> [virtual]</code></td> |
---|
| 227 | </tr> |
---|
| 228 | |
---|
| 229 | </table> |
---|
| 230 | </td> |
---|
| 231 | </tr> |
---|
| 232 | </table> |
---|
| 233 | <table cellspacing=5 cellpadding=0 border=0> |
---|
| 234 | <tr> |
---|
| 235 | <td> |
---|
| 236 | |
---|
| 237 | </td> |
---|
| 238 | <td> |
---|
| 239 | |
---|
| 240 | <p> |
---|
| 241 | <dl compact><dt><b>Returns :</b></dt><dd> |
---|
| 242 | a pointer to the simplest genotype string </dl> </td> |
---|
| 243 | </tr> |
---|
| 244 | </table> |
---|
| 245 | <a name="a3" doxytag="Geno_fx::mutate"></a><p> |
---|
| 246 | <table width="100%" cellpadding="2" cellspacing="0" border="0"> |
---|
| 247 | <tr> |
---|
| 248 | <td class="md"> |
---|
| 249 | <table cellpadding="0" cellspacing="0" border="0"> |
---|
| 250 | <tr> |
---|
| 251 | <td class="md" nowrap valign="top"> virtual int Geno_fx::mutate </td> |
---|
| 252 | <td class="md" valign="top">( </td> |
---|
| 253 | <td class="md" nowrap valign="top">char *& </td> |
---|
| 254 | <td class="mdname" nowrap> <em>geno</em>, </td> |
---|
| 255 | </tr> |
---|
| 256 | <tr> |
---|
| 257 | <td></td> |
---|
| 258 | <td></td> |
---|
| 259 | <td class="md" nowrap>float & </td> |
---|
| 260 | <td class="mdname" nowrap> <em>chg</em></td> |
---|
| 261 | </tr> |
---|
| 262 | <tr> |
---|
| 263 | <td></td> |
---|
| 264 | <td class="md">) </td> |
---|
| 265 | <td class="md" colspan="2"><code> [virtual]</code></td> |
---|
| 266 | </tr> |
---|
| 267 | |
---|
| 268 | </table> |
---|
| 269 | </td> |
---|
| 270 | </tr> |
---|
| 271 | </table> |
---|
| 272 | <table cellspacing=5 cellpadding=0 border=0> |
---|
| 273 | <tr> |
---|
| 274 | <td> |
---|
| 275 | |
---|
| 276 | </td> |
---|
| 277 | <td> |
---|
| 278 | |
---|
| 279 | <p> |
---|
| 280 | Mutates a genotype. Mutation should always change something. |
---|
| 281 | <p> |
---|
| 282 | Avoid unnecessary calls in your code. Every genotype argument passed to this function is first checked, and validated if <a class="el" href="classGeno__fx.html#a1">checkValidity</a>() reported an error (or if there is no <a class="el" href="classGeno__fx.html#a1">checkValidity</a>() implemented). Every resulting genotype is subject to the same procedure, unless GENOPER_OPFAIL was returned. Thus you do not have to call these functions on input and output genotypes, because they are validated if needed. <dl compact><dt><b>Parameters: </b></dt><dd> |
---|
| 283 | <table border=0 cellspacing=2 cellpadding=0> |
---|
| 284 | <tr><td valign=top><em>geno</em> </td><td> |
---|
| 285 | input/output: genotype to be mutated </td></tr> |
---|
| 286 | <tr><td valign=top><em>chg</em> </td><td> |
---|
| 287 | output: initialize with a value (in most cases 0..1) corresponding to the amount of genotype mutated. For example, it could be the number of changed genes divided by the total number of genes before mutation. </td></tr> |
---|
| 288 | </table> |
---|
| 289 | </dl><dl compact><dt><b>Return values: </b></dt><dd> |
---|
| 290 | <table border=0 cellspacing=2 cellpadding=0> |
---|
| 291 | <tr><td valign=top><em>GENOPER_OK</em> </td><td> |
---|
| 292 | </td></tr> |
---|
| 293 | <tr><td valign=top><em>GENOPER_OPFAIL</em> </td><td> |
---|
| 294 | </td></tr> |
---|
| 295 | </table> |
---|
| 296 | </dl><dl compact><dt><b>See also: </b></dt><dd> |
---|
| 297 | Mutation example to illustrate the exchange of pointers for <em>geno</em>. The mutation adds random letter at the beginning or removes last letter from <em>geno</em>. <div class="fragment"><pre>{ |
---|
| 298 | <span class="keywordtype">int</span> len=strlen(geno); |
---|
| 299 | <span class="keywordflow">if</span> (len==0 || random(2)==0) <span class="comment">//add</span> |
---|
| 300 | { |
---|
| 301 | <span class="keywordtype">char</span>* mutated=(<span class="keywordtype">char</span>*)malloc(mutated,len+2); <span class="comment">//allocate for mutated genotype</span> |
---|
| 302 | mutated[0]=<span class="charliteral">'A'</span>+random(10); <span class="comment">//first char random</span> |
---|
| 303 | strcpy(mutated+1,geno); <span class="comment">//the rest is original</span> |
---|
| 304 | free(geno); <span class="comment">//must take care of the original allocation</span> |
---|
| 305 | geno=mutated; |
---|
| 306 | } <span class="keywordflow">else</span> geno[len-1]=0; <span class="comment">//simply shorten the string - remove last char</span> |
---|
| 307 | chg=1.0/max(len,1); <span class="comment">//estimation of mutation strength, divby0-safe</span> |
---|
| 308 | } |
---|
| 309 | </pre></div> </dl> |
---|
| 310 | <p> |
---|
| 311 | Reimplemented in <a class="el" href="classGeno__ftest.html#a3">Geno_ftest</a>. </td> |
---|
| 312 | </tr> |
---|
| 313 | </table> |
---|
| 314 | <a name="a6" doxytag="Geno_fx::style"></a><p> |
---|
| 315 | <table width="100%" cellpadding="2" cellspacing="0" border="0"> |
---|
| 316 | <tr> |
---|
| 317 | <td class="md"> |
---|
| 318 | <table cellpadding="0" cellspacing="0" border="0"> |
---|
| 319 | <tr> |
---|
| 320 | <td class="md" nowrap valign="top"> virtual unsigned long Geno_fx::style </td> |
---|
| 321 | <td class="md" valign="top">( </td> |
---|
| 322 | <td class="md" nowrap valign="top">const char * </td> |
---|
| 323 | <td class="mdname" nowrap> <em>geno</em>, </td> |
---|
| 324 | </tr> |
---|
| 325 | <tr> |
---|
| 326 | <td></td> |
---|
| 327 | <td></td> |
---|
| 328 | <td class="md" nowrap>int </td> |
---|
| 329 | <td class="mdname" nowrap> <em>pos</em></td> |
---|
| 330 | </tr> |
---|
| 331 | <tr> |
---|
| 332 | <td></td> |
---|
| 333 | <td class="md">) </td> |
---|
| 334 | <td class="md" colspan="2"><code> [virtual]</code></td> |
---|
| 335 | </tr> |
---|
| 336 | |
---|
| 337 | </table> |
---|
| 338 | </td> |
---|
| 339 | </tr> |
---|
| 340 | </table> |
---|
| 341 | <table cellspacing=5 cellpadding=0 border=0> |
---|
| 342 | <tr> |
---|
| 343 | <td> |
---|
| 344 | |
---|
| 345 | </td> |
---|
| 346 | <td> |
---|
| 347 | |
---|
| 348 | <p> |
---|
| 349 | You may want to have your genotype colored. This method provides desired character styles for genes. <dl compact><dt><b>Parameters: </b></dt><dd> |
---|
| 350 | <table border=0 cellspacing=2 cellpadding=0> |
---|
| 351 | <tr><td valign=top><em>geno</em> </td><td> |
---|
| 352 | genotype </td></tr> |
---|
| 353 | <tr><td valign=top><em>pos</em> </td><td> |
---|
| 354 | 0-based char offset </td></tr> |
---|
| 355 | </table> |
---|
| 356 | </dl><dl compact><dt><b>Return values: </b></dt><dd> |
---|
| 357 | <table border=0 cellspacing=2 cellpadding=0> |
---|
| 358 | <tr><td valign=top><em>number-encoded</em> </td><td> |
---|
| 359 | visual style (and validity) of the genotype char at <em>geno[pos]</em>. Assume white background. </td></tr> |
---|
| 360 | </table> |
---|
| 361 | </dl><dl compact><dt><b>See also: </b></dt><dd> |
---|
| 362 | GENSTYLE_* macros, like <a class="el" href="geno__fx_8h.html#a6">GENSTYLE_BOLD</a> </dl> |
---|
| 363 | <p> |
---|
| 364 | Reimplemented in <a class="el" href="classGeno__ftest.html#a5">Geno_ftest</a>. </td> |
---|
| 365 | </tr> |
---|
| 366 | </table> |
---|
| 367 | <a name="a2" doxytag="Geno_fx::validate"></a><p> |
---|
| 368 | <table width="100%" cellpadding="2" cellspacing="0" border="0"> |
---|
| 369 | <tr> |
---|
| 370 | <td class="md"> |
---|
| 371 | <table cellpadding="0" cellspacing="0" border="0"> |
---|
| 372 | <tr> |
---|
| 373 | <td class="md" nowrap valign="top"> virtual int Geno_fx::validate </td> |
---|
| 374 | <td class="md" valign="top">( </td> |
---|
| 375 | <td class="md" nowrap valign="top">char *& </td> |
---|
| 376 | <td class="mdname1" valign="top" nowrap> <em>geno</em> </td> |
---|
| 377 | <td class="md" valign="top">) </td> |
---|
| 378 | <td class="md" nowrap><code> [virtual]</code></td> |
---|
| 379 | </tr> |
---|
| 380 | |
---|
| 381 | </table> |
---|
| 382 | </td> |
---|
| 383 | </tr> |
---|
| 384 | </table> |
---|
| 385 | <table cellspacing=5 cellpadding=0 border=0> |
---|
| 386 | <tr> |
---|
| 387 | <td> |
---|
| 388 | |
---|
| 389 | </td> |
---|
| 390 | <td> |
---|
| 391 | |
---|
| 392 | <p> |
---|
| 393 | Validates a genotype. The purpose of this function is to validate obvious/minor errors (range overruns, invalid links, etc.). Do not try to introduce entirely new genes in place of an error. <dl compact><dt><b>Parameters: </b></dt><dd> |
---|
| 394 | <table border=0 cellspacing=2 cellpadding=0> |
---|
| 395 | <tr><td valign=top><em>geno</em> </td><td> |
---|
| 396 | input/output: genotype to be validated </td></tr> |
---|
| 397 | </table> |
---|
| 398 | </dl><dl compact><dt><b>Return values: </b></dt><dd> |
---|
| 399 | <table border=0 cellspacing=2 cellpadding=0> |
---|
| 400 | <tr><td valign=top><em>GENOPER_OK</em> </td><td> |
---|
| 401 | must be returned in any case ("did my best to validate") </td></tr> |
---|
| 402 | </table> |
---|
| 403 | </dl> |
---|
| 404 | <p> |
---|
| 405 | Reimplemented in <a class="el" href="classGeno__ftest.html#a2">Geno_ftest</a>. </td> |
---|
| 406 | </tr> |
---|
| 407 | </table> |
---|
| 408 | <hr><address style="align: right;"><small>Generated on Sun Sep 15 00:58:40 2002 for Framsticks GenoFX by |
---|
| 409 | <a href="http://www.doxygen.org/index.html"> |
---|
| 410 | <img src="doxygen.png" alt="doxygen" align="middle" border=0 |
---|
| 411 | width=110 height=53></a>1.2.17 </small></address> |
---|
| 412 | </body> |
---|
| 413 | </html> |
---|