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

Last change on this file since 1304 was 1273, checked in by Maciej Komosinski, 15 months ago

fH, fB, fL: improved default parameter values, syntax coloring and code logic

File size: 2.1 KB
RevLine 
[797]1// This file is a part of Framsticks SDK.  http://www.framsticks.com/
[1273]2// Copyright (C) 1999-2023  Maciej Komosinski and Szymon Ulatowski.
[797]3// See LICENSE.txt for details.
4
[780]5#ifndef _FB_OPER_H_
6#define _FB_OPER_H_
7
8#include "../genooperators.h"
[797]9#include <list>
[780]10
11/** @name Codes for general fB mutation types */
12//@{
[1273]13#define FB_SUBSTITUTION     0 ///<Relative probability of changing a single random character (or a neuron) in the genotype
14#define FB_INSERTION        1 ///<Relative probability of inserting a random character in a random place of the genotype
15#define FB_INSERTION_NEURON 2 ///<Relative probability of inserting a neuron in a random place of genotype
16#define FB_DELETION         3 ///<Relative probability of deleting a random character (or a neuron) in the genotype
17#define FB_DUPLICATION      4 ///<Relative probability of copying a single *gene* of the genotype and appending it to the beginning of this genotype
18#define FB_TRANSLOCATION    5 ///<Relative probability of swapping two substrings in the genotype
19#define FB_MUT_COUNT        6 ///<Count of mutation types
[780]20//@}
21
22/** @name Codes for fB cross over types */
23//@{
[1273]24#define FB_GENE_TRANSFER 0 ///<Relative probability of crossing over by copying a single random gene from each parent to the beginning of the other parent
25#define FB_CROSSING_OVER 1 ///<Relative probability of crossing over by a random distribution of genes from both parents to both children
[780]26#define FB_XOVER_COUNT   2 ///<Count of crossing over types
27//@}
28
29class Geno_fB : public GenoOperators
30{
31private:
[821]32        bool hasStick(const SString &genotype);
33        SString detokenizeSequence(std::list<SString> *tokenlist);
34        std::list<SString> tokenizeSequence(const SString &genotype);
[780]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
[1273]50        virtual const char* getSimplest() { return "3\naaazz"; }
[780]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.