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

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

added f8 (L-systems) representation and converter f8->f1

File size: 3.0 KB
Line 
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
37#define F8_OPERATION_COUNT 14
38
39class ProductionInfo {
40public:
41        ProductionInfo() {};
42        ProductionInfo(SString name, int paramCount);
43        SString name;
44        int paramCount;
45        vector<SString> paramNames;
46        bool isFirstProduction;
47};
48
49class Geno_f8 : public Geno_fx {
50public:
51        Geno_f8();
52        ~Geno_f8();
53       
54        //probabilities of mutation operators
55        double operation[F8_OPERATION_COUNT];
56       
57        int checkValidity(const char * geno);
58        int validate(char * &geno);
59        int mutate(char *&g,float& chg, int &method);
60        int crossOver(char *&g1,char *&g2,float& chg1,float& chg2);
61        unsigned long style(const char *g, int pos);
62        char* getSimplest();
63       
64        SString testMutate(SString &in, int method);
65protected:
66        GenoConv_F8ToF1 *converter;
67        static const int maxTotalIterations = 200;
68        static const int maxNormalIterations = 100;
69       
70        vector<char> simpleCommandLetters;
71       
72        int getProductionsCount(const SString &in);
73        vector<ProductionInfo> getProductionsInfo(const SString &in);
74        bool checkProdNameExist(vector<ProductionInfo> info, SString name) const;
75        bool checkParamNameExist(vector<SString> names, SString name) const;
76        SString getOppositeCondition(const SString &c) const;
77        SString removeProductionCalls(const SString production) const;
78        SString mutateChangeBeginningArg(SString &in, float& chg);
79        SString mutateChangeArg(SString &in, float& chg);
80        SString mutateDeleteCommand(SString &in, float& chg);
81        SString mutateInsertCommands(SString &in, float& chg);
82        //SString mutateReplaceCommand(SString &in, float& chg);
83        //SString mutateInsertReplaceCommand(SString &in, float& chg, bool replace);
84        SString mutateEncapsulate(SString &in, float& chg);
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);
96};
97
98#endif
99
Note: See TracBrowser for help on using the repository browser.