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

Last change on this file since 271 was 247, checked in by Maciej Komosinski, 10 years ago

Sources support both 32-bit and 64-bit, and more compilers

  • Property svn:eol-style set to native
File size: 1.7 KB
Line 
1// This file is a part of the Framsticks GDK.
2// Copyright (C) 1999-2014  Maciej Komosinski and Szymon Ulatowski.  See LICENSE.txt for details.
3// Refer to http://www.framsticks.com/ for further information.
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        int validate(char *&);
36        int checkValidity(const char *);
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"; }
40        uint32_t style(const char *g, int pos);
41
42        // mutation probabilities
43        double prob[F4_COUNT], probadd[F4_ADD_COUNT];
44
45protected:
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)
57};
58
59
60#endif
61
Note: See TracBrowser for help on using the repository browser.