[286] | 1 | // This file is a part of Framsticks SDK. http://www.framsticks.com/ |
---|
| 2 | // Copyright (C) 1999-2015 Maciej Komosinski and Szymon Ulatowski. |
---|
| 3 | // See LICENSE.txt for details. |
---|
[193] | 4 | |
---|
[196] | 5 | // Copyright (C) 1999,2000 Adam Rotaru-Varga (adam_rotaru@yahoo.com), GNU LGPL |
---|
| 6 | // Copyright (C) since 2001 Maciej Komosinski |
---|
| 7 | |
---|
[193] | 8 | #ifndef _GENO_F4_H_ |
---|
| 9 | #define _GENO_F4_H_ |
---|
| 10 | |
---|
[196] | 11 | #include <stdio.h> |
---|
[193] | 12 | #include "f4_general.h" |
---|
[196] | 13 | #include "common/nonstd.h" |
---|
| 14 | #include "../oper_fx.h" |
---|
| 15 | #include <frams/param/param.h> |
---|
[193] | 16 | |
---|
| 17 | |
---|
| 18 | #define F4_ADD 0 |
---|
| 19 | #define F4_DEL 1 |
---|
| 20 | #define F4_MOD 2 |
---|
| 21 | #define F4_COUNT 3 |
---|
| 22 | |
---|
| 23 | #define F4_ADD_DIV 0 |
---|
| 24 | #define F4_ADD_CONN 1 |
---|
| 25 | #define F4_ADD_NEUPAR 2 |
---|
| 26 | #define F4_ADD_REP 3 |
---|
| 27 | #define F4_ADD_SIMP 4 |
---|
| 28 | #define F4_ADD_COUNT 5 |
---|
| 29 | |
---|
| 30 | |
---|
[196] | 31 | class Geno_f4 : public GenoOperators |
---|
[193] | 32 | { |
---|
| 33 | public: |
---|
[196] | 34 | Geno_f4(); |
---|
[513] | 35 | int checkValidity(const char *, const char *genoname); |
---|
| 36 | int validate(char *&, const char *genoname); |
---|
[196] | 37 | int mutate(char *& g, float & chg, int &method); |
---|
| 38 | int crossOver(char *&g1, char *&g2, float& chg1, float& chg2); |
---|
| 39 | const char* getSimplest() { return "X"; } |
---|
[247] | 40 | uint32_t style(const char *g, int pos); |
---|
[193] | 41 | |
---|
[196] | 42 | // mutation probabilities |
---|
| 43 | double prob[F4_COUNT], probadd[F4_ADD_COUNT]; |
---|
[193] | 44 | |
---|
| 45 | protected: |
---|
[196] | 46 | /* int MutateMany(char *& g, float & chg); // not used anymore */ |
---|
| 47 | int ValidateRec(f4_node * geno, int retrycount) const; |
---|
| 48 | int MutateOne(f4_node *& g, int &method) const; |
---|
| 49 | void linkNodeMakeRandom(f4_node * nn) const; |
---|
| 50 | void linkNodeChangeRandom(f4_node * nn) const; |
---|
| 51 | void nparNodeMakeRandom(f4_node * nn) const; |
---|
| 52 | void repeatNodeChangeRandom(f4_node * nn) const; |
---|
| 53 | int MutateOneValid(f4_node * &g, int &method) const; |
---|
| 54 | int CrossOverOne(f4_node *g1, f4_node *g2, float chg) const; |
---|
| 55 | // returns GENOPER_OK or GENOPER_OPFAIL |
---|
| 56 | // chg: fraction of parent1 genes in child (in g1) (parent2 has the rest) |
---|
[193] | 57 | }; |
---|
| 58 | |
---|
| 59 | |
---|
| 60 | #endif |
---|
| 61 | |
---|