source: cpp/frams/genetics/fB/fB_oper.h @ 934

Last change on this file since 934 was 821, checked in by Maciej Komosinski, 6 years ago

Performance and stability improvements in fB, fH, and fL; improved parsing and math evaluations in fL

File size: 2.1 KB
Line 
1// This file is a part of Framsticks SDK.  http://www.framsticks.com/
2// Copyright (C) 1999-2018  Maciej Komosinski and Szymon Ulatowski.
3// See LICENSE.txt for details.
4
5#ifndef _FB_OPER_H_
6#define _FB_OPER_H_
7
8#include "../genooperators.h"
9#include <list>
10
11/** @name Codes for general fB mutation types */
12//@{
13#define FB_SUBSTITUTION  0 ///<Relative probability of mutation by changing single random letter in genotype (substitution)
14#define FB_INSERTION     1 ///<Relative probability of mutation by inserting characters in random place of genotype
15#define FB_NCLASSINS     2 ///<Relative probability of mutation by inserting neuron class definition in random place of genotype
16#define FB_DELETION      3 ///<Relative probability of mutation by deleting random characters in genotype
17#define FB_DUPLICATION   4 ///<Relative probability of mutation by copying single *gene* of genotype and appending it to the beginning of this genotype
18#define FB_TRANSLOCATION 5 ///<Relative probability of mutation by replacing two substrings in genotype
19#define FB_MUT_COUNT     6 ///<Count of mutation types
20//@}
21
22/** @name Codes for fB cross over types */
23//@{
24#define FB_GENE_TRANSFER 0 ///<Relative probability of crossing over by transferring single genes from both parents to beginning of each other
25#define FB_CROSSING_OVER 1 ///<Relative probability of crossing over by random distribution of genes from both parents to both children
26#define FB_XOVER_COUNT   2 ///<Count of crossing over types
27//@}
28
29class Geno_fB : public GenoOperators
30{
31private:
32        bool hasStick(const SString &genotype);
33        SString detokenizeSequence(std::list<SString> *tokenlist);
34        std::list<SString> tokenizeSequence(const SString &genotype);
35
36public:
37        double mutationprobs[FB_MUT_COUNT];
38        double crossoverprobs[FB_XOVER_COUNT];
39
40        Geno_fB();
41
42        int checkValidity(const char *geno, const char *genoname);
43
44        int validate(char *&geno, const char *genoname);
45
46        int mutate(char *&geno, float& chg, int &method);
47
48        int crossOver(char *&g1, char *&g2, float& chg1, float& chg2);
49
50        virtual const char* getSimplest() { return "5\naaazz"; }
51
52        uint32_t style(const char *geno, int pos);
53};
54
55#endif //_FB_OPER_H_
Note: See TracBrowser for help on using the repository browser.