Documentation of CSL
simplification.h
Go to the documentation of this file.
1 // This file is part of MARTY.
2 //
3 // MARTY is free software: you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation, either version 3 of the License, or
6 // (at your option) any later version.
7 //
8 // MARTY is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with MARTY. If not, see <https://www.gnu.org/licenses/>.
15 
22 #ifndef SIMPLIFICATION_H_INCLUDED
23 #define SIMPLIFICATION_H_INCLUDED
24 
25 #include "abstract.h"
26 
27 namespace csl {
28 
29 extern bool RANDOM_SEED;
30 
31 extern const int NUMBER_OF_MUTATIONS;
32 
33 extern const int NATURAL_SELECTION;
34 
35 extern const int NUMBER_OF_GENERATION;
36 
37 extern const int GENERATION_BEFORE_SELECTION;
38 
43 extern const int SIMPLIFICATION_METHOD;
44 
50 extern const int MAX_ALTERNATE_FORMS;
51 
57 extern const int MAX_RECURSION_ALTERNATE;
58 
63 void printVector(const csl::vector_expr& vector);
64 
77 void addAlternateForm(csl::vector_expr& alternateForms,
78  const Expr& newAlternate,
79  bool add_factor_expand=true);
80 
85 void reduceAlternate(csl::vector_expr& alternateForms);
86 
91 void clearRedundancyAlternate(csl::vector_expr& alternateForms);
92 
101 csl::vector_expr getRecursiveAlternateForms(const Expr& expr, int depth=-1);
102 
112 csl::vector_expr internalRecursiveAlternateForms(const Expr& expr, int depth=-1);
113 
120 Expr Simplify(const Expr& expr, int depth=-1);
121 
122 int numberOfMutatingNodes(const Expr& expr);
123 
124 bool insertSortMutant(csl::vector_expr& vec, const Expr& newExpr);
125 
126 bool addMutants(csl::vector_expr& individuals,
127  const csl::vector_expr& mutants);
128 
129 csl::vector_expr getRandomMutation(const Expr& expr);
130 
131 void naturalSelection(csl::vector_expr& individuals);
132 
133 Expr evolve(const Expr& baseIndividual);
134 } // End of namespace csl
135 
136 #endif
const int MAX_ALTERNATE_FORMS
Maximum number of alternate forms given by getRecursiveAlternateForms(). When getting alternate forms...
Definition: alternateForms.cpp:39
void addAlternateForm(csl::vector_expr &alternateForms, const Expr &newAlternate, bool add_factor_expand=true)
Tried to add newAlternate in the set alternateForms. We simply test if the alternate is already prese...
Definition: alternateForms.cpp:48
Namespace for csl library.
Definition: abreviation.h:34
Expr Simplify(const Expr &expr, int depth=-1)
Simplifies expr depending on its type.
Definition: alternateForms.cpp:230
csl::vector_expr getRecursiveAlternateForms(const Expr &expr, int depth=-1)
Returns the alternate forms of expr by applying recursively internalRecursiveAlternateForms() MAX_REC...
Definition: alternateForms.cpp:110
const int SIMPLIFICATION_METHOD
Determines which simplification method is applied. Ther used to be 2, now there is only one method...
Definition: alternateForms.cpp:38
void clearRedundancyAlternate(csl::vector_expr &alternateForms)
Search and remove redundancies (equal alternate forms) in alternateForms.
Definition: alternateForms.cpp:100
const int MAX_RECURSION_ALTERNATE
When getting alternateForms, we iterate MAX_RECURSION_ALTERNATE times (getting alternate forms of the...
Definition: alternateForms.cpp:40
csl::vector_expr internalRecursiveAlternateForms(const Expr &expr, int depth=-1)
Calculates and return all alternate forms of expr, by getting (once) alternate forms of the possible ...
Definition: alternateForms.cpp:156
Base classes for all exprs in the program.
void printVector(const csl::vector_expr &vector)
Display a vector of expressions. Useful in debug.
Definition: alternateForms.cpp:42
void reduceAlternate(csl::vector_expr &alternateForms)
Reduces the number of elements in alternateForms to MAX_ALTERNATE_FORMS.
Definition: alternateForms.cpp:72