source: cpp/frams/genetics/f4/oper_f4.h @ 674

Last change on this file since 674 was 674, checked in by Maciej Komosinski, 7 years ago

f4 modifiers implemented similarly to f1 modifiers, and a base for support for excluding selected modifiers in f4 mutations

  • Property svn:eol-style set to native
File size: 1.9 KB
Line 
1// This file is a part of Framsticks SDK.  http://www.framsticks.com/
2// Copyright (C) 1999-2017  Maciej Komosinski and Szymon Ulatowski.
3// See LICENSE.txt for details.
4
5// Copyright (C) 1999,2000  Adam Rotaru-Varga (adam_rotaru@yahoo.com), GNU LGPL
6// Copyright (C) since 2001 Maciej Komosinski
7
8#ifndef _GENO_F4_H_
9#define _GENO_F4_H_
10
11#include <stdio.h>
12#include "f4_general.h"
13#include "common/nonstd.h"
14#include "../oper_fx.h"
15#include <frams/param/param.h>
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
31class Geno_f4 : public GenoOperators
32{
33public:
34        Geno_f4();
35        void setDefaults();
36
37        int checkValidity(const char *, const char *genoname);
38        int validate(char *&, const char *genoname);
39        int mutate(char *& g, float & chg, int &method);
40        int crossOver(char *&g1, char *&g2, float& chg1, float& chg2);
41        const char* getSimplest() { return "X"; }
42        uint32_t style(const char *g, int pos);
43
44        // mutation probabilities
45        double prob[F4_COUNT], probadd[F4_ADD_COUNT];
46
47        SString excluded_modifiers; //not to be used in mutations
48        static const char *all_modifiers;
49
50protected:
51        /* int MutateMany(char *& g, float & chg); // not used anymore */
52        int  ValidateRec(f4_node * geno, int retrycount) const;
53        int  MutateOne(f4_node *& g, int &method) const;
54        void linkNodeMakeRandom(f4_node * nn) const;
55        void linkNodeChangeRandom(f4_node * nn) const;
56        void nparNodeMakeRandom(f4_node * nn) const;
57        void repeatNodeChangeRandom(f4_node * nn) const;
58        int  MutateOneValid(f4_node * &g, int &method) const;
59        int  CrossOverOne(f4_node *g1, f4_node *g2, float chg) const;
60        // returns GENOPER_OK or GENOPER_OPFAIL
61        // chg: fraction of parent1 genes in child (in g1) (parent2 has the rest)
62};
63
64
65#endif
66
Note: See TracBrowser for help on using the repository browser.