source: cpp/_old/f4/geno_f4.h @ 132

Last change on this file since 132 was 4, checked in by Maciej Komosinski, 16 years ago

added f4, a genetic representation that describes development of an organism

File size: 2.4 KB
Line 
1/*
2 *  geno_f4.h - f4 genetic operators.
3 *
4 *  f4genotype - f4 format genotype conversions for FramSticks
5 *
6 *  Copyright (C) 1999,2000  Adam Rotaru-Varga (adam_rotaru@yahoo.com)
7 *  Copyright (C) 2001-2004  Maciej Komosinski
8 *
9 *  This library is free software; you can redistribute it and/or
10 *  modify it under the terms of the GNU Lesser General Public
11 *  License as published by the Free Software Foundation; either
12 *  version 2.1 of the License, or (at your option) any later version.
13 *
14 *  This library is distributed in the hope that it will be useful,
15 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 *  Lesser General Public License for more details.
18 *
19 *  You should have received a copy of the GNU Lesser General Public
20 *  License along with this library; if not, write to the Free Software
21 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 *
23 */
24
25#ifndef _GENO_F4_H_
26#define _GENO_F4_H_
27
28#include "f4_general.h"
29#include "nonstd.h"
30#include <stdio.h>
31#include "geno_fx.h"
32#include "param.h"
33
34
35#define F4_ADD           0
36#define F4_DEL           1
37#define F4_MOD           2
38#define F4_COUNT         3
39
40#define F4_ADD_DIV       0
41#define F4_ADD_CONN      1
42#define F4_ADD_NEUPAR    2
43#define F4_ADD_REP       3
44#define F4_ADD_SIMP      4
45#define F4_ADD_COUNT     5
46
47
48class Geno_f4: public Geno_fx
49{
50public:
51  Geno_f4();
52  int validate(char *&);
53  int checkValidity(const char *);
54  int mutate(char *& g, float & chg,int &method);
55  int crossOver(char *&g1, char *&g2, float& chg1, float& chg2);
56  char* getSimplest() {return "X";};
57  unsigned long style(const char *g, int pos);
58
59  // mutation probabilities
60  double prob[F4_COUNT],probadd[F4_ADD_COUNT];
61
62protected:
63  /* int MutateMany(char *& g, float & chg); // not used any more */
64  int  ValidateRec(f4_node * geno, int retrycount) const;
65  int  MutateOne(f4_node *& g,int &method) const;
66  void linkNodeMakeRandom(f4_node * nn) const;
67  void linkNodeChangeRandom(f4_node * nn) const;
68  void nparNodeMakeRandom(f4_node * nn) const;
69  void repeatNodeChangeRandom(f4_node * nn) const;
70  int  MutateOneValid(f4_node * &g,int &method) const;
71  int  CrossOverOne(f4_node *g1, f4_node *g2, float chg) const;
72    // returns GENOPER_OK or GENOPER_OPFAIL
73    // chg: fraction of parent1 genes in child (in g1) (parent2 has the rest)
74};
75
76
77#endif
78
Note: See TracBrowser for help on using the repository browser.