Changeset 121 for cpp/frams/genetics
- Timestamp:
- 02/08/14 06:00:41 (11 years ago)
- Location:
- cpp/frams/genetics
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/frams/genetics/defgenoconv.cpp
r109 r121 1 // This file is a part of the Framsticks GDK. 2 // Copyright (C) 2002-2014 Maciej Komosinski and Szymon Ulatowski. See LICENSE.txt for details. 3 // Refer to http://www.framsticks.com/ for further information. 4 1 5 #include "defgenoconv.h" 2 6 … … 4 8 5 9 #ifdef USE_GENCONV_F10 6 #include " conv/conv_f1.h"10 #include "f1/conv_f1.h" 7 11 #endif 8 12 #ifdef USE_GENCONV_F20 9 #include " conv/conv_f2.h"13 #include "f2/conv_f2.h" 10 14 #endif 11 15 #ifdef USE_GENCONV_F32 12 #include " conv/conv_f3.h"16 #include "f3/conv_f3.h" 13 17 #endif 14 18 #ifdef USE_GENCONV_F40 15 #include " conv/conv_f4.h"19 #include "f4/conv_f4.h" 16 20 #endif 17 21 #ifdef USE_GENCONV_F41_TEST 18 #include " conv/conv_f4.h"22 #include "f4/conv_f4.h" 19 23 #endif 20 24 #ifdef USE_GENCONV_F50 21 #include " conv/conv_f5.h"25 #include "f5/conv_f5.h" 22 26 #endif 23 27 #ifdef USE_GENCONV_F60 24 #include " conv/geno_f6.h"28 #include "f6/geno_f6.h" 25 29 #endif 26 30 #ifdef USE_GENCONV_F70 27 #include " conv/conv_f7.h"31 #include "f7/conv_f7.h" 28 32 #endif 29 33 #ifdef USE_GENCONV_F81 30 #include " conv/conv_f8tof1.h"34 #include "f8/conv_f8tof1.h" 31 35 #endif 32 36 #ifdef USE_GENCONV_F90 33 #include " conv/conv_f9.h"37 #include "f9/conv_f9.h" 34 38 #endif 35 39 -
cpp/frams/genetics/defgenoconv.h
r109 r121 1 // This file is a part of the Framsticks GDK library.2 // Copyright (C) 2002-201 1Szymon Ulatowski. See LICENSE.txt for details.1 // This file is a part of the Framsticks GDK. 2 // Copyright (C) 2002-2014 Maciej Komosinski and Szymon Ulatowski. See LICENSE.txt for details. 3 3 // Refer to http://www.framsticks.com/ for further information. 4 4 -
cpp/frams/genetics/f1/conv_f1.cpp
r109 r121 1 // This file is a part of the Framsticks GDK library.2 // Copyright (C) 2002-201 3Szymon Ulatowski. See LICENSE.txt for details.1 // This file is a part of the Framsticks GDK. 2 // Copyright (C) 2002-2014 Maciej Komosinski and Szymon Ulatowski. See LICENSE.txt for details. 3 3 // Refer to http://www.framsticks.com/ for further information. 4 4 -
cpp/frams/genetics/f1/conv_f1.h
r109 r121 1 // This file is a part of the Framsticks GDK library.2 // Copyright (C) 2002-201 1Szymon Ulatowski. See LICENSE.txt for details.1 // This file is a part of the Framsticks GDK. 2 // Copyright (C) 2002-2014 Maciej Komosinski and Szymon Ulatowski. See LICENSE.txt for details. 3 3 // Refer to http://www.framsticks.com/ for further information. 4 4 … … 6 6 #define _CONV_F1_H 7 7 8 #include <frams/genetic /genoconv.h>8 #include <frams/genetics/genoconv.h> 9 9 #include <frams/model/model.h> 10 10 … … 75 75 76 76 #endif 77 78 79 80 81 -
cpp/frams/genetics/gen-config-GDK.h
r109 r121 1 // This file is a part of the Framsticks GDK library. See LICENSE.txt for details. 1 // This file is a part of the Framsticks GDK. 2 // Copyright (C) 2002-2014 Maciej Komosinski and Szymon Ulatowski. See LICENSE.txt for details. 2 3 // Refer to http://www.framsticks.com/ for further information. 4 3 5 4 6 /** … … 16 18 //#define USE_GENCONV_F41_TEST 17 19 //#define USE_GENCONV_F50 20 #define USE_GENCONV_F90 18 21 19 22 //#define USE_GENMAN_F0 -
cpp/frams/genetics/geno.cpp
r109 r121 1 // This file is a part of the Framsticks GDK library.2 // Copyright (C) 2002-201 1Szymon Ulatowski. See LICENSE.txt for details.1 // This file is a part of the Framsticks GDK. 2 // Copyright (C) 2002-2014 Maciej Komosinski and Szymon Ulatowski. See LICENSE.txt for details. 3 3 // Refer to http://www.framsticks.com/ for further information. 4 4 -
cpp/frams/genetics/geno.h
r109 r121 1 // This file is a part of the Framsticks GDK library.2 // Copyright (C) 2002-201 1Szymon Ulatowski. See LICENSE.txt for details.1 // This file is a part of the Framsticks GDK. 2 // Copyright (C) 2002-2014 Maciej Komosinski and Szymon Ulatowski. See LICENSE.txt for details. 3 3 // Refer to http://www.framsticks.com/ for further information. 4 4 -
cpp/frams/genetics/genoconv.cpp
r109 r121 1 // This file is a part of the Framsticks GDK library.2 // Copyright (C) 2002-201 1Szymon Ulatowski. See LICENSE.txt for details.1 // This file is a part of the Framsticks GDK. 2 // Copyright (C) 2002-2014 Maciej Komosinski and Szymon Ulatowski. See LICENSE.txt for details. 3 3 // Refer to http://www.framsticks.com/ for further information. 4 4 -
cpp/frams/genetics/genoconv.h
r109 r121 1 // This file is a part of the Framsticks GDK library.2 // Copyright (C) 2002-201 1Szymon Ulatowski. See LICENSE.txt for details.1 // This file is a part of the Framsticks GDK. 2 // Copyright (C) 2002-2014 Maciej Komosinski and Szymon Ulatowski. See LICENSE.txt for details. 3 3 // Refer to http://www.framsticks.com/ for further information. 4 4 -
cpp/frams/genetics/oper_fx.cpp
r119 r121 1 // This file is a part of the Framsticks G enoFX library.2 // Copyright (C) 2002-201 1 Maciej Komosinski. See LICENSE.txt for details.1 // This file is a part of the Framsticks GDK. 2 // Copyright (C) 2002-2014 Maciej Komosinski and Szymon Ulatowski. See LICENSE.txt for details. 3 3 // Refer to http://www.framsticks.com/ for further information. 4 4 5 5 #include <ctype.h> //isupper() 6 #include " geno_fx.h"6 #include "oper_fx.h" 7 7 #include <common/framsg.h> 8 8 #include <common/nonstd_math.h> … … 33 33 34 34 35 int Geno _fx::roulette(const double *probtab,const int count)35 int GenoOperators::roulette(const double *probtab,const int count) 36 36 { 37 37 double sum=0; … … 43 43 } 44 44 45 bool Geno _fx::getMinMaxDef(ParamInterface *p,int i,double &mn,double &mx,double &def)45 bool GenoOperators::getMinMaxDef(ParamInterface *p,int i,double &mn,double &mx,double &def) 46 46 { 47 47 mn=mx=def=0; … … 68 68 } 69 69 70 int Geno _fx::selectRandomProperty(Neuro* n)70 int GenoOperators::selectRandomProperty(Neuro* n) 71 71 { 72 72 int neuext=n->extraProperties().getPropCount(), … … 78 78 } 79 79 80 double Geno _fx::mutateNeuProperty(double current,Neuro *n,int i)80 double GenoOperators::mutateNeuProperty(double current,Neuro *n,int i) 81 81 { 82 82 if (i==-1) return mutateCreepNoLimit('f',current,-10,10); //i==-1: mutating weight of neural connection … … 89 89 } 90 90 91 bool Geno _fx::mutatePropertyNaive(ParamInterface &p,int i)91 bool GenoOperators::mutatePropertyNaive(ParamInterface &p,int i) 92 92 { 93 93 double mn,mx,df; … … 102 102 } 103 103 104 bool Geno _fx::mutateProperty(ParamInterface &p,int i)104 bool GenoOperators::mutateProperty(ParamInterface &p,int i) 105 105 { 106 106 double newval; … … 112 112 } 113 113 114 bool Geno _fx::getMutatedProperty(ParamInterface &p,int i,double oldval,double &newval)114 bool GenoOperators::getMutatedProperty(ParamInterface &p,int i,double oldval,double &newval) 115 115 { 116 116 newval=0; … … 128 128 } 129 129 130 double Geno _fx::mutateCreepNoLimit(char type,double current,double mn,double mx)130 double GenoOperators::mutateCreepNoLimit(char type,double current,double mn,double mx) 131 131 { 132 132 double result=RndGen.Gauss(current,(mx-mn)/2/5); // /halfinterval, 5 times narrower … … 136 136 } 137 137 138 double Geno _fx::mutateCreep(char type,double current,double mn,double mx)138 double GenoOperators::mutateCreep(char type,double current,double mn,double mx) 139 139 { 140 140 double result=mutateCreepNoLimit(type,current,mn,mx); //TODO consider that when boundary is touched (reflect/absorb below), the default precision (3 digits) may change. Is it good or bad? … … 148 148 } 149 149 150 NeuroClass* Geno _fx::getRandomNeuroClass()150 NeuroClass* GenoOperators::getRandomNeuroClass() 151 151 { 152 152 SListTempl<NeuroClass*> active; … … 156 156 } 157 157 158 NeuroClass* Geno _fx::parseNeuroClass(char*& s)158 NeuroClass* GenoOperators::parseNeuroClass(char*& s) 159 159 { 160 160 int len=strlen(s); … … 171 171 } 172 172 173 Neuro* Geno _fx::findNeuro(const Model *m,const NeuroClass *nc)173 Neuro* GenoOperators::findNeuro(const Model *m,const NeuroClass *nc) 174 174 { 175 175 if (!m) return NULL; … … 179 179 } 180 180 181 int Geno _fx::neuroClassProp(char*& s,NeuroClass *nc,bool also_v1_N_props)181 int GenoOperators::neuroClassProp(char*& s,NeuroClass *nc,bool also_v1_N_props) 182 182 { 183 183 int len=strlen(s); … … 213 213 } 214 214 215 bool Geno _fx::isWS(const char c)215 bool GenoOperators::isWS(const char c) 216 216 {return c==' ' || c=='\n' || c=='\t' || c=='\r';} 217 217 218 void Geno _fx::skipWS(char *&s)219 { if (!s) FramMessage("Geno _fx","skipWS","NULL reference!",1); else218 void GenoOperators::skipWS(char *&s) 219 { if (!s) FramMessage("GenoOperators","skipWS","NULL reference!",1); else 220 220 while (isWS(*s)) s++; 221 221 } 222 222 223 bool Geno _fx::areAlike(char *g1,char *g2)223 bool GenoOperators::areAlike(char *g1,char *g2) 224 224 { 225 225 while (*g1 || *g2) … … 235 235 } 236 236 237 char* Geno _fx::strchrn0(const char *str,char ch)237 char* GenoOperators::strchrn0(const char *str,char ch) 238 238 { return ch==0?NULL:strchr((char*)str,ch); } 239 239 240 bool Geno _fx::isNeuroClassName(const char firstchar)240 bool GenoOperators::isNeuroClassName(const char firstchar) 241 241 { 242 242 return isupper(firstchar) || firstchar=='|' || firstchar=='@' || firstchar=='*'; -
cpp/frams/genetics/oper_fx.h
r119 r121 1 // This file is a part of the Framsticks G enoFX library.2 // Copyright (C) 2002-201 1 Maciej Komosinski. See LICENSE.txt for details.1 // This file is a part of the Framsticks GDK. 2 // Copyright (C) 2002-2014 Maciej Komosinski and Szymon Ulatowski. See LICENSE.txt for details. 3 3 // Refer to http://www.framsticks.com/ for further information. 4 4 5 #ifndef _GENO_ FX_H_6 #define _GENO_ FX_H_5 #ifndef _GENO_OPERATORS_H_ 6 #define _GENO_OPERATORS_H_ 7 7 8 8 #include <common/nonstd.h> … … 49 49 50 50 When designing genetic operations on some representation, inherit your class 51 (for example Geno _fMy) from Geno_fx. Define some methods,51 (for example GenoOper_fMy) from GenoOperators. Define some methods, 52 52 like mutate(), in your class, to allow for evolution. 53 53 Ensure they have the same names and arguments as the corresponding … … 77 77 the available source on developmental encoding and f4 genotype format.*/ 78 78 79 class Geno _fx79 class GenoOperators 80 80 { 81 81 public: … … 84 84 SString name; ///<name of this set of genetic operators 85 85 char **mutation_method_names; ///<array of names for mutation methods. If initialized (by new char*[]), must have entries for each method index returned by mutate(geno,chg,METHOD). If initialized, it is automatically freed by this destructor. 86 Geno _fx() : par(empty_paramtab) {supported_format='x'; name="Default"; mutation_method_names=NULL; setDefaults();}86 GenoOperators() : par(empty_paramtab) {supported_format='x'; name="Default"; mutation_method_names=NULL; setDefaults();} 87 87 88 88 /**Used to perform initializations of Param parameters that are not handled by the Param itself … … 172 172 ///currently not used (similarity of two genotypes) 173 173 virtual float similarity(const char*,const char*) {return GENOPER_NOOPER;} 174 virtual ~Geno _fx() {if (mutation_method_names) {delete []mutation_method_names; mutation_method_names=NULL;}}174 virtual ~GenoOperators() {if (mutation_method_names) {delete []mutation_method_names; mutation_method_names=NULL;}} 175 175 // virtual char getFormat() {return 255;} //returns supported genotype format, for ex. '1' 176 176 // virtual int enabled() {return 1;} // should be enabled by default … … 178 178 /** \name Some helpful methods for you */ 179 179 //@{ 180 180 static int roulette(const double *probtab,const int count); ///<returns random index according to probabilities in the \e probtab table or -1 if all probs are zero. \e count is the number of elements in \e probtab. 181 181 static bool getMinMaxDef(ParamInterface *p,int propindex,double &mn,double &mx,double &def); ///<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). 182 182 static int selectRandomProperty(Neuro* n); ///<selects random property (either 0-based extraproperty of Neuro or 100-based property of its NeuroClass). -1 if Neuro has no properties. … … 194 194 static void skipWS(char *&s); ///<advances pointer \e s skipping whitespaces. 195 195 static bool areAlike(char*,char*); ///<compares two text strings skipping whitespaces. Returns 1 when equal, 0 when different. 196 196 static char* strchrn0(const char *str,char ch); ///<like strchr, but does not find zero char in \e str. 197 197 static bool isNeuroClassName(const char firstchar); ///<determines if \e firstchar may start NeuroClass name. If not, it may start NeuroClass' (or Neuro's) property name. 198 198 //@} … … 216 216 217 217 #endif 218
Note: See TracChangeset
for help on using the changeset viewer.