source: cpp/f8-to-f1/geno_f8.h @ 90

Last change on this file since 90 was 33, checked in by Maciej Komosinski, 15 years ago

maximal f1 genotype length published as the f8->f1 converter parameter

File size: 3.1 KB
RevLine 
[1]1/*
2 *  geno_f8.h
3 *  L-systemToF1
4 *
5 *  Created by Maciej Wajcht on 08-06-07.
6 *  Copyright 2008 __MyCompanyName__. All rights reserved.
7 *
8 */
9
10#ifndef _GENO_F8_H_
11#define _GENO_F8_H_
12
13#include "param.h"
14#include "sstring.h"
15#include "geno_fx.h"
16#include <vector>
17#include "conv_f8tof1.h"
18
19using namespace std;
20
21//indices in array with probabilities of mutation operators
22#define F8_CHANGE_BEGINNING_ARG 0
23#define F8_CHANGE_ARG 1
24#define F8_DELETE_COMMAND 2
25#define F8_INSERT_COMMANDS 3
26#define F8_ENCAPSULATE 4
27#define F8_CHANGE_CONDITION_SIGN 5
28//#define F8_REPLACE_COMMAND 6
29#define F8_ADD_PARAMETER 6
30#define F8_ADD_CONDITION 7
31#define F8_ADD_SUBPRODUCTION 8
32#define F8_CHANGE_ITERATIONS_NUMBER 9
33#define F8_DELETE_PARAMETER 10
34#define F8_DELETE_CONDITION 11
35#define F8_ADD_LOOP 12
36#define F8_DELETE_LOOP 13
[30]37#define F8_DELETE_PRODUCTION 14
38#define F8_OPERATION_COUNT 15
[1]39
40class ProductionInfo {
41public:
42        ProductionInfo() {};
43        ProductionInfo(SString name, int paramCount);
44        SString name;
45        int paramCount;
46        vector<SString> paramNames;
47        bool isFirstProduction;
48};
49
50class Geno_f8 : public Geno_fx {
51public:
52        Geno_f8();
53        ~Geno_f8();
[33]54
55        //probabilities of mutation operators
[1]56        double operation[F8_OPERATION_COUNT];
[33]57
[1]58        int checkValidity(const char * geno);
59        int validate(char * &geno);
60        int mutate(char *&g,float& chg, int &method);
61        int crossOver(char *&g1,char *&g2,float& chg1,float& chg2);
62        unsigned long style(const char *g, int pos);
63        char* getSimplest();
[33]64
[1]65        SString testMutate(SString &in, int method);
66protected:
67        GenoConv_F8ToF1 *converter;
68       
69        vector<char> simpleCommandLetters;
70       
71        int getProductionsCount(const SString &in);
72        vector<ProductionInfo> getProductionsInfo(const SString &in);
73        bool checkProdNameExist(vector<ProductionInfo> info, SString name) const;
74        bool checkParamNameExist(vector<SString> names, SString name) const;
75        SString getOppositeCondition(const SString &c) const;
76        SString removeProductionCalls(const SString production) const;
77        SString mutateChangeBeginningArg(SString &in, float& chg);
78        SString mutateChangeArg(SString &in, float& chg);
79        SString mutateDeleteCommand(SString &in, float& chg);
80        SString mutateInsertCommands(SString &in, float& chg);
81        //SString mutateReplaceCommand(SString &in, float& chg);
82        //SString mutateInsertReplaceCommand(SString &in, float& chg, bool replace);
83        SString mutateEncapsulate(SString &in, float& chg);
[30]84        SString mutateDeleteProduction(SString &in, float& chg);
[1]85        SString mutateChangeConditionSign(SString &in, float& chg);
86        SString mutateAddParameter(SString &in, float& chg);
87        SString mutateAddCondition(SString &in, float& chg);
88        SString mutateDeleteParameter(SString &in, float& chg);
89        SString mutateDeleteCondition(SString &in, float& chg);
90        SString mutateAddLoop(SString &in, float& chg);
91        SString mutateDeleteLoop(SString &in, float& chg);
92        SString mutateAddSubproduction(SString &in, float& chg);
93        SString mutateChangeIterationsNumber(SString &in, float& chg);
94        SString addParameterToCalls(const SString line, SString &prodName);
95        SString deleteParameterFromCalls(const SString line, SString &prodName, int paramIdx);
[6]96private:
97        RelationType getDifferentCondition(RelationType type);
[1]98};
99
100#endif
101
Note: See TracBrowser for help on using the repository browser.