Changeset 121 for cpp/frams/genetics/oper_fx.cpp
- Timestamp:
- 02/08/14 06:00:41 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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=='*';
Note: See TracChangeset
for help on using the changeset viewer.