├── .github └── workflows │ └── cmake-multi-platform.yml ├── .gitignore ├── LICENSE ├── README.md ├── algorithm ├── EvolutionaryAlgorithm.h ├── MuPlusLambda.h └── OnePlusLambda.h ├── benchmark ├── BenchmarkFileReader.h └── symbolic_regression │ ├── DatasetGenerator.h │ └── ObjectiveFunctions.h ├── build ├── checkpoint │ └── subdir.mk ├── makefile ├── parameters │ └── subdir.mk ├── random │ └── subdir.mk ├── sources.mk └── subdir.mk ├── cgp.cpp ├── checkpoint └── Checkpoint.h ├── composite └── Composite.h ├── constants ├── ERC.h └── erc_types.h ├── data ├── checkpoints │ └── generation-50.checkpoint ├── datfiles │ ├── koza1.dat │ ├── koza2.dat │ ├── koza3.dat │ ├── nguyen5-test.dat │ ├── nguyen5-training.dat │ ├── nguyen7-test.dat │ ├── nguyen7-training.dat │ ├── pagie-test.dat │ └── pagie-training.dat ├── parfiles │ ├── cgp-parameters-types.txt │ └── cgp.params ├── plufiles │ ├── add1c.plu │ ├── add2c.plu │ ├── add3.plu │ ├── add4.plu │ ├── add5.plu │ ├── add5c.plu │ ├── add6.plu │ ├── add6c.plu │ ├── add8.plu │ ├── add8c.plu │ ├── add_sub3.plu │ ├── add_sub4.plu │ ├── addsub4.plu │ ├── alu2.plu │ ├── alu3.plu │ ├── alu4.plu │ ├── demux16.plu │ ├── demux1x16.plu │ ├── demux1x32.plu │ ├── demux1x64.plu │ ├── demux1x8.plu │ ├── demux32.plu │ ├── demux64.plu │ ├── demux8.plu │ ├── epar10.plu │ ├── epar11.plu │ ├── epar8.plu │ ├── epar9.plu │ ├── icomp3.plu │ ├── icomp3x1.plu │ ├── icomp4.plu │ ├── icomp4x1.plu │ ├── icomp5.plu │ ├── icomp5x1.plu │ ├── icomp6.plu │ ├── icomp6x1.plu │ ├── icomp7.plu │ ├── icomp8.plu │ ├── icomp9.plu │ ├── mcomp3.plu │ ├── mcomp3x3.plu │ ├── mcomp4.plu │ ├── mcomp4x4.plu │ ├── mcomp5.plu │ ├── mcomp5x5.plu │ ├── mcomp6.plu │ ├── mcomp6x6.plu │ ├── mul3.plu │ ├── mul4.plu │ ├── mult3.plu │ └── mult4.plu └── statfiles │ └── 1706782556952.stat ├── evaluator └── Evaluator.h ├── evolver └── Evolver.h ├── fitness └── Fitness.h ├── functions ├── BooleanFunctions.h ├── Functions.h └── MathematicalFunctions.h ├── initializer ├── BlackBoxInitializer.h ├── Initializer.h ├── LogicSynthesisInitializer.h └── SymbolicRegressionInitializer.h ├── mutation ├── Mutation.h └── MutationPipeline.h ├── parameters ├── Parameters.cpp └── Parameters.h ├── population ├── AbstractPopulation.h ├── DynamicPopulation.h └── StaticPopulation.h ├── problems ├── BlackBoxProblem.h ├── LogicSynthesisProblem.h └── SymbolicRegressionProblem.h ├── random ├── Random.cpp └── Random.h ├── recombination └── Recombination.h ├── representation ├── Individual.h └── Species.h ├── template └── template_types.h ├── user-guide.pdf ├── validation └── Validation.h └── variation ├── BinaryOperator.h ├── GeneticOperator.h ├── UnaryOperator.h ├── crossover ├── BlockCrossover.h └── DiscreteCrossover.h └── mutation ├── Duplication.h ├── Inversion.h ├── Phenotypic.h ├── ProbabilisticPoint.h └── SingleActiveGene.h /.github/workflows/cmake-multi-platform.yml: -------------------------------------------------------------------------------- 1 | # This starter workflow is for a CMake project running on multiple platforms. There is a different starter workflow if you just want a single platform. 2 | # See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-single-platform.yml 3 | name: CMake on multiple platforms 4 | 5 | on: 6 | push: 7 | branches: [ "main" ] 8 | pull_request: 9 | branches: [ "main" ] 10 | 11 | jobs: 12 | build: 13 | runs-on: ${{ matrix.os }} 14 | 15 | strategy: 16 | # Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable. 17 | fail-fast: false 18 | 19 | # Set up a matrix to run the following 3 configurations: 20 | # 1. 21 | # 2. 22 | # 3. 23 | # 24 | # To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list. 25 | matrix: 26 | os: [ubuntu-latest, windows-latest] 27 | build_type: [Release] 28 | c_compiler: [gcc, clang, cl] 29 | include: 30 | - os: windows-latest 31 | c_compiler: cl 32 | cpp_compiler: cl 33 | - os: ubuntu-latest 34 | c_compiler: gcc 35 | cpp_compiler: g++ 36 | - os: ubuntu-latest 37 | c_compiler: clang 38 | cpp_compiler: clang++ 39 | exclude: 40 | - os: windows-latest 41 | c_compiler: gcc 42 | - os: windows-latest 43 | c_compiler: clang 44 | - os: ubuntu-latest 45 | c_compiler: cl 46 | 47 | steps: 48 | - uses: actions/checkout@v3 49 | 50 | - name: Set reusable strings 51 | # Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file. 52 | id: strings 53 | shell: bash 54 | run: | 55 | echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT" 56 | 57 | - name: Configure CMake 58 | # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. 59 | # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type 60 | run: > 61 | cmake -B ${{ steps.strings.outputs.build-output-dir }} 62 | -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} 63 | -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} 64 | -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} 65 | -DCMAKE_CXX_STANDARD=17 66 | -DCMAKE_CXX_FLAGS_RELEASE="-O3" 67 | -S ${{ github.workspace }} 68 | 69 | - name: Build 70 | # Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator). 71 | run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} 72 | 73 | - name: Test 74 | working-directory: ${{ steps.strings.outputs.build-output-dir }} 75 | # Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator). 76 | # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail 77 | run: ctest --build-config ${{ matrix.build_type }} 78 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | *.smod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | -------------------------------------------------------------------------------- /algorithm/MuPlusLambda.h: -------------------------------------------------------------------------------- 1 | // CGP++: Modern C++ Implementation of Cartesian Genetic Programming 2 | // =============================================================================== 3 | // File: MuPlusLambda.h 4 | // =============================================================================== 5 | // 6 | // =============================================================================== 7 | // Copyright (C) 2024 8 | // 9 | // 10 | // License: Academic Free License v. 3.0 11 | // ================================================================================ 12 | 13 | #ifndef ALGORITHM_MUPLUSLAMBDA_H_ 14 | #define ALGORITHM_MUPLUSLAMBDA_H_ 15 | 16 | #include "EvolutionaryAlgorithm.h" 17 | 18 | /// @brief Provides a mu+lambda ES that is used to enable crossover-based CGP. 19 | 20 | /// @details This implementation follows the defintion of a mu+lambda EA 21 | /// by Beyer and Schwefel (2002) 22 | 23 | /// @see Beyer, Schwefel: Evolution strategies - A comprehensive introduction. 24 | /// Natural Computing 1, 3–52 (2002). 25 | /// https://doi.org/10.1023/A:1015059928466 26 | 27 | /// @tparam E Evaluation Type 28 | /// @tparam G Genotype Type 29 | /// @tparam F Fitness Type 30 | // 31 | template 32 | class MuPlusLambda: public EvolutionaryAlgorithm { 33 | private: 34 | int mu; 35 | int lambda; 36 | 37 | int select_parent(); 38 | void breed(int num_offspring) override; 39 | public: 40 | MuPlusLambda(std::shared_ptr> p_composite); 41 | virtual ~MuPlusLambda() = default; 42 | 43 | std::pair evolve() override; 44 | 45 | }; 46 | 47 | template 48 | MuPlusLambda::MuPlusLambda( 49 | std::shared_ptr> p_composite) : 50 | EvolutionaryAlgorithm(p_composite) { 51 | this->name = "mu-plus-lambda"; 52 | mu = this->parameters->get_mu(); 53 | lambda = this->parameters->get_lambda(); 54 | this->parameters->set_population_size(mu + lambda); 55 | } 56 | 57 | template 58 | int MuPlusLambda::select_parent() { 59 | return this->random->random_integer(0, this->mu - 1); 60 | } 61 | 62 | /// @brief Breeds new offspring by recombination and mutation by 63 | /// selecting from the parent population. 64 | template 65 | void MuPlusLambda::breed(int num_offspring) { 66 | 67 | for (int i = 0; i < num_offspring; i++) { 68 | 69 | int idx1 = this->select_parent(); 70 | int idx2 = this->select_parent(); 71 | 72 | std::shared_ptr> p1 = this->population->get_individual( 73 | idx1); 74 | std::shared_ptr> p2 = this->population->get_individual( 75 | idx2); 76 | 77 | std::shared_ptr> o1 = 78 | std::make_shared>(p1); 79 | 80 | std::shared_ptr> o2 = 81 | std::make_shared>(p2); 82 | 83 | this->recombination->crossover(o1, o2); 84 | 85 | this->mutation->mutate(o1); 86 | o1->set_evaluated(false); 87 | 88 | this->population->set_individual(o1, this->mu + i); 89 | } 90 | } 91 | 92 | /// @brief Evolves the population in the mu+lambda fashion 93 | /// @return number of fitness evaluations, best fitness 94 | template 95 | std::pair MuPlusLambda::evolve() { 96 | 97 | this->best_fitness = this->fitness->worst_value(); 98 | this->is_ideal = false; 99 | 100 | while (this->generation_number <= this->max_generations && !this->is_ideal) { 101 | 102 | 103 | // Trigger the evaluation process 104 | this->evaluate(); 105 | 106 | // Increase the number of fitness evaluations by the number 107 | // that has been used in the evaluation procedure 108 | this->fitness_evaluations += this->lambda; 109 | 110 | // Sort population for the selection process 111 | this->population->sort(); 112 | 113 | // Obtain best fitness from the sorted population 114 | this->best_fitness = this->population->get_individual(0)->get_fitness(); 115 | 116 | // Trigger reporting intermediate result results 117 | this->report(this->generation_number); 118 | 119 | // Check for ideal fitness 120 | this->check_ideal(this->generation_number); 121 | 122 | // Check for checkpoint modulo 123 | this->check_checkpoint(); 124 | 125 | // Breed lambda offspring 126 | this->breed(lambda); 127 | 128 | this->generation_number++; 129 | 130 | } 131 | 132 | return std::pair { this->fitness_evaluations, this->best_fitness }; 133 | } 134 | 135 | #endif /* ALGORITHM_MUPLUSLAMBDA_H_ */ 136 | -------------------------------------------------------------------------------- /algorithm/OnePlusLambda.h: -------------------------------------------------------------------------------- 1 | // CGP++: Modern C++ Implementation of Cartesian Genetic Programming 2 | // =============================================================================== 3 | // File: OnePlusLambda.h 4 | // =============================================================================== 5 | // 6 | // =============================================================================== 7 | // Copyright (C) 2024 8 | // 9 | // 10 | // License: Academic Free License v. 3.0 11 | // ================================================================================ 12 | 13 | #ifndef ALGORITHM_ONEPLUSLAMBDA_H_ 14 | #define ALGORITHM_ONEPLUSLAMBDA_H_ 15 | 16 | #include "EvolutionaryAlgorithm.h" 17 | #include 18 | #include 19 | 20 | /// @brief Provides the one+lambda ES adaption that is commonly used in CGP. 21 | 22 | /// @details Uses the neutral genetic drift (NGD) as proposed by Miller. 23 | /// This adadption is often used as search algorithm since CGP has been predominantly 24 | /// only with mutation in the past. Considers individuals with equal fitness for selection 25 | // if neutral genetic drift is enabled 26 | 27 | /// @see Miller, 2019: Cartesian genetic programming: its status and future 28 | /// https://link.springer.com/article/10.1007/s10710-019-09360-6 29 | 30 | /// @tparam E Evaluation Type 31 | /// @tparam G Genotype Type 32 | /// @tparam F Fitness Type 33 | template 34 | class OnePlusLambda: public EvolutionaryAlgorithm { 35 | private: 36 | int lambda; 37 | int parent_index; 38 | 39 | bool neutral_genetic_drift = true; 40 | 41 | std::multimap fitness_map; 42 | std::shared_ptr> parent; 43 | 44 | int select_parent(); 45 | void create_fitness_map(); 46 | 47 | void breed(int num_offspring) override; 48 | 49 | public: 50 | OnePlusLambda(std::shared_ptr> p_composite); 51 | virtual ~OnePlusLambda() = default; 52 | 53 | std::pair evolve() override; 54 | 55 | }; 56 | 57 | 58 | template 59 | OnePlusLambda::OnePlusLambda( 60 | std::shared_ptr> p_composite) : 61 | EvolutionaryAlgorithm(p_composite) { 62 | 63 | this->name = "one-plus-lambda"; 64 | lambda = this->parameters->get_lambda(); 65 | this->parameters->set_population_size(1 + lambda); 66 | neutral_genetic_drift = this->parameters->is_neutral_genetic_drift(); 67 | } 68 | 69 | /// @brief Maps the position of the individuals and the corresponding fitness. 70 | /// @details Uses std::multimap for the mapping. 71 | template 72 | void OnePlusLambda::create_fitness_map() { 73 | 74 | this->fitness_map.clear(); 75 | 76 | F fitness; 77 | std::shared_ptr> individual; 78 | 79 | for (int i = 0; i < this->population->size(); i++) { 80 | individual = this->population->get_individual(i); 81 | fitness = individual->get_fitness(); 82 | this->fitness_map.insert(std::pair(fitness, i)); 83 | } 84 | } 85 | 86 | /// @brief Selects the parent for the breeding procedure by using elitism 87 | /// and NGD. 88 | /// @return parent 89 | template 90 | int OnePlusLambda::select_parent() { 91 | 92 | create_fitness_map(); 93 | 94 | // Checking if this is the first parent to be selected 95 | if (this->parent_index == -1) { 96 | // Setting the best fitness as the first fitness in the map 97 | this->best_fitness = this->fitness_map.begin()->first; 98 | // Returning the index of the first individual in the map 99 | return this->fitness_map.begin()->second; 100 | } 101 | 102 | bool is_better; 103 | bool is_equal; 104 | 105 | int rand; 106 | 107 | std::vector better_fitness; 108 | std::vector equal_fitness; 109 | 110 | // Iterate over the fitness map to categorize individuals based on better or equal fitness 111 | for (auto it = this->fitness_map.begin(); it != this->fitness_map.end(); 112 | it++) { 113 | is_better = this->fitness->is_better(it->first, this->best_fitness); 114 | is_equal = (it->first == this->best_fitness); 115 | 116 | if (is_better) { 117 | better_fitness.push_back(it->second); 118 | } else if (is_equal) { 119 | equal_fitness.push_back(it->second); 120 | } else { 121 | break; 122 | } 123 | } 124 | 125 | // Select the parent from the individuals with better fitness 126 | if (better_fitness.size() > 0) { 127 | rand = this->random->random_integer(0, better_fitness.size() - 1); 128 | return better_fitness.at(rand); 129 | // Select the parent from the individuals with equal fitness if neutral genetic drift is enabled 130 | } else if (this->neutral_genetic_drift && equal_fitness.size() > 0) { 131 | rand = this->random->random_integer(0, equal_fitness.size() - 1); 132 | return equal_fitness.at(rand); 133 | 134 | // Return the index of the current parent when no other options are available 135 | } else { 136 | return this->parent_index; 137 | } 138 | 139 | } 140 | 141 | /// @brief Breed lambda offspring by mutation 142 | /// @param num_offspring number of offspring 143 | template 144 | void OnePlusLambda::breed(int num_offspring) { 145 | 146 | std::shared_ptr> parent = this->population->get_individual( 147 | this->parent_index); 148 | 149 | if (this->parent_index != 0) { 150 | this->population->set_individual(parent, 0); 151 | } 152 | 153 | std::shared_ptr genome_parent = parent->get_genome(); 154 | 155 | for (int i = 1; i < this->population->size(); i++) { 156 | std::shared_ptr> offspring = std::make_shared< 157 | Individual>(parent); 158 | this->mutation->mutate(offspring); 159 | offspring->set_evaluated(false); 160 | this->population->set_individual(offspring, i); 161 | } 162 | } 163 | 164 | /// @brief Evolves the population by means of the one+lambda EA with or without NGD. 165 | template 166 | std::pair OnePlusLambda::evolve() { 167 | 168 | this->best_fitness = this->fitness->worst_value(); 169 | this->is_ideal = false; 170 | 171 | if (this->generation_number == 0) { 172 | this->parent_index = -1; 173 | } 174 | 175 | while (this->generation_number <= this->max_generations && !this->is_ideal) { 176 | 177 | this->evaluate(); 178 | 179 | // Increase the number of fitness evaluations by the number 180 | // that has been used in the evaluation procedure 181 | this->fitness_evaluations += this->lambda; 182 | 183 | // Obtain parent with or without considering NGD 184 | this->parent_index = this->select_parent(); 185 | 186 | this->parent = this->population->get_individual(this->parent_index); 187 | 188 | // Obtain best fitness from the sorted population 189 | this->best_fitness = parent->get_fitness(); 190 | 191 | this->report(this->generation_number); 192 | 193 | // Check for ideal fitness 194 | this->check_ideal(this->generation_number); 195 | 196 | // Check for checkpoint modulo 197 | this->check_checkpoint(); 198 | 199 | // Breed lambda offspring 200 | this->breed(lambda); 201 | 202 | // Reset parent index for the next generation 203 | this->parent_index = 0; 204 | 205 | this->generation_number++; 206 | 207 | } 208 | 209 | return std::pair { this->fitness_evaluations, this->best_fitness }; 210 | } 211 | 212 | #endif /* ALGORITHM_ONEPLUSLAMBDA_H_ */ 213 | -------------------------------------------------------------------------------- /benchmark/BenchmarkFileReader.h: -------------------------------------------------------------------------------- 1 | // CGP++: Modern C++ Implementation of Cartesian Genetic Programming 2 | // =============================================================================== 3 | // File: BenchmarkFileReader.h 4 | // =============================================================================== 5 | // 6 | // =============================================================================== 7 | // Copyright (C) 2024 8 | // 9 | // 10 | // License: Academic Free License v. 3.0 11 | // ================================================================================ 12 | 13 | #ifndef BENCHMARKS_BOOL_BENCHMARKREADER_H_ 14 | #define BENCHMARKS_BOOL_BENCHMARKREADER_H_ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | /// @brief Class for reading a benchmark file and providing access to the input and output data. 26 | /// @tparam E Evaluation Type 27 | template 28 | class BenchmarkFileReader { 29 | private: 30 | std::shared_ptr>> inputs; 31 | std::shared_ptr>> outputs; 32 | 33 | std::ifstream ifs; 34 | std::string line; 35 | 36 | int num_inputs; 37 | int num_outputs; 38 | int num_instances; 39 | 40 | public: 41 | BenchmarkFileReader(); 42 | ~BenchmarkFileReader() = default; 43 | void read_benchmark_file(std::string file_path); 44 | void print_data(); 45 | 46 | std::shared_ptr>> get_input_data() const; 47 | std::shared_ptr>> get_output_data() const; 48 | int get_num_instances() const; 49 | int get_num_inputs() const; 50 | int get_num_outputs() const; 51 | }; 52 | 53 | template 54 | BenchmarkFileReader::BenchmarkFileReader() { 55 | inputs = std::make_shared>>(); 56 | outputs = std::make_shared>>(); 57 | } 58 | 59 | /// @brief Prints the input and output data stored in the reader object. 60 | template 61 | void BenchmarkFileReader::print_data() { 62 | 63 | if (inputs.size() == 0) { 64 | throw std::runtime_error("No input data available!"); 65 | return; 66 | } 67 | 68 | if (outputs.size() == 0) { 69 | throw std::runtime_error("No output data available!"); 70 | return; 71 | } 72 | 73 | for (auto vec = inputs.begin(); vec != inputs.end(); 74 | ++vec) { 75 | for (auto it = vec->begin(); it != vec->end(); ++it) { 76 | std::cout << *it << " "; 77 | } 78 | std::cout << std::endl; 79 | } 80 | 81 | std::cout << std::endl; 82 | 83 | for (auto vec = outputs.begin(); vec != outputs.end(); 84 | ++vec) { 85 | for (auto it = vec->begin(); it != vec->end(); ++it) { 86 | std::cout << *it << " "; 87 | } 88 | std::cout << std::endl; 89 | } 90 | 91 | } 92 | 93 | /// @brief Reads the benchmark file and stores the input and output data in the file reader object. 94 | /// @tparam E Evaluation Type 95 | /// @param file_path file path of the benchmark file to be read 96 | template 97 | void BenchmarkFileReader::read_benchmark_file(std::string file_path) { 98 | 99 | if (file_path.size() == 0) { 100 | throw std::runtime_error("File path is an empty string!"); 101 | } 102 | 103 | std::string extension = std::filesystem::path(file_path).extension(); 104 | 105 | // Check if the file extension is valid 106 | if (extension != ".plu" && extension != ".dat") { 107 | throw std::runtime_error("Method only accepts PLU or DAT files!"); 108 | } 109 | 110 | ifs.open(file_path, std::ifstream::in); 111 | 112 | char c; 113 | 114 | if (ifs.is_open()) { 115 | 116 | std::string str; 117 | E input; 118 | E output; 119 | 120 | // Read the meta information from the file 121 | ifs >> str >> num_inputs; 122 | ifs >> str >> num_outputs; 123 | ifs >> str >> num_instances; 124 | 125 | std::vector input_chunk; 126 | std::vector output_chunk; 127 | 128 | // Read the input and output values for each instance 129 | for (int i = 0; i < num_instances; i++) { 130 | 131 | for (int j = 0; j < num_inputs; j++) { 132 | ifs >> input; 133 | input_chunk.push_back(input); 134 | } 135 | 136 | // Inputs and outputs are seperated with whitespaces 137 | // Therefore, we skip this whitespace 138 | do { 139 | ifs.get(c); 140 | } while (ifs.peek() == ' '); 141 | 142 | for (int j = 0; j < num_outputs; j++) { 143 | ifs >> output; 144 | output_chunk.push_back(output); 145 | } 146 | 147 | 148 | inputs->push_back(input_chunk); 149 | outputs->push_back(output_chunk); 150 | 151 | input_chunk.clear(); 152 | output_chunk.clear(); 153 | } 154 | 155 | if (!ifs.good()) { 156 | throw std::runtime_error("Error while reading benchmark file!"); 157 | } 158 | 159 | ifs.close(); 160 | 161 | } else { 162 | throw std::runtime_error("Error opening benchmark file!"); 163 | } 164 | 165 | } 166 | 167 | template 168 | std::shared_ptr>> BenchmarkFileReader::get_input_data() const { 169 | return inputs; 170 | } 171 | 172 | template 173 | std::shared_ptr>> BenchmarkFileReader::get_output_data() const { 174 | return outputs; 175 | } 176 | 177 | template 178 | int BenchmarkFileReader::get_num_instances() const { 179 | return num_instances; 180 | } 181 | 182 | template 183 | int BenchmarkFileReader::get_num_inputs() const { 184 | return num_inputs; 185 | } 186 | 187 | template 188 | int BenchmarkFileReader::get_num_outputs() const { 189 | return num_outputs; 190 | } 191 | 192 | #endif /* BENCHMARKS_BOOL_BENCHMARKREADER_H_ */ 193 | -------------------------------------------------------------------------------- /benchmark/symbolic_regression/ObjectiveFunctions.h: -------------------------------------------------------------------------------- 1 | // CGP++: Modern C++ Implementation of Cartesian Genetic Programming 2 | // =============================================================================== 3 | // File: ObjectiveFunctions.h 4 | // =============================================================================== 5 | // 6 | // =============================================================================== 7 | // Copyright (C) 2024 8 | // 9 | // 10 | // License: Academic Free License v. 3.0 11 | // ================================================================================ 12 | 13 | #ifndef BENCHMARK_SYMBOLIC_REGRESSION_OBJECTIVEFUNCTIONS_H_ 14 | #define BENCHMARK_SYMBOLIC_REGRESSION_OBJECTIVEFUNCTIONS_H_ 15 | 16 | #include 17 | 18 | /// @brief Subset of objective functions proposed by McDermott et al. (2012) 19 | /// @see https://doi.org/10.1145/2330163.2330273 20 | class ObjectiveFunctions { 21 | public: 22 | ObjectiveFunctions() = delete; 23 | 24 | static float polynomial(int degree, float x) { 25 | float res = 0.0; 26 | 27 | for (int i = 0; i <= degree; i++) { 28 | res += pow(x, i); 29 | } 30 | 31 | return res; 32 | } 33 | 34 | static float poly2(float* xs) { 35 | float x = xs[0]; 36 | return x * x + x; 37 | } 38 | 39 | static float poly3(float* xs) { 40 | float x = xs[0]; 41 | return x * x * x + x * x + x; 42 | } 43 | 44 | static float koza1(float* xs) { 45 | float x = xs[0]; 46 | return x * x * x * x + x * x * x + x * x + x; 47 | } 48 | 49 | static float koza3(float* xs) { 50 | float x = xs[0]; 51 | return x * x * x * x * x * x - 2 * x * x * x * x + x * x; 52 | } 53 | 54 | static float koza2(float* xs) { 55 | float x = xs[0]; 56 | return x * x * x * x * x - 2 * x * x * x + x; 57 | } 58 | 59 | static float nguyen3(float* xs) { 60 | float x = xs[0]; 61 | return x * x * x * x * x + x * x * x * x + x * x * x + x * x + x; 62 | } 63 | 64 | static float nguyen4(float* xs) { 65 | float x = xs[0]; 66 | return x * x * x * x * x * x + x * x * x * x * x + x * x * x * x + x * x * x + x * x + x; 67 | } 68 | 69 | static float nguyen5(float* xs) { 70 | float x = xs[0]; 71 | return sin(x * x) * cos(x) - 1; 72 | } 73 | 74 | static float nguyen6(float* xs) { 75 | float x = xs[0]; 76 | return sin(x) * sin(x + x * x); 77 | } 78 | 79 | static float nguyen7(float* xs) { 80 | float x = xs[0]; 81 | return log(x + 1) + log(x * x + 1); 82 | } 83 | 84 | static float nguyen8(float* xs) { 85 | float x = xs[0]; 86 | return sqrt(x); 87 | } 88 | 89 | static float nguyen9(float* xs) { 90 | float x = xs[0]; 91 | float y = xs[1]; 92 | return sin(x) + sin(y * y); 93 | } 94 | 95 | static float nguyen10(float* xs) { 96 | float x = xs[0]; 97 | float y = xs[1]; 98 | return 2.0 * sin(x) * cos(y); 99 | } 100 | 101 | static float keijzer4(float* xs) { 102 | float x = xs[0]; 103 | return x * x * x * exp(-1.0 * x) * cos(x) * sin(x) * (sin(x) * sin(x) * cos(x) - 1); 104 | } 105 | 106 | static float keijzer6(float* xs) { 107 | float x = xs[0]; 108 | float sum = 0; 109 | float fx = floor(x); 110 | int i; 111 | for (i = 1; i < fx + 1; i++) // up to and including floor(x) 112 | { 113 | sum += (1.0 / i); 114 | } 115 | return sum; 116 | } 117 | 118 | static float korns12(float* xs) { 119 | float x = xs[0]; 120 | float w = xs[3]; 121 | return 2.0 - (2.1 * (cos(9.8 * x) * sin(1.3 * w))); 122 | } 123 | 124 | static float vladisleva4(float* xs) { 125 | float sum = 0; 126 | int i; 127 | for (i = 0; i < 5; i++) { 128 | sum += (xs[i] - 3) * (xs[i] - 3); 129 | } 130 | 131 | return 10.0 / (5.0 + sum); 132 | } 133 | 134 | static float vladislavleva6(float* xs) { 135 | float x = xs[0]; 136 | float y = xs[1]; 137 | return 6.0 * sin(x) * cos(y); 138 | } 139 | 140 | static float pagie1(float* xs) { 141 | float x = xs[0]; 142 | float y = xs[1]; 143 | float res = (1.0 / (1.0 + pow(x, -4.0))) + (1.0 / (1.0 + pow(y, -4.0))); 144 | return res; 145 | } 146 | 147 | static int get_num_erc(int problem) { 148 | if (problem == 11 || problem == 12) { 149 | return 1; 150 | } else { 151 | return 2; 152 | } 153 | } 154 | 155 | }; 156 | 157 | #endif /* BENCHMARK_SYMBOLIC_REGRESSION_OBJECTIVEFUNCTIONS_H_ */ 158 | -------------------------------------------------------------------------------- /build/checkpoint/subdir.mk: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Automatically-generated file. Do not edit! 3 | ################################################################################ 4 | 5 | # Add inputs and outputs from these tool invocations to the build variables 6 | 7 | # Each subdirectory must supply rules for building sources it contributes 8 | 9 | -------------------------------------------------------------------------------- /build/makefile: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Automatically-generated file. Do not edit! 3 | ################################################################################ 4 | 5 | -include ../makefile.init 6 | 7 | RM := rm 8 | 9 | # All of the sources participating in the build are defined here 10 | -include sources.mk 11 | -include random/subdir.mk 12 | -include parameters/subdir.mk 13 | -include subdir.mk 14 | ifneq ($(MAKECMDGOALS),clean) 15 | ifneq ($(strip $(C++M_DEPS)),) 16 | -include $(C++M_DEPS) 17 | endif 18 | ifneq ($(strip $(C++_DEPS)),) 19 | -include $(C++_DEPS) 20 | endif 21 | ifneq ($(strip $(CCM_DEPS)),) 22 | -include $(CCM_DEPS) 23 | endif 24 | ifneq ($(strip $(CC_DEPS)),) 25 | -include $(CC_DEPS) 26 | endif 27 | ifneq ($(strip $(CPP_DEPS)),) 28 | -include $(CPP_DEPS) 29 | endif 30 | ifneq ($(strip $(CXXM_DEPS)),) 31 | -include $(CXXM_DEPS) 32 | endif 33 | ifneq ($(strip $(CXX_DEPS)),) 34 | -include $(CXX_DEPS) 35 | endif 36 | ifneq ($(strip $(C_DEPS)),) 37 | -include $(C_DEPS) 38 | endif 39 | ifneq ($(strip $(C_UPPER_DEPS)),) 40 | -include $(C_UPPER_DEPS) 41 | endif 42 | endif 43 | 44 | -include ../makefile.defs 45 | 46 | OPTIONAL_TOOL_DEPS := \ 47 | $(wildcard ../makefile.defs) \ 48 | $(wildcard ../makefile.init) \ 49 | $(wildcard ../makefile.targets) \ 50 | 51 | 52 | BUILD_ARTIFACT_NAME := cartesian-genetic-programming 53 | BUILD_ARTIFACT_EXTENSION := 54 | BUILD_ARTIFACT_PREFIX := 55 | BUILD_ARTIFACT := $(BUILD_ARTIFACT_PREFIX)$(BUILD_ARTIFACT_NAME)$(if $(BUILD_ARTIFACT_EXTENSION),.$(BUILD_ARTIFACT_EXTENSION),) 56 | 57 | # Add inputs and outputs from these tool invocations to the build variables 58 | 59 | # All Target 60 | all: main-build 61 | 62 | # Main-build Target 63 | main-build: cartesian-genetic-programming 64 | 65 | # Tool invocations 66 | cartesian-genetic-programming: $(OBJS) $(USER_OBJS) makefile $(OPTIONAL_TOOL_DEPS) 67 | @echo 'Building target: $@' 68 | @echo 'Invoking: GCC C++ Linker' 69 | g++ -o "cartesian-genetic-programming" $(OBJS) $(USER_OBJS) $(LIBS) 70 | @echo 'Finished building target: $@' 71 | @echo ' ' 72 | 73 | # Other Targets 74 | clean: 75 | -$(RM) cartesian-genetic-programming 76 | -@echo ' ' 77 | 78 | .PHONY: all clean dependents main-build 79 | 80 | -include ../makefile.targets 81 | -------------------------------------------------------------------------------- /build/parameters/subdir.mk: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Automatically-generated file. Do not edit! 3 | ################################################################################ 4 | 5 | # Add inputs and outputs from these tool invocations to the build variables 6 | CPP_SRCS += \ 7 | ../parameters/Parameters.cpp 8 | 9 | CPP_DEPS += \ 10 | ./parameters/Parameters.d 11 | 12 | OBJS += \ 13 | ./parameters/Parameters.o 14 | 15 | 16 | # Each subdirectory must supply rules for building sources it contributes 17 | parameters/%.o: ../parameters/%.cpp parameters/subdir.mk 18 | @echo 'Building file: $<' 19 | @echo 'Invoking: GCC C++ Compiler' 20 | g++ -std=c++17 -O3 -g -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$@" -o "$@" "$<" 21 | @echo 'Finished building: $<' 22 | @echo ' ' 23 | 24 | 25 | clean: clean-parameters 26 | 27 | clean-parameters: 28 | -$(RM) ./parameters/Parameters.d ./parameters/Parameters.o 29 | 30 | .PHONY: clean-parameters 31 | 32 | -------------------------------------------------------------------------------- /build/random/subdir.mk: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Automatically-generated file. Do not edit! 3 | ################################################################################ 4 | 5 | # Add inputs and outputs from these tool invocations to the build variables 6 | CPP_SRCS += \ 7 | ../random/Random.cpp 8 | 9 | CPP_DEPS += \ 10 | ./random/Random.d 11 | 12 | OBJS += \ 13 | ./random/Random.o 14 | 15 | 16 | # Each subdirectory must supply rules for building sources it contributes 17 | random/%.o: ../random/%.cpp random/subdir.mk 18 | @echo 'Building file: $<' 19 | @echo 'Invoking: GCC C++ Compiler' 20 | g++ -std=c++17 -O3 -g -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$@" -o "$@" "$<" 21 | @echo 'Finished building: $<' 22 | @echo ' ' 23 | 24 | 25 | clean: clean-random 26 | 27 | clean-random: 28 | -$(RM) ./random/Random.d ./random/Random.o 29 | 30 | .PHONY: clean-random 31 | 32 | -------------------------------------------------------------------------------- /build/sources.mk: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Automatically-generated file. Do not edit! 3 | ################################################################################ 4 | 5 | ASM_SRCS := 6 | C++M_SRCS := 7 | C++_SRCS := 8 | CCM_SRCS := 9 | CC_SRCS := 10 | CPP_SRCS := 11 | CXXM_SRCS := 12 | CXX_SRCS := 13 | C_SRCS := 14 | C_UPPER_SRCS := 15 | OBJ_SRCS := 16 | O_SRCS := 17 | S_UPPER_SRCS := 18 | C++M_DEPS := 19 | C++_DEPS := 20 | CCM_DEPS := 21 | CC_DEPS := 22 | CPP_DEPS := 23 | CXXM_DEPS := 24 | CXX_DEPS := 25 | C_DEPS := 26 | C_UPPER_DEPS := 27 | EXECUTABLES := 28 | OBJS := 29 | 30 | # Every subdirectory with source files must be described here 31 | SUBDIRS := \ 32 | . \ 33 | parameters \ 34 | random \ 35 | 36 | -------------------------------------------------------------------------------- /build/subdir.mk: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # Automatically-generated file. Do not edit! 3 | ################################################################################ 4 | 5 | # Add inputs and outputs from these tool invocations to the build variables 6 | CPP_SRCS += \ 7 | ../cgp.cpp 8 | 9 | CPP_DEPS += \ 10 | ./cgp.d 11 | 12 | OBJS += \ 13 | ./cgp.o 14 | 15 | 16 | # Each subdirectory must supply rules for building sources it contributes 17 | %.o: ../%.cpp subdir.mk 18 | @echo 'Building file: $<' 19 | @echo 'Invoking: GCC C++ Compiler' 20 | g++ -std=c++17 -O3 -g -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$@" -o "$@" "$<" 21 | @echo 'Finished building: $<' 22 | @echo ' ' 23 | 24 | 25 | clean: clean--2e- 26 | 27 | clean--2e-: 28 | -$(RM) ./cgp.d ./cgp.o 29 | 30 | .PHONY: clean--2e- 31 | 32 | -------------------------------------------------------------------------------- /checkpoint/Checkpoint.h: -------------------------------------------------------------------------------- 1 | // CGP++: Modern C++ Implementation of Cartesian Genetic Programming 2 | // =============================================================================== 3 | // File: Checkpoint.h 4 | // =============================================================================== 5 | // 6 | // =============================================================================== 7 | // Copyright (C) 2024 8 | // 9 | // 10 | // License: Academic Free License v. 3.0 11 | // ================================================================================ 12 | #ifndef CHECKPOINT_CHECKPOINT_H_ 13 | #define CHECKPOINT_CHECKPOINT_H_ 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #include "../algorithm/EvolutionaryAlgorithm.h" 24 | #include "../parameters/Parameters.h" 25 | #include "../population/AbstractPopulation.h" 26 | #include "../random/Random.h" 27 | 28 | using namespace std::chrono; 29 | 30 | /// @brief Handles reading and writing checkpoints for the evolutionary algorithm. 31 | /// @tparam E Evaluation Type 32 | /// @tparam G Genotype Type 33 | /// @tparam F Fitness Type 34 | template 35 | class Checkpoint { 36 | private: 37 | std::shared_ptr parameters; 38 | std::string dir_name; 39 | public: 40 | Checkpoint(std::shared_ptr p_parameters); 41 | virtual ~Checkpoint() = default; 42 | void write(std::shared_ptr> population, 43 | std::shared_ptr> constants, int generation_number); 44 | int load(std::shared_ptr> population, 45 | std::shared_ptr> constants, 46 | std::shared_ptr random, std::string &checkpoint_file_path); 47 | void create_dir(); 48 | void init(); 49 | std::vector split_genome(string genome_str); 50 | }; 51 | 52 | template 53 | Checkpoint::Checkpoint(std::shared_ptr p_parameters) { 54 | if (p_parameters != nullptr) { 55 | this->parameters = p_parameters; 56 | } else { 57 | throw std::invalid_argument( 58 | "Nullpointer exception in checkpoint class!"); 59 | } 60 | } 61 | 62 | template 63 | void Checkpoint::init() { 64 | create_dir(); 65 | } 66 | 67 | 68 | /// @brief Creates a directory for the checkpoint using the current timestamp. 69 | /// @details Concatenates the checkpoint file directory from the Parameters object with 70 | /// the current timestamp to create the directory path. 71 | template 72 | void Checkpoint::create_dir() { 73 | std::stringstream ss; 74 | uint64_t tstamp = duration_cast( 75 | system_clock::now().time_since_epoch()).count(); 76 | ss << this->parameters->CHECKPOINT_FILE_DIR << tstamp; 77 | std::filesystem::create_directories(ss.str()); 78 | ss.str(""); 79 | ss << tstamp; 80 | this->dir_name = ss.str(); 81 | } 82 | 83 | /// @brief Writes the data to a file. 84 | /// @details Creates the file name based on the generation number.The checkpoint data includes the generation number, 85 | /// global seed, genomes of each individual in the population, and constants. 86 | /// @param population 87 | /// @param constants 88 | /// @param generation_number 89 | template 90 | void Checkpoint::write( 91 | std::shared_ptr> population, 92 | std::shared_ptr> constants, int generation_number) { 93 | std::stringstream ss; 94 | std::unique_ptr ofs; 95 | 96 | // Write the genomes of the individuals in the population 97 | ss << this->parameters->CHECKPOINT_FILE_DIR << this->dir_name << "/" 98 | << "generation-" << generation_number << ".checkpoint"; 99 | ofs = std::make_unique(ss.str().c_str(), 100 | istream::out | ios::binary); 101 | ss.str(""); 102 | ss << "generation_number " << generation_number << std::endl; 103 | ss << "global_seed " << this->parameters->get_global_seed() << std::endl; 104 | 105 | // Write the constants 106 | for (int i = 0; i < this->parameters->get_population_size(); i++) { 107 | std::string genome_str = population->get_individual(i)->to_string(","); 108 | ss << "genome " << genome_str << std::endl; 109 | } 110 | 111 | for (int i = 0; i < this->parameters->get_num_constants(); i++) { 112 | E constant = constants->at(i); 113 | ss << "constant " << constant << std::endl; 114 | } 115 | 116 | // Write the content of the stringstream to the file 117 | *ofs << ss.rdbuf(); 118 | } 119 | 120 | /// @brief Loads the checkpoint data from a file and initializes the population and constants accordingly. 121 | /// @details Takes the path to the checkpoint file as input and returns the generation number. 122 | /// @param population 123 | /// @param constants 124 | /// @param random 125 | /// @param checkpoint_file_path 126 | /// @return 127 | template 128 | int Checkpoint::load( 129 | std::shared_ptr> population, 130 | std::shared_ptr> constants, 131 | std::shared_ptr random, std::string &checkpoint_file_path) { 132 | std::ifstream ifs; 133 | ifs.open(checkpoint_file_path, ios_base::in | ios_base::binary); 134 | 135 | std::string parameter; 136 | std::string value; 137 | 138 | double global_seed; 139 | int generation_number; 140 | double constant; 141 | 142 | std::shared_ptr>> genomes = 143 | std::make_shared>>(); 144 | 145 | constants->clear(); 146 | 147 | if (ifs.is_open()) { 148 | while (ifs >> parameter >> value) { 149 | if (parameter == "generation_number") { 150 | generation_number = std::stoi(value); 151 | } else if (parameter == "global_seed") { 152 | global_seed = std::stod(value); 153 | } else if (parameter == "genome") { 154 | std::vector genome = this->split_genome(value); 155 | genomes->push_back(genome); 156 | } else if (parameter == "constant") { 157 | try { 158 | constant = std::stod(value); 159 | } catch (const std::invalid_argument &e) { 160 | std::cerr 161 | << "Constant type is invalid and can't be read by the checkpointer." 162 | <push_back(constant); 165 | } 166 | } 167 | } else { 168 | throw std::runtime_error("Error opening checkpoint file!"); 169 | } 170 | 171 | random->set_seed(global_seed); 172 | population->init_from_checkpoint(genomes); 173 | 174 | return generation_number; 175 | } 176 | 177 | /// @brief Function takes the geome str and splits it into substrings 178 | /// bsed on the occurrence of commas. It tstores these substrings in a vector and returns the vector. 179 | /// @param genome_str The input genome string to split. 180 | /// @return A vector of substrings obtained by splitting the genome string. 181 | template 182 | std::vector Checkpoint::split_genome(string genome_str) { 183 | std::vector vec; 184 | unsigned int pos = 0; 185 | while (pos <= genome_str.size()) { 186 | pos = genome_str.find(","); 187 | vec.push_back(genome_str.substr(0, pos)); 188 | genome_str.erase(0, pos + 1); 189 | } 190 | return vec; 191 | } 192 | 193 | #endif /* CHECKPOINT_CHECKPOINT_H_ */ 194 | -------------------------------------------------------------------------------- /constants/ERC.h: -------------------------------------------------------------------------------- 1 | // CGP++: Modern C++ Implementation of Cartesian Genetic Programming 2 | // =============================================================================== 3 | // File: ERC.h 4 | // =============================================================================== 5 | // 6 | // =============================================================================== 7 | // Copyright (C) 2024 8 | // 9 | // 10 | // License: Academic Free License v. 3.0 11 | // ================================================================================ 12 | 13 | #ifndef ERC_ERC_H_ 14 | #define ERC_ERC_H_ 15 | 16 | #include 17 | #include "../random/Random.h" 18 | #include "erc_types.h" 19 | 20 | /// @brief Represents an ERC (Ephemeral Random Constant) as used in GP. 21 | class ERC { 22 | public: 23 | ERC() = delete; 24 | 25 | // Defines the different types of ERC 26 | static const ERC_TYPE KOZA = 0; 27 | static const ERC_TYPE ONE = 1; 28 | static const ERC_TYPE TWO = 2; 29 | 30 | /// @brief Generate an ERC of the specified type 31 | /// @param p_random Pointer to the random number generator instace 32 | /// @param type The type of ERC to generate 33 | /// @return The generated ERC value 34 | static float generate_ERC(std::shared_ptr p_random, ERC_TYPE type) { 35 | switch (type) { 36 | case KOZA: 37 | return koza(p_random); 38 | break; 39 | 40 | case ONE: 41 | return one(); 42 | break; 43 | 44 | case TWO: 45 | return two(); 46 | break; 47 | 48 | default: 49 | throw std::invalid_argument("Unknown constant type!"); 50 | } 51 | } 52 | 53 | /// @brief Get the name of the ERC typ 54 | /// @param type The type of ERC 55 | /// @return The name of the ERC type as string. 56 | static std::string erc_name(ERC_TYPE type) { 57 | switch (type) { 58 | case KOZA: 59 | return "KOZA"; 60 | break; 61 | 62 | case ONE: 63 | return "ONE"; 64 | break; 65 | 66 | case TWO: 67 | return "TWO"; 68 | break; 69 | 70 | default: 71 | throw std::invalid_argument("Unknown constant type!"); 72 | } 73 | 74 | } 75 | 76 | static float koza(std::shared_ptr p_random) { 77 | return p_random->random_float(-1.0, 1.0); 78 | } 79 | 80 | static float one() { 81 | return 1.0f; 82 | } 83 | 84 | static float two() { 85 | return 2.0f; 86 | } 87 | }; 88 | 89 | #endif /* ERC_H_ */ 90 | -------------------------------------------------------------------------------- /constants/erc_types.h: -------------------------------------------------------------------------------- 1 | typedef unsigned int ERC_TYPE; 2 | -------------------------------------------------------------------------------- /data/checkpoints/generation-50.checkpoint: -------------------------------------------------------------------------------- 1 | generation_number 50 2 | global_seed 1706766371186480657 3 | genome 1,0,1,2,0,2,2,3,1,0,4,3,2,1,2,0,5,2,1,0,0,0,8,4,0,7,1,0,7,3,3 4 | genome 1,0,1,2,0,2,2,3,1,2,4,3,2,1,2,0,5,2,1,0,5,0,8,4,0,7,1,0,7,3,3 5 | genome 1,0,1,2,0,2,2,3,1,0,4,3,2,2,1,0,1,2,1,0,0,0,8,4,0,7,1,0,7,3,3 6 | genome 1,0,1,2,0,2,2,0,1,0,4,3,2,2,1,0,1,2,1,0,0,0,8,4,0,7,1,0,7,1,3 7 | genome 1,0,1,2,0,2,2,3,1,0,4,3,2,2,3,0,1,2,1,0,0,0,8,4,0,7,1,0,7,3,3 8 | genome 1,0,1,2,0,2,2,0,1,0,4,3,2,2,1,0,1,5,1,0,0,0,8,2,0,7,1,0,7,1,3 9 | genome 1,0,1,2,0,2,2,0,1,0,4,3,2,2,0,0,1,4,1,0,0,0,8,4,0,7,1,0,7,1,3 10 | genome 1,0,1,2,0,2,2,3,1,0,4,3,2,1,2,0,5,6,1,0,0,0,8,4,0,7,1,0,7,3,3 11 | genome 1,1,1,0,0,2,2,3,1,2,4,3,2,1,2,1,5,2,1,0,5,0,8,4,0,7,1,0,7,3,3 12 | genome 1,0,1,0,0,2,2,0,1,0,4,3,2,2,1,0,3,2,1,0,0,0,8,4,0,7,1,0,7,8,3 13 | genome 2,0,1,2,0,2,2,3,1,0,4,3,2,2,1,0,1,2,1,5,0,0,3,4,0,7,1,0,7,3,3 14 | genome 1,0,1,2,1,2,2,3,2,2,4,2,2,1,2,0,5,2,1,0,2,0,8,4,0,7,1,0,7,3,3 15 | constant -0.74118 16 | -------------------------------------------------------------------------------- /data/datfiles/koza1.dat: -------------------------------------------------------------------------------- 1 | .i 1 2 | .o 1 3 | .p 20 4 | 0.571965 1.19325 5 | 0.198192 0.2468 6 | 0.332413 0.491852 7 | -0.630832 -0.325559 8 | -0.89878 -0.164464 9 | 0.970743 3.71587 10 | 0.894716 3.05229 11 | 0.147635 0.173123 12 | -0.445633 -0.296104 13 | -0.664529 -0.321376 14 | -0.425338 -0.288645 15 | 0.522597 1.01302 16 | 0.442076 0.762097 17 | -0.659558 -0.32222 18 | 0.0462336 0.0484745 19 | -0.0465327 -0.0444635 20 | -0.172244 -0.146806 21 | -0.781772 -0.274873 22 | 0.151308 0.178191 23 | 0.393863 0.634155 24 | .e -------------------------------------------------------------------------------- /data/datfiles/koza2.dat: -------------------------------------------------------------------------------- 1 | .i 1 2 | .o 1 3 | .p 20 4 | 0.739031 0.152215 5 | 0.330504 0.262244 6 | -0.304348 -0.250577 7 | 0.64282 0.221332 8 | -0.222676 -0.201141 9 | 0.0119791 0.0119757 10 | -0.666952 -0.205567 11 | -0.97182 -0.00300044 12 | -0.0376941 -0.0375871 13 | 0.171218 0.161326 14 | 0.075562 0.0747016 15 | 0.0955608 0.0938235 16 | 0.45767 0.286021 17 | 0.559211 0.264148 18 | -0.756708 -0.138224 19 | 0.538935 0.271332 20 | -0.394065 -0.281181 21 | -0.196844 -0.181885 22 | -0.029379 -0.0293283 23 | -0.794621 -0.107949 24 | .e -------------------------------------------------------------------------------- /data/datfiles/koza3.dat: -------------------------------------------------------------------------------- 1 | .i 1 2 | .o 1 3 | .p 20 4 | -0.0144103 0.000207572 5 | -0.0788583 0.00614154 6 | 0.869528 0.044985 7 | -0.451275 0.129149 8 | 0.137451 0.0181858 9 | 0.240551 0.051362 10 | 0.904437 0.027094 11 | 0.505579 0.141638 12 | 0.896569 0.0309321 13 | 0.201857 0.0374933 14 | -0.692816 0.129793 15 | -0.0423312 0.00178552 16 | 0.313718 0.0799998 17 | 0.131035 0.0165857 18 | -0.282794 0.0676928 19 | 0.47442 0.135159 20 | 0.335302 0.0885686 21 | -0.445235 0.12743 22 | 0.330706 0.0867526 23 | 0.611741 0.146544 24 | .e -------------------------------------------------------------------------------- /data/datfiles/nguyen5-test.dat: -------------------------------------------------------------------------------- 1 | .i 1 2 | .o 1 3 | .p 20 4 | 0.7043888494759429 -0.6372423073967962 5 | 0.06950652988066097 -0.9951805263966008 6 | 0.689478665976688 -0.6468665412598184 7 | 0.9031597970972949 -0.5491458726855738 8 | 0.39506701850893466 -0.8565287753802755 9 | 0.3987588768902144 -0.8540833090550888 10 | -0.5504248971296934 -0.7457122451446752 11 | -0.22495037837928433 -0.9506933016554248 12 | 0.21508855877278887 -0.9548190498729531 13 | 0.007086514090338891 -0.9999497825790212 14 | 0.04823498745720012 -0.9976760941232737 15 | -0.6202969309537034 -0.6945800729971103 16 | 0.8615866505274992 -0.5597605522593034 17 | -0.1565175032076347 -0.9758041487772571 18 | 0.1873034298767422 -0.9655380918823594 19 | -0.34963887873728106 -0.8854348989510167 20 | -0.9115222560188996 -0.5476245030229967 21 | -0.7957540548078375 -0.5859271095979961 22 | -0.577052393516327 -0.7260588505684076 23 | 0.8568520679052982 -0.5612771637423914 24 | .e 25 | -------------------------------------------------------------------------------- /data/datfiles/nguyen5-training.dat: -------------------------------------------------------------------------------- 1 | .i 1 2 | .o 1 3 | .p 20 4 | 0.5359424158541386 -0.756421357536082 5 | -0.05401264812838913 -0.9970868924525943 6 | 0.9872319942538546 -0.5440500650681916 7 | 0.254259670083002 -0.9374740415871102 8 | 0.2435498223464858 -0.9424677810386536 9 | -0.3489321163558865 -0.8858659267026481 10 | 0.06813425030288034 -0.9953685117666855 11 | 0.35205882154955415 -0.8839544658870895 12 | 0.678091791381094 -0.6543996675604061 13 | 0.5518442763148586 -0.7446626948097428 14 | 0.3487204536312549 -0.885994893105748 15 | -0.889657206529523 -0.5520460718134366 16 | -0.08538393228141206 -0.9927362073944345 17 | 0.9477343751550749 -0.5435630474555377 18 | 0.7991731028414419 -0.5843157838905143 19 | -0.8076243730219472 -0.5804438386359019 20 | -0.4370661354171126 -0.8279808764033563 21 | -0.5397119761050393 -0.7536345450959601 22 | 0.8495413499897471 -0.5637365887410979 23 | -0.6901865578022273 -0.6464032801572339 24 | .e 25 | -------------------------------------------------------------------------------- /data/datfiles/nguyen7-test.dat: -------------------------------------------------------------------------------- 1 | .i 1 2 | .o 1 3 | .p 20 4 | 1.3715628526173613 0.913809068929758 5 | 1.9896996074295297 1.753574287701922 6 | 0.9517410410479821 0.43126381111883305 7 | 1.2020720064120924 0.705750701146407 8 | 0.45573831314878266 0.07086519194161338 9 | 0.37324122899198287 0.04136642675387176 10 | 1.4022987205538666 0.9529934259716697 11 | 1.596720032010559 1.2088532232381612 12 | 1.083297948155899 0.5698071727187249 13 | 0.8390659040169928 0.3247325502903502 14 | 1.595127914968564 1.2067099834742356 15 | 0.20577921098985996 0.007760688612500674 16 | 1.4174303685025005 0.9724268015490207 17 | 1.2319282536152796 0.741306014902835 18 | 1.5231135932266053 1.1105249958220083 19 | 0.3174294116100518 0.026466105456539095 20 | 0.05476794184914535 0.00015969776134694047 21 | 0.01146813698859428 1.4995867787812777e-06 22 | 1.5571261279898998 1.1557632975842023 23 | 1.1405294722646218 0.634155307517099 24 | .e 25 | -------------------------------------------------------------------------------- /data/datfiles/nguyen7-training.dat: -------------------------------------------------------------------------------- 1 | .i 1 2 | .o 1 3 | .p 20 4 | 0.8332134529825219 0.3195427532532757 5 | 1.7893528297775685 1.472559017055473 6 | 0.23242913933476017 0.010995766134204603 7 | 0.7383914457726717 0.24063034389130908 8 | 0.1962835024630396 0.006775143049913497 9 | 1.3683349831440141 0.9097171741618426 10 | 0.8429805502615493 0.3282238060988721 11 | 1.7550289978136084 1.425009504963239 12 | 0.12257636175314901 0.0017243600230243646 13 | 1.1043077782212012 0.5931656053322324 14 | 0.8456833094026124 0.33064348438561125 15 | 1.9257403885855289 1.663316281940011 16 | 0.9580121544688955 0.43754188551367473 17 | 0.8673398257031095 0.3503009225411611 18 | 0.10785756165262339 0.0011846935612553672 19 | 0.6905001050867119 0.204691832405701 20 | 0.5267406246586208 0.103613254625999 21 | 0.057688370258798694 0.00018634054890622308 22 | 1.9015084959942985 1.6292396000913787 23 | 1.198908216226476 0.7020133925937211 24 | .e 25 | -------------------------------------------------------------------------------- /data/datfiles/pagie-test.dat: -------------------------------------------------------------------------------- 1 | .i 2 2 | .o 1 3 | .p 101 4 | -5.0 -5.0 1.996805111821086 5 | -4.9 -4.9 1.9965366771945907 6 | -4.800000000000001 -4.800000000000001 1.9962394818306806 7 | -4.700000000000001 -4.700000000000001 1.9959097536219645 8 | -4.600000000000001 -4.600000000000001 1.9955431317878105 9 | -4.500000000000002 -4.500000000000002 1.9951345598297094 10 | -4.400000000000002 -4.400000000000002 1.9946781561727 11 | -4.3000000000000025 -4.3000000000000025 1.994167057230793 12 | -4.200000000000003 -4.200000000000003 1.9935932262462457 13 | -4.100000000000003 -4.100000000000003 1.9929472194589035 14 | -4.0000000000000036 -4.0000000000000036 1.9922178988326849 15 | -3.9000000000000035 -3.9000000000000035 1.991392077526393 16 | -3.8000000000000034 -3.8000000000000034 1.9904540803079134 17 | -3.7000000000000033 -3.7000000000000033 1.9893851958510977 18 | -3.600000000000003 -3.600000000000003 1.9881629908807683 19 | -3.500000000000003 -3.500000000000003 1.9867604468349194 20 | -3.400000000000003 -3.400000000000003 1.9851448672545335 21 | -3.300000000000003 -3.300000000000003 1.983276487326504 22 | -3.200000000000003 -3.200000000000003 1.981106694276084 23 | -3.1000000000000028 -3.1000000000000028 1.978575736378721 24 | -3.0000000000000027 -3.0000000000000027 1.975609756097561 25 | -2.9000000000000026 -2.9000000000000026 1.9721169248871784 26 | -2.8000000000000025 -2.8000000000000025 1.9679823775005763 27 | -2.7000000000000024 -2.7000000000000024 1.96306153394368 28 | -2.6000000000000023 -2.6000000000000023 1.9571712464880422 29 | -2.500000000000002 -2.500000000000002 1.950078003120125 30 | -2.400000000000002 -2.400000000000002 1.9414821403492346 31 | -2.300000000000002 -2.300000000000002 1.9309966498873525 32 | -2.200000000000002 -2.200000000000002 1.9181186951395262 33 | -2.100000000000002 -2.100000000000002 1.9021914016461192 34 | -2.0000000000000018 -2.0000000000000018 1.882352941176471 35 | -1.9000000000000017 -1.9000000000000017 1.857469658853629 36 | -1.8000000000000016 -1.8000000000000016 1.8260506540495414 37 | -1.7000000000000015 -1.7000000000000015 1.7861442884485843 38 | -1.6000000000000014 -1.6000000000000014 1.7352255877991958 39 | -1.5000000000000013 -1.5000000000000013 1.670103092783506 40 | -1.4000000000000012 -1.4000000000000012 1.5869134170522154 41 | -1.3000000000000012 -1.3000000000000012 1.4813412515235613 42 | -1.200000000000001 -1.200000000000001 1.3492972410203035 43 | -1.100000000000001 -1.100000000000001 1.1883446288705832 44 | -1.0000000000000009 -1.0000000000000009 1.0000000000000018 45 | -0.9000000000000009 -0.9000000000000009 0.7923434575206831 46 | -0.8000000000000009 -0.8000000000000009 0.5811577752553936 47 | -0.700000000000001 -0.700000000000001 0.3872268365454416 48 | -0.600000000000001 -0.600000000000001 0.229461756373939 49 | -0.500000000000001 -0.500000000000001 0.1176470588235303 50 | -0.400000000000001 -0.400000000000001 0.04992199687987569 51 | -0.30000000000000104 -0.30000000000000104 0.016069834341831388 52 | -0.20000000000000104 -0.20000000000000104 0.0031948881789138042 53 | -0.10000000000000103 -0.10000000000000103 0.00019998000199980827 54 | -1.0269562977782698e-15 -1.0269562977782698e-15 2.2245278427451163e-60 55 | 0.09999999999999898 0.09999999999999898 0.00019998000199979185 56 | 0.19999999999999898 0.19999999999999898 0.003194888178913673 57 | 0.299999999999999 0.299999999999999 0.016069834341830954 58 | 0.399999999999999 0.399999999999999 0.04992199687987472 59 | 0.499999999999999 0.499999999999999 0.11764705882352852 60 | 0.599999999999999 0.599999999999999 0.2294617563739363 61 | 0.699999999999999 0.699999999999999 0.387226836545438 62 | 0.7999999999999989 0.7999999999999989 0.5811577752553895 63 | 0.8999999999999989 0.8999999999999989 0.7923434575206788 64 | 0.9999999999999989 0.9999999999999989 0.9999999999999978 65 | 1.099999999999999 1.099999999999999 1.18834462887058 66 | 1.199999999999999 1.199999999999999 1.3492972410203006 67 | 1.2999999999999992 1.2999999999999992 1.481341251523559 68 | 1.3999999999999992 1.3999999999999992 1.5869134170522134 69 | 1.4999999999999993 1.4999999999999993 1.6701030927835046 70 | 1.5999999999999994 1.5999999999999994 1.7352255877991947 71 | 1.6999999999999995 1.6999999999999995 1.7861442884485836 72 | 1.7999999999999996 1.7999999999999996 1.8260506540495407 73 | 1.8999999999999997 1.8999999999999997 1.8574696588536284 74 | 1.9999999999999998 1.9999999999999998 1.8823529411764706 75 | 2.0999999999999996 2.0999999999999996 1.9021914016461188 76 | 2.1999999999999997 2.1999999999999997 1.9181186951395257 77 | 2.3 2.3 1.930996649887352 78 | 2.4 2.4 1.9414821403492346 79 | 2.5 2.5 1.9500780031201246 80 | 2.6 2.6 1.9571712464880422 81 | 2.7 2.7 1.9630615339436797 82 | 2.8000000000000003 2.8000000000000003 1.9679823775005763 83 | 2.9000000000000004 2.9000000000000004 1.9721169248871784 84 | 3.0000000000000004 3.0000000000000004 1.975609756097561 85 | 3.1000000000000005 3.1000000000000005 1.978575736378721 86 | 3.2000000000000006 3.2000000000000006 1.981106694276084 87 | 3.3000000000000007 3.3000000000000007 1.983276487326504 88 | 3.400000000000001 3.400000000000001 1.9851448672545335 89 | 3.500000000000001 3.500000000000001 1.9867604468349194 90 | 3.600000000000001 3.600000000000001 1.9881629908807683 91 | 3.700000000000001 3.700000000000001 1.9893851958510977 92 | 3.800000000000001 3.800000000000001 1.9904540803079134 93 | 3.9000000000000012 3.9000000000000012 1.991392077526393 94 | 4.000000000000001 4.000000000000001 1.9922178988326849 95 | 4.1000000000000005 4.1000000000000005 1.9929472194589035 96 | 4.2 4.2 1.9935932262462457 97 | 4.3 4.3 1.994167057230793 98 | 4.3999999999999995 4.3999999999999995 1.9946781561727 99 | 4.499999999999999 4.499999999999999 1.9951345598297094 100 | 4.599999999999999 4.599999999999999 1.9955431317878105 101 | 4.699999999999998 4.699999999999998 1.9959097536219645 102 | 4.799999999999998 4.799999999999998 1.9962394818306806 103 | 4.899999999999998 4.899999999999998 1.9965366771945907 104 | 4.999999999999997 4.999999999999997 1.996805111821086 105 | .e 106 | -------------------------------------------------------------------------------- /data/datfiles/pagie-training.dat: -------------------------------------------------------------------------------- 1 | .i 2 2 | .o 1 3 | .p 25 4 | -5.0 -5.0 1.996805111821086 5 | -4.6 -4.6 1.9955431317878105 6 | -4.199999999999999 -4.199999999999999 1.9935932262462457 7 | -3.7999999999999994 -3.7999999999999994 1.9904540803079134 8 | -3.3999999999999995 -3.3999999999999995 1.9851448672545335 9 | -2.9999999999999996 -2.9999999999999996 1.975609756097561 10 | -2.5999999999999996 -2.5999999999999996 1.9571712464880422 11 | -2.1999999999999997 -2.1999999999999997 1.9181186951395257 12 | -1.7999999999999998 -1.7999999999999998 1.8260506540495407 13 | -1.4 -1.4 1.586913417052214 14 | -0.9999999999999999 -0.9999999999999999 0.9999999999999998 15 | -0.5999999999999999 -0.5999999999999999 0.2294617563739375 16 | -0.19999999999999984 -0.19999999999999984 0.0031948881789137283 17 | 0.20000000000000018 0.20000000000000018 0.0031948881789137496 18 | 0.6000000000000002 0.6000000000000002 0.22946175637393793 19 | 1.0000000000000002 1.0000000000000002 1.0000000000000004 20 | 1.4000000000000004 1.4000000000000004 1.5869134170522146 21 | 1.8000000000000003 1.8000000000000003 1.826050654049541 22 | 2.2 2.2 1.9181186951395257 23 | 2.6 2.6 1.9571712464880422 24 | 3.0 3.0 1.975609756097561 25 | 3.4 3.4 1.9851448672545335 26 | 3.8 3.8 1.9904540803079134 27 | 4.2 4.2 1.9935932262462457 28 | 4.6000000000000005 4.6000000000000005 1.9955431317878105 29 | .e 30 | -------------------------------------------------------------------------------- /data/parfiles/cgp-parameters-types.txt: -------------------------------------------------------------------------------- 1 | algorithm - 0 = one-plus-lambda, 1 = mu-plus-lambda 2 | levels_back - type: integer 3 | 4 | num_jobs - type: integer 5 | num_function_nodes - type: integer 6 | num_variables - type: integer 7 | num_constants - type: integer 8 | constant_type - 0 = Koza 9 | num_outputs - type: integer 10 | num_functions - type: integer 11 | max_arity - type: integer 12 | 13 | num_parents - type: integer 14 | num_offspring - type: integer 15 | 16 | max_fitness_evaluations - type: integer 17 | ideal_fitness - type: generic 18 | minimizing_fitness - 0 = false, 1 = true 19 | 20 | crossover_type - 0 = block, 1 = discrete 21 | crossover_rate - type: float, range: [0.0, 1.0] 22 | 23 | probabilistic_point_mutation - 0 = deactivated, 1 = activated 24 | single_active_gene_mutation - 0 = deactivated, 1 = activated 25 | inversion_mutation - 0 = deactivated, 1 = activated 26 | duplication_mutation - 0 = deactivated, 1 = activated 27 | point_mutation_rate - type: float, range: [0.0, 1.0] 28 | duplication_rate - type: float, range: [0.0, 1.0] 29 | inversion_rate - type: float, range: [0.0, 1.0] 30 | max_duplication_depth - type: integer 31 | max_inversion_depth - type: integer 32 | 33 | neutral_genetic_drift - 0 = deactivated, 1 = activated 34 | simple_report_type - 0 = deactivated, 1 = activated 35 | print_configuration - 0 = deactivated, 1 = activated 36 | evaluate_expression - 0 = deactivated, 1 = activated 37 | 38 | num_eval_threads - type: integer 39 | generate_random_seed - 0 = deactivated, 1 = activated 40 | global_seed - type: long long 41 | 42 | report_during_job - 0 = deactivated, 1 = activated 43 | report_after_job - 0 = deactivated, 1 = activated 44 | report_simple - 0 = deactivated, 1 = activated 45 | report_interval - 0 = deactivated, 1 = activated 46 | 47 | checkpointing - 0 = deactivated, 1 = activated 48 | checkpoint_modulo - type: integer 49 | 50 | write_statfile - 0 = deactivated, 1 = activated -------------------------------------------------------------------------------- /data/parfiles/cgp.params: -------------------------------------------------------------------------------- 1 | algorithm 1 2 | levels_back 1 3 | 4 | num_jobs 100 5 | num_function_nodes 1000 6 | num_variables 1 7 | num_constants 0 8 | constant_type 0 9 | num_outputs 1 10 | num_functions 4 11 | max_arity 2 12 | num_parents 1 13 | num_offspring 1 14 | 15 | max_fitness_evaluations 100000 16 | ideal_fitness 0.01 17 | minimizing_fitness 1 18 | 19 | crossover_type 1 20 | crossover_rate 0.5 21 | 22 | mutation_type 0 23 | probabilistic_point_mutation 1 24 | single_active_gene_mutation 0 25 | inversion_mutation 0 26 | duplication_mutation 0 27 | point_mutation_rate 0.001 28 | duplication_rate 0.05 29 | inversion_rate 0.05 30 | max_duplication_depth 10 31 | max_inversion_depth 10 32 | 33 | neutral_genetic_drift 1 34 | simple_report_type 0 35 | print_configuration 1 36 | evaluate_expression 0 37 | 38 | num_eval_threads 1 39 | 40 | generate_random_seed 1 41 | global_seed 7847239521 42 | 43 | report_during_job 0 44 | report_after_job 1 45 | report_simple 0 46 | report_interval 100 47 | 48 | checkpointing 0 49 | checkpoint_modulo 10 50 | 51 | write_statfile 1 52 | .e 53 | 54 | -------------------------------------------------------------------------------- /data/plufiles/add1c.plu: -------------------------------------------------------------------------------- 1 | .i 3 2 | .o 2 3 | .p 1 4 | 240 204 170 232 150 5 | .e 6 | -------------------------------------------------------------------------------- /data/plufiles/add2c.plu: -------------------------------------------------------------------------------- 1 | .i 5 2 | .o 3 3 | .p 1 4 | 4294901760 4278255360 4042322160 3435973836 2863311530 4277723264 3783728760 2573637990 5 | .e -------------------------------------------------------------------------------- /data/plufiles/add3.plu: -------------------------------------------------------------------------------- 1 | .i 7 2 | .o 4 3 | .p 4 4 | 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 3758129152 534806400 505313400 2576967270 5 | 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 4261476352 33425400 3789653895 2576967270 6 | 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 4292935552 3760160895 505313400 2576967270 7 | 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 4294901752 4261541895 3789653895 2576967270 8 | .e -------------------------------------------------------------------------------- /data/plufiles/add4.plu: -------------------------------------------------------------------------------- 1 | .i 9 2 | .o 5 3 | .p 16 4 | 0 0 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 2147483648 2147450880 2139127680 2021161080 1717986918 5 | 0 0 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 3758096384 536862720 534781920 505290270 2576980377 6 | 0 0 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 4160749568 134215680 133695480 2273806215 1717986918 7 | 0 0 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 4261412864 33553920 33423870 3789677025 2576980377 8 | 0 4294967295 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 4286578688 8388480 2155839615 2021161080 1717986918 9 | 0 4294967295 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 4292870144 2097120 3760185375 505290270 2576980377 10 | 0 4294967295 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 4294443008 524280 4161271815 2273806215 1717986918 11 | 0 4294967295 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 4294836224 131070 4261543425 3789677025 2576980377 12 | 4294967295 0 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 4294934528 2147516415 2139127680 2021161080 1717986918 13 | 4294967295 0 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 4294959104 3758104575 534781920 505290270 2576980377 14 | 4294967295 0 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 4294965248 4160751615 133695480 2273806215 1717986918 15 | 4294967295 0 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 4294966784 4261413375 33423870 3789677025 2576980377 16 | 4294967295 4294967295 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 4294967168 4286578815 2155839615 2021161080 1717986918 17 | 4294967295 4294967295 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 4294967264 4292870175 3760185375 505290270 2576980377 18 | 4294967295 4294967295 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 4294967288 4294443015 4161271815 2273806215 1717986918 19 | 4294967295 4294967295 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 4294967294 4294836225 4261543425 3789677025 2576980377 20 | .e -------------------------------------------------------------------------------- /data/plufiles/add_sub3.plu: -------------------------------------------------------------------------------- 1 | .i 7 2 | .o 4 3 | .p 4 4 | 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 3770712064 507279600 2570282700 1437226410 5 | 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 4277991664 3787687695 2570282700 1437226410 6 | 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 252117761 4034411550 865717350 1437226410 7 | 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 4286529311 260555745 865717350 1437226410 8 | .e -------------------------------------------------------------------------------- /data/plufiles/add_sub4.plu: -------------------------------------------------------------------------------- 1 | .i 9 2 | .o 5 3 | .p 16 4 | 0 0 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 2147483648 2139160320 2021191920 1718013132 1431677610 5 | 0 0 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 3758145536 534790080 505297980 2576954163 1431677610 6 | 0 0 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 4160811008 133697520 2273775375 1718013132 1431677610 7 | 0 0 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 4261477376 33424380 3789669315 2576954163 1431677610 8 | 0 4294967295 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 4286643968 2155806975 2021191920 1718013132 1431677610 9 | 0 4294967295 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 4292935616 3760177215 505297980 2576954163 1431677610 10 | 0 4294967295 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 4294508528 4161269775 2273775375 1718013132 1431677610 11 | 0 4294967295 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 4294901756 4261542915 3789669315 2576954163 1431677610 12 | 4294967295 0 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 196609 66847230 1010572830 3435947622 1431677610 13 | 4294967295 0 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 983047 267388920 4042291320 859019673 1431677610 14 | 4294967295 0 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 4128799 1069555680 3284394465 3435947622 1431677610 15 | 4294967295 0 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 16711807 4278222720 252675975 859019673 1431677610 16 | 4294967295 4294967295 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 67043839 4228120065 1010572830 3435947622 1431677610 17 | 4294967295 4294967295 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 268371967 4027578375 4042291320 859019673 1431677610 18 | 4294967295 4294967295 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 1073684479 3225411615 3284394465 3435947622 1431677610 19 | 4294967295 4294967295 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 4294934527 16744575 252675975 859019673 1431677610 20 | .e 21 | -------------------------------------------------------------------------------- /data/plufiles/addsub4.plu: -------------------------------------------------------------------------------- 1 | .i 9 2 | .o 5 3 | .p 16 4 | 0 0 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 2147483648 2139160320 2021191920 1718013132 1431677610 5 | 0 0 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 3758145536 534790080 505297980 2576954163 1431677610 6 | 0 0 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 4160811008 133697520 2273775375 1718013132 1431677610 7 | 0 0 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 4261477376 33424380 3789669315 2576954163 1431677610 8 | 0 4294967295 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 4286643968 2155806975 2021191920 1718013132 1431677610 9 | 0 4294967295 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 4292935616 3760177215 505297980 2576954163 1431677610 10 | 0 4294967295 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 4294508528 4161269775 2273775375 1718013132 1431677610 11 | 0 4294967295 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 4294901756 4261542915 3789669315 2576954163 1431677610 12 | 4294967295 0 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 196609 66847230 1010572830 3435947622 1431677610 13 | 4294967295 0 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 983047 267388920 4042291320 859019673 1431677610 14 | 4294967295 0 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 4128799 1069555680 3284394465 3435947622 1431677610 15 | 4294967295 0 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 16711807 4278222720 252675975 859019673 1431677610 16 | 4294967295 4294967295 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 67043839 4228120065 1010572830 3435947622 1431677610 17 | 4294967295 4294967295 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 268371967 4027578375 4042291320 859019673 1431677610 18 | 4294967295 4294967295 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 1073684479 3225411615 3284394465 3435947622 1431677610 19 | 4294967295 4294967295 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 4294934527 16744575 252675975 859019673 1431677610 20 | .e 21 | -------------------------------------------------------------------------------- /data/plufiles/alu2.plu: -------------------------------------------------------------------------------- 1 | .i 7 2 | .o 3 3 | .p 5 4 | 0 0 0 65280 61680 52428 43690 0 52224 41120 5 | 0 0 65535 65280 61680 52428 43690 0 65484 64250 6 | 0 65535 0 65280 61680 52428 43690 0 13260 23130 7 | 0 65535 65535 65280 61680 52428 43690 60544 37740 23130 8 | 65535 0 0 65280 61680 52428 43690 2254 14790 23130 9 | .e -------------------------------------------------------------------------------- /data/plufiles/alu3.plu: -------------------------------------------------------------------------------- 1 | .i 9 2 | .o 4 3 | .p 10 4 | 0 0 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 0 0 3435921408 2852170240 5 | 0 0 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 0 4042322160 3435921408 2852170240 6 | 0 0 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 0 4042322160 4294954188 4289396650 7 | 0 0 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 0 4294967295 4294954188 4289396650 8 | 0 4294967295 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 0 4042322160 859032780 1437226410 9 | 0 4294967295 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 0 252645135 859032780 1437226410 10 | 0 4294967295 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 3770712064 507279600 2570282700 1437226410 11 | 0 4294967295 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 4277991664 3787687695 2570282700 1437226410 12 | 4294967295 0 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 235274752 4034411550 865717350 1437226410 13 | 4294967295 0 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 4269686302 260555745 865717350 1437226410 14 | -------------------------------------------------------------------------------- /data/plufiles/alu4.plu: -------------------------------------------------------------------------------- 1 | .i 11 2 | .o 5 3 | .p 40 4 | 0 0 0 0 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 0 0 0 0 2863267840 5 | 0 0 0 0 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 0 0 0 3435973836 2863267840 6 | 0 0 0 0 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 0 0 4042322160 0 2863267840 7 | 0 0 0 0 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 0 0 4042322160 3435973836 2863267840 8 | 0 0 0 4294967295 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 0 4278255360 0 0 2863267840 9 | 0 0 0 4294967295 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 0 4278255360 0 3435973836 2863267840 10 | 0 0 0 4294967295 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 0 4278255360 4042322160 0 2863267840 11 | 0 0 0 4294967295 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 0 4278255360 4042322160 3435973836 2863267840 12 | 0 0 4294967295 0 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 0 4278255360 4042322160 3435973836 4294945450 13 | 0 0 4294967295 0 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 0 4278255360 4042322160 4294967295 4294945450 14 | 0 0 4294967295 0 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 0 4278255360 4294967295 3435973836 4294945450 15 | 0 0 4294967295 0 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 0 4278255360 4294967295 4294967295 4294945450 16 | 0 0 4294967295 4294967295 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 0 4294967295 4042322160 3435973836 4294945450 17 | 0 0 4294967295 4294967295 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 0 4294967295 4042322160 4294967295 4294945450 18 | 0 0 4294967295 4294967295 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 0 4294967295 4294967295 3435973836 4294945450 19 | 0 0 4294967295 4294967295 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 0 4294967295 4294967295 4294967295 4294945450 20 | 0 4294967295 0 0 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 0 4278255360 4042322160 3435973836 1431677610 21 | 0 4294967295 0 0 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 0 4278255360 4042322160 858993459 1431677610 22 | 0 4294967295 0 0 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 0 4278255360 252645135 3435973836 1431677610 23 | 0 4294967295 0 0 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 0 4278255360 252645135 858993459 1431677610 24 | 0 4294967295 0 4294967295 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 0 16711935 4042322160 3435973836 1431677610 25 | 0 4294967295 0 4294967295 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 0 16711935 4042322160 858993459 1431677610 26 | 0 4294967295 0 4294967295 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 0 16711935 252645135 3435973836 1431677610 27 | 0 4294967295 0 4294967295 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 0 16711935 252645135 858993459 1431677610 28 | 0 4294967295 4294967295 0 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 2147483648 2139160320 2021191920 1718013132 1431677610 29 | 0 4294967295 4294967295 0 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 3758145536 534790080 505297980 2576954163 1431677610 30 | 0 4294967295 4294967295 0 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 4160811008 133697520 2273775375 1718013132 1431677610 31 | 0 4294967295 4294967295 0 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 4261477376 33424380 3789669315 2576954163 1431677610 32 | 0 4294967295 4294967295 4294967295 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 4286643968 2155806975 2021191920 1718013132 1431677610 33 | 0 4294967295 4294967295 4294967295 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 4292935616 3760177215 505297980 2576954163 1431677610 34 | 0 4294967295 4294967295 4294967295 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 4294508528 4161269775 2273775375 1718013132 1431677610 35 | 0 4294967295 4294967295 4294967295 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 4294901756 4261542915 3789669315 2576954163 1431677610 36 | 4294967295 0 0 0 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 4294770686 66847230 1010572830 3435947622 1431677610 37 | 4294967295 0 0 0 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 4293984248 267388920 4042291320 859019673 1431677610 38 | 4294967295 0 0 0 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 4290838496 1069555680 3284394465 3435947622 1431677610 39 | 4294967295 0 0 0 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 4278255488 4278222720 252675975 859019673 1431677610 40 | 4294967295 0 0 4294967295 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 4227923456 4228120065 1010572830 3435947622 1431677610 41 | 4294967295 0 0 4294967295 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 4026595328 4027578375 4042291320 859019673 1431677610 42 | 4294967295 0 0 4294967295 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 3221282816 3225411615 3284394465 3435947622 1431677610 43 | 4294967295 0 0 4294967295 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 32768 16744575 252675975 859019673 1431677610 44 | .e -------------------------------------------------------------------------------- /data/plufiles/demux16.plu: -------------------------------------------------------------------------------- 1 | .i 5 2 | .o 16 3 | .p 1 4 | 4294901760 4278255360 4042322160 3435973836 2863311530 2 8 32 128 512 2048 8192 32768 131072 524288 2097152 8388608 33554432 134217728 536870912 2147483648 5 | .e 6 | -------------------------------------------------------------------------------- /data/plufiles/demux1x16.plu: -------------------------------------------------------------------------------- 1 | .i 5 2 | .o 16 3 | .p 1 4 | 4294901760 4278255360 4042322160 3435973836 2863311530 2 8 32 128 512 2048 8192 32768 131072 524288 2097152 8388608 33554432 134217728 536870912 2147483648 5 | .e 6 | -------------------------------------------------------------------------------- /data/plufiles/demux1x32.plu: -------------------------------------------------------------------------------- 1 | .i 6 2 | .o 32 3 | .p 2 4 | 0 4294901760 4278255360 4042322160 3435973836 2863311530 2 8 32 128 512 2048 8192 32768 131072 524288 2097152 8388608 33554432 134217728 536870912 2147483648 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5 | 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 8 32 128 512 2048 8192 32768 131072 524288 2097152 8388608 33554432 134217728 536870912 2147483648 6 | .e 7 | -------------------------------------------------------------------------------- /data/plufiles/demux1x64.plu: -------------------------------------------------------------------------------- 1 | .i 7 2 | .o 64 3 | .p 4 4 | 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 2 8 32 128 512 2048 8192 32768 131072 524288 2097152 8388608 33554432 134217728 536870912 2147483648 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5 | 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 8 32 128 512 2048 8192 32768 131072 524288 2097152 8388608 33554432 134217728 536870912 2147483648 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 | 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 8 32 128 512 2048 8192 32768 131072 524288 2097152 8388608 33554432 134217728 536870912 2147483648 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7 | 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 8 32 128 512 2048 8192 32768 131072 524288 2097152 8388608 33554432 134217728 536870912 2147483648 8 | .e 9 | -------------------------------------------------------------------------------- /data/plufiles/demux1x8.plu: -------------------------------------------------------------------------------- 1 | .i 4 2 | .o 8 3 | .p 1 4 | 65280 61680 52428 43690 2 8 32 128 512 2048 8192 32768 5 | .e 6 | -------------------------------------------------------------------------------- /data/plufiles/demux32.plu: -------------------------------------------------------------------------------- 1 | .i 6 2 | .o 32 3 | .p 2 4 | 0 4294901760 4278255360 4042322160 3435973836 2863311530 2 8 32 128 512 2048 8192 32768 131072 524288 2097152 8388608 33554432 134217728 536870912 2147483648 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5 | 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 8 32 128 512 2048 8192 32768 131072 524288 2097152 8388608 33554432 134217728 536870912 2147483648 6 | .e 7 | -------------------------------------------------------------------------------- /data/plufiles/demux64.plu: -------------------------------------------------------------------------------- 1 | .i 7 2 | .o 64 3 | .p 4 4 | 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 2 8 32 128 512 2048 8192 32768 131072 524288 2097152 8388608 33554432 134217728 536870912 2147483648 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5 | 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 8 32 128 512 2048 8192 32768 131072 524288 2097152 8388608 33554432 134217728 536870912 2147483648 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 | 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 8 32 128 512 2048 8192 32768 131072 524288 2097152 8388608 33554432 134217728 536870912 2147483648 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7 | 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 8 32 128 512 2048 8192 32768 131072 524288 2097152 8388608 33554432 134217728 536870912 2147483648 8 | .e 9 | -------------------------------------------------------------------------------- /data/plufiles/demux8.plu: -------------------------------------------------------------------------------- 1 | .i 4 2 | .o 8 3 | .p 1 4 | 65280 61680 52428 43690 2 8 32 128 512 2048 8192 32768 5 | .e 6 | -------------------------------------------------------------------------------- /data/plufiles/epar10.plu: -------------------------------------------------------------------------------- 1 | .i 10 2 | .o 1 3 | .p 32 4 | 0 0 0 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 1771476585 5 | 0 0 0 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 2523490710 6 | 0 0 0 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 2523490710 7 | 0 0 0 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 1771476585 8 | 0 0 4294967295 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 2523490710 9 | 0 0 4294967295 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 1771476585 10 | 0 0 4294967295 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 1771476585 11 | 0 0 4294967295 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 2523490710 12 | 0 4294967295 0 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 2523490710 13 | 0 4294967295 0 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 1771476585 14 | 0 4294967295 0 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 1771476585 15 | 0 4294967295 0 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 2523490710 16 | 0 4294967295 4294967295 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 1771476585 17 | 0 4294967295 4294967295 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 2523490710 18 | 0 4294967295 4294967295 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 2523490710 19 | 0 4294967295 4294967295 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 1771476585 20 | 4294967295 0 0 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 2523490710 21 | 4294967295 0 0 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 1771476585 22 | 4294967295 0 0 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 1771476585 23 | 4294967295 0 0 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 2523490710 24 | 4294967295 0 4294967295 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 1771476585 25 | 4294967295 0 4294967295 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 2523490710 26 | 4294967295 0 4294967295 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 2523490710 27 | 4294967295 0 4294967295 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 1771476585 28 | 4294967295 4294967295 0 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 1771476585 29 | 4294967295 4294967295 0 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 2523490710 30 | 4294967295 4294967295 0 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 2523490710 31 | 4294967295 4294967295 0 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 1771476585 32 | 4294967295 4294967295 4294967295 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 2523490710 33 | 4294967295 4294967295 4294967295 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 1771476585 34 | 4294967295 4294967295 4294967295 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 1771476585 35 | 4294967295 4294967295 4294967295 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 2523490710 36 | .e -------------------------------------------------------------------------------- /data/plufiles/epar11.plu: -------------------------------------------------------------------------------- 1 | .i 11 2 | .o 1 3 | .p 64 4 | 0 0 0 0 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 1771476585 5 | 0 0 0 0 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 2523490710 6 | 0 0 0 0 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 2523490710 7 | 0 0 0 0 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 1771476585 8 | 0 0 0 4294967295 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 2523490710 9 | 0 0 0 4294967295 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 1771476585 10 | 0 0 0 4294967295 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 1771476585 11 | 0 0 0 4294967295 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 2523490710 12 | 0 0 4294967295 0 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 2523490710 13 | 0 0 4294967295 0 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 1771476585 14 | 0 0 4294967295 0 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 1771476585 15 | 0 0 4294967295 0 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 2523490710 16 | 0 0 4294967295 4294967295 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 1771476585 17 | 0 0 4294967295 4294967295 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 2523490710 18 | 0 0 4294967295 4294967295 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 2523490710 19 | 0 0 4294967295 4294967295 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 1771476585 20 | 0 4294967295 0 0 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 2523490710 21 | 0 4294967295 0 0 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 1771476585 22 | 0 4294967295 0 0 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 1771476585 23 | 0 4294967295 0 0 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 2523490710 24 | 0 4294967295 0 4294967295 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 1771476585 25 | 0 4294967295 0 4294967295 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 2523490710 26 | 0 4294967295 0 4294967295 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 2523490710 27 | 0 4294967295 0 4294967295 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 1771476585 28 | 0 4294967295 4294967295 0 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 1771476585 29 | 0 4294967295 4294967295 0 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 2523490710 30 | 0 4294967295 4294967295 0 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 2523490710 31 | 0 4294967295 4294967295 0 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 1771476585 32 | 0 4294967295 4294967295 4294967295 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 2523490710 33 | 0 4294967295 4294967295 4294967295 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 1771476585 34 | 0 4294967295 4294967295 4294967295 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 1771476585 35 | 0 4294967295 4294967295 4294967295 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 2523490710 36 | 4294967295 0 0 0 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 2523490710 37 | 4294967295 0 0 0 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 1771476585 38 | 4294967295 0 0 0 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 1771476585 39 | 4294967295 0 0 0 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 2523490710 40 | 4294967295 0 0 4294967295 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 1771476585 41 | 4294967295 0 0 4294967295 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 2523490710 42 | 4294967295 0 0 4294967295 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 2523490710 43 | 4294967295 0 0 4294967295 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 1771476585 44 | 4294967295 0 4294967295 0 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 1771476585 45 | 4294967295 0 4294967295 0 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 2523490710 46 | 4294967295 0 4294967295 0 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 2523490710 47 | 4294967295 0 4294967295 0 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 1771476585 48 | 4294967295 0 4294967295 4294967295 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 2523490710 49 | 4294967295 0 4294967295 4294967295 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 1771476585 50 | 4294967295 0 4294967295 4294967295 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 1771476585 51 | 4294967295 0 4294967295 4294967295 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 2523490710 52 | 4294967295 4294967295 0 0 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 1771476585 53 | 4294967295 4294967295 0 0 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 2523490710 54 | 4294967295 4294967295 0 0 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 2523490710 55 | 4294967295 4294967295 0 0 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 1771476585 56 | 4294967295 4294967295 0 4294967295 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 2523490710 57 | 4294967295 4294967295 0 4294967295 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 1771476585 58 | 4294967295 4294967295 0 4294967295 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 1771476585 59 | 4294967295 4294967295 0 4294967295 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 2523490710 60 | 4294967295 4294967295 4294967295 0 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 2523490710 61 | 4294967295 4294967295 4294967295 0 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 1771476585 62 | 4294967295 4294967295 4294967295 0 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 1771476585 63 | 4294967295 4294967295 4294967295 0 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 2523490710 64 | 4294967295 4294967295 4294967295 4294967295 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 1771476585 65 | 4294967295 4294967295 4294967295 4294967295 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 2523490710 66 | 4294967295 4294967295 4294967295 4294967295 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 2523490710 67 | 4294967295 4294967295 4294967295 4294967295 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 1771476585 68 | .e -------------------------------------------------------------------------------- /data/plufiles/epar8.plu: -------------------------------------------------------------------------------- 1 | .i 8 2 | .o 1 3 | .p 8 4 | 0 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 1771476585 5 | 0 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 2523490710 6 | 0 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 2523490710 7 | 0 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 1771476585 8 | 4294967295 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 2523490710 9 | 4294967295 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 1771476585 10 | 4294967295 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 1771476585 11 | 4294967295 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 2523490710 12 | .e -------------------------------------------------------------------------------- /data/plufiles/epar9.plu: -------------------------------------------------------------------------------- 1 | .i 9 2 | .o 1 3 | .p 16 4 | 0 0 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 1771476585 5 | 0 0 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 2523490710 6 | 0 0 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 2523490710 7 | 0 0 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 1771476585 8 | 0 4294967295 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 2523490710 9 | 0 4294967295 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 1771476585 10 | 0 4294967295 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 1771476585 11 | 0 4294967295 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 2523490710 12 | 4294967295 0 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 2523490710 13 | 4294967295 0 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 1771476585 14 | 4294967295 0 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 1771476585 15 | 4294967295 0 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 2523490710 16 | 4294967295 4294967295 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 1771476585 17 | 4294967295 4294967295 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 2523490710 18 | 4294967295 4294967295 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 2523490710 19 | 4294967295 4294967295 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 1771476585 20 | .e -------------------------------------------------------------------------------- /data/plufiles/icomp3.plu: -------------------------------------------------------------------------------- 1 | .i 3 2 | .o 9 3 | .p 1 4 | 240 204 170 12 195 48 10 165 80 34 153 68 5 | .e 6 | -------------------------------------------------------------------------------- /data/plufiles/icomp3x1.plu: -------------------------------------------------------------------------------- 1 | .i 3 2 | .o 9 3 | .p 1 4 | 240 204 170 12 195 48 10 165 80 34 153 68 5 | .e 6 | -------------------------------------------------------------------------------- /data/plufiles/icomp4.plu: -------------------------------------------------------------------------------- 1 | .i 4 2 | .o 18 3 | .p 1 4 | 65280 61680 52428 43690 240 61455 3840 204 52275 13056 170 43605 21760 3084 50115 12336 2570 42405 20560 8738 39321 17476 5 | .e 6 | -------------------------------------------------------------------------------- /data/plufiles/icomp4x1.plu: -------------------------------------------------------------------------------- 1 | .i 4 2 | .o 18 3 | .p 1 4 | 65280 61680 52428 43690 240 61455 3840 204 52275 13056 170 43605 21760 3084 50115 12336 2570 42405 20560 8738 39321 17476 5 | .e 6 | -------------------------------------------------------------------------------- /data/plufiles/icomp5.plu: -------------------------------------------------------------------------------- 1 | .i 5 2 | .o 30 3 | .p 1 4 | 4294901760 4278255360 4042322160 3435973836 2863311530 65280 4278190335 16711680 61680 4042264335 252641280 52428 3435934515 858980352 43690 2863289685 1431633920 15728880 4027576335 251662080 13369548 3425946675 855651072 11141290 2857740885 1426085120 202116108 3284386755 808464432 168430090 2779096485 1347440720 572662306 2576980377 1145324612 5 | .e 6 | -------------------------------------------------------------------------------- /data/plufiles/icomp5x1.plu: -------------------------------------------------------------------------------- 1 | .i 5 2 | .o 30 3 | .p 1 4 | 4294901760 4278255360 4042322160 3435973836 2863311530 65280 4278190335 16711680 61680 4042264335 252641280 52428 3435934515 858980352 43690 2863289685 1431633920 15728880 4027576335 251662080 13369548 3425946675 855651072 11141290 2857740885 1426085120 202116108 3284386755 808464432 168430090 2779096485 1347440720 572662306 2576980377 1145324612 5 | .e 6 | -------------------------------------------------------------------------------- /data/plufiles/icomp6.plu: -------------------------------------------------------------------------------- 1 | .i 6 2 | .o 45 3 | .p 2 4 | 0 4294901760 4278255360 4042322160 3435973836 2863311530 4294901760 65535 0 4278255360 16711935 0 4042322160 252645135 0 3435973836 858993459 0 2863311530 1431655765 0 65280 4278190335 16711680 61680 4042264335 252641280 52428 3435934515 858980352 43690 2863289685 1431633920 15728880 4027576335 251662080 13369548 3425946675 855651072 11141290 2857740885 1426085120 202116108 3284386755 808464432 168430090 2779096485 1347440720 572662306 2576980377 1145324612 5 | 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 0 4294901760 65535 0 4278255360 16711935 0 4042322160 252645135 0 3435973836 858993459 0 2863311530 1431655765 65280 4278190335 16711680 61680 4042264335 252641280 52428 3435934515 858980352 43690 2863289685 1431633920 15728880 4027576335 251662080 13369548 3425946675 855651072 11141290 2857740885 1426085120 202116108 3284386755 808464432 168430090 2779096485 1347440720 572662306 2576980377 1145324612 6 | .e 7 | -------------------------------------------------------------------------------- /data/plufiles/icomp6x1.plu: -------------------------------------------------------------------------------- 1 | .i 6 2 | .o 45 3 | .p 2 4 | 0 4294901760 4278255360 4042322160 3435973836 2863311530 4294901760 65535 0 4278255360 16711935 0 4042322160 252645135 0 3435973836 858993459 0 2863311530 1431655765 0 65280 4278190335 16711680 61680 4042264335 252641280 52428 3435934515 858980352 43690 2863289685 1431633920 15728880 4027576335 251662080 13369548 3425946675 855651072 11141290 2857740885 1426085120 202116108 3284386755 808464432 168430090 2779096485 1347440720 572662306 2576980377 1145324612 5 | 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 0 4294901760 65535 0 4278255360 16711935 0 4042322160 252645135 0 3435973836 858993459 0 2863311530 1431655765 65280 4278190335 16711680 61680 4042264335 252641280 52428 3435934515 858980352 43690 2863289685 1431633920 15728880 4027576335 251662080 13369548 3425946675 855651072 11141290 2857740885 1426085120 202116108 3284386755 808464432 168430090 2779096485 1347440720 572662306 2576980377 1145324612 6 | .e 7 | -------------------------------------------------------------------------------- /data/plufiles/icomp7.plu: -------------------------------------------------------------------------------- 1 | .i 7 2 | .o 63 3 | .p 4 4 | 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 0 4294967295 0 4294901760 65535 0 4278255360 16711935 0 4042322160 252645135 0 3435973836 858993459 0 2863311530 1431655765 0 4294901760 65535 0 4278255360 16711935 0 4042322160 252645135 0 3435973836 858993459 0 2863311530 1431655765 0 65280 4278190335 16711680 61680 4042264335 252641280 52428 3435934515 858980352 43690 2863289685 1431633920 15728880 4027576335 251662080 13369548 3425946675 855651072 11141290 2857740885 1426085120 202116108 3284386755 808464432 168430090 2779096485 1347440720 572662306 2576980377 1145324612 5 | 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 4294967295 0 0 4294901760 65535 0 4278255360 16711935 0 4042322160 252645135 0 3435973836 858993459 0 2863311530 1431655765 0 0 4294901760 65535 0 4278255360 16711935 0 4042322160 252645135 0 3435973836 858993459 0 2863311530 1431655765 65280 4278190335 16711680 61680 4042264335 252641280 52428 3435934515 858980352 43690 2863289685 1431633920 15728880 4027576335 251662080 13369548 3425946675 855651072 11141290 2857740885 1426085120 202116108 3284386755 808464432 168430090 2779096485 1347440720 572662306 2576980377 1145324612 6 | 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 0 0 4294967295 0 4294901760 65535 0 4278255360 16711935 0 4042322160 252645135 0 3435973836 858993459 0 2863311530 1431655765 4294901760 65535 0 4278255360 16711935 0 4042322160 252645135 0 3435973836 858993459 0 2863311530 1431655765 0 65280 4278190335 16711680 61680 4042264335 252641280 52428 3435934515 858980352 43690 2863289685 1431633920 15728880 4027576335 251662080 13369548 3425946675 855651072 11141290 2857740885 1426085120 202116108 3284386755 808464432 168430090 2779096485 1347440720 572662306 2576980377 1145324612 7 | 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 0 4294967295 0 0 4294901760 65535 0 4278255360 16711935 0 4042322160 252645135 0 3435973836 858993459 0 2863311530 1431655765 0 4294901760 65535 0 4278255360 16711935 0 4042322160 252645135 0 3435973836 858993459 0 2863311530 1431655765 65280 4278190335 16711680 61680 4042264335 252641280 52428 3435934515 858980352 43690 2863289685 1431633920 15728880 4027576335 251662080 13369548 3425946675 855651072 11141290 2857740885 1426085120 202116108 3284386755 808464432 168430090 2779096485 1347440720 572662306 2576980377 1145324612 8 | .e -------------------------------------------------------------------------------- /data/plufiles/icomp8.plu: -------------------------------------------------------------------------------- 1 | .i 8 2 | .o 84 3 | .p 8 4 | 0 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 0 4294967295 0 0 4294967295 0 4294901760 65535 0 4278255360 16711935 0 4042322160 252645135 0 3435973836 858993459 0 2863311530 1431655765 0 0 4294967295 0 4294901760 65535 0 4278255360 16711935 0 4042322160 252645135 0 3435973836 858993459 0 2863311530 1431655765 0 4294901760 65535 0 4278255360 16711935 0 4042322160 252645135 0 3435973836 858993459 0 2863311530 1431655765 0 65280 4278190335 16711680 61680 4042264335 252641280 52428 3435934515 858980352 43690 2863289685 1431633920 15728880 4027576335 251662080 13369548 3425946675 855651072 11141290 2857740885 1426085120 202116108 3284386755 808464432 168430090 2779096485 1347440720 572662306 2576980377 1145324612 5 | 0 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 0 4294967295 0 4294967295 0 0 4294901760 65535 0 4278255360 16711935 0 4042322160 252645135 0 3435973836 858993459 0 2863311530 1431655765 0 4294967295 0 0 4294901760 65535 0 4278255360 16711935 0 4042322160 252645135 0 3435973836 858993459 0 2863311530 1431655765 0 0 4294901760 65535 0 4278255360 16711935 0 4042322160 252645135 0 3435973836 858993459 0 2863311530 1431655765 65280 4278190335 16711680 61680 4042264335 252641280 52428 3435934515 858980352 43690 2863289685 1431633920 15728880 4027576335 251662080 13369548 3425946675 855651072 11141290 2857740885 1426085120 202116108 3284386755 808464432 168430090 2779096485 1347440720 572662306 2576980377 1145324612 6 | 0 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 4294967295 0 0 0 4294967295 0 4294901760 65535 0 4278255360 16711935 0 4042322160 252645135 0 3435973836 858993459 0 2863311530 1431655765 0 0 0 4294967295 0 4294901760 65535 0 4278255360 16711935 0 4042322160 252645135 0 3435973836 858993459 0 2863311530 1431655765 4294901760 65535 0 4278255360 16711935 0 4042322160 252645135 0 3435973836 858993459 0 2863311530 1431655765 0 65280 4278190335 16711680 61680 4042264335 252641280 52428 3435934515 858980352 43690 2863289685 1431633920 15728880 4027576335 251662080 13369548 3425946675 855651072 11141290 2857740885 1426085120 202116108 3284386755 808464432 168430090 2779096485 1347440720 572662306 2576980377 1145324612 7 | 0 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 4294967295 0 0 4294967295 0 0 4294901760 65535 0 4278255360 16711935 0 4042322160 252645135 0 3435973836 858993459 0 2863311530 1431655765 0 0 4294967295 0 0 4294901760 65535 0 4278255360 16711935 0 4042322160 252645135 0 3435973836 858993459 0 2863311530 1431655765 0 4294901760 65535 0 4278255360 16711935 0 4042322160 252645135 0 3435973836 858993459 0 2863311530 1431655765 65280 4278190335 16711680 61680 4042264335 252641280 52428 3435934515 858980352 43690 2863289685 1431633920 15728880 4027576335 251662080 13369548 3425946675 855651072 11141290 2857740885 1426085120 202116108 3284386755 808464432 168430090 2779096485 1347440720 572662306 2576980377 1145324612 8 | 4294967295 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 0 0 4294967295 0 0 4294967295 0 4294901760 65535 0 4278255360 16711935 0 4042322160 252645135 0 3435973836 858993459 0 2863311530 1431655765 0 4294967295 0 4294901760 65535 0 4278255360 16711935 0 4042322160 252645135 0 3435973836 858993459 0 2863311530 1431655765 0 4294901760 65535 0 4278255360 16711935 0 4042322160 252645135 0 3435973836 858993459 0 2863311530 1431655765 0 65280 4278190335 16711680 61680 4042264335 252641280 52428 3435934515 858980352 43690 2863289685 1431633920 15728880 4027576335 251662080 13369548 3425946675 855651072 11141290 2857740885 1426085120 202116108 3284386755 808464432 168430090 2779096485 1347440720 572662306 2576980377 1145324612 9 | 4294967295 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 0 0 4294967295 0 4294967295 0 0 4294901760 65535 0 4278255360 16711935 0 4042322160 252645135 0 3435973836 858993459 0 2863311530 1431655765 4294967295 0 0 4294901760 65535 0 4278255360 16711935 0 4042322160 252645135 0 3435973836 858993459 0 2863311530 1431655765 0 0 4294901760 65535 0 4278255360 16711935 0 4042322160 252645135 0 3435973836 858993459 0 2863311530 1431655765 65280 4278190335 16711680 61680 4042264335 252641280 52428 3435934515 858980352 43690 2863289685 1431633920 15728880 4027576335 251662080 13369548 3425946675 855651072 11141290 2857740885 1426085120 202116108 3284386755 808464432 168430090 2779096485 1347440720 572662306 2576980377 1145324612 10 | 4294967295 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 0 4294967295 0 0 0 4294967295 0 4294901760 65535 0 4278255360 16711935 0 4042322160 252645135 0 3435973836 858993459 0 2863311530 1431655765 0 0 4294967295 0 4294901760 65535 0 4278255360 16711935 0 4042322160 252645135 0 3435973836 858993459 0 2863311530 1431655765 4294901760 65535 0 4278255360 16711935 0 4042322160 252645135 0 3435973836 858993459 0 2863311530 1431655765 0 65280 4278190335 16711680 61680 4042264335 252641280 52428 3435934515 858980352 43690 2863289685 1431633920 15728880 4027576335 251662080 13369548 3425946675 855651072 11141290 2857740885 1426085120 202116108 3284386755 808464432 168430090 2779096485 1347440720 572662306 2576980377 1145324612 11 | 4294967295 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 0 4294967295 0 0 4294967295 0 0 4294901760 65535 0 4278255360 16711935 0 4042322160 252645135 0 3435973836 858993459 0 2863311530 1431655765 0 4294967295 0 0 4294901760 65535 0 4278255360 16711935 0 4042322160 252645135 0 3435973836 858993459 0 2863311530 1431655765 0 4294901760 65535 0 4278255360 16711935 0 4042322160 252645135 0 3435973836 858993459 0 2863311530 1431655765 65280 4278190335 16711680 61680 4042264335 252641280 52428 3435934515 858980352 43690 2863289685 1431633920 15728880 4027576335 251662080 13369548 3425946675 855651072 11141290 2857740885 1426085120 202116108 3284386755 808464432 168430090 2779096485 1347440720 572662306 2576980377 1145324612 12 | .e -------------------------------------------------------------------------------- /data/plufiles/mcomp3.plu: -------------------------------------------------------------------------------- 1 | .i 6 2 | .o 3 3 | .p 2 4 | 0 4294901760 4278255360 4042322160 3435973836 2863311530 4042849534 134480385 117637376 5 | 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 8437984 2151686160 2134843151 6 | .e 7 | -------------------------------------------------------------------------------- /data/plufiles/mcomp3x3.plu: -------------------------------------------------------------------------------- 1 | .i 6 2 | .o 3 3 | .p 2 4 | 0 4294901760 4278255360 4042322160 3435973836 2863311530 4042849534 134480385 117637376 5 | 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 8437984 2151686160 2134843151 6 | .e 7 | -------------------------------------------------------------------------------- /data/plufiles/mcomp4.plu: -------------------------------------------------------------------------------- 1 | .i 8 2 | .o 3 3 | .p 8 4 | 0 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 4294770686 131073 65536 5 | 0 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 4293984248 524292 458755 6 | 0 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 4290838496 2097168 2031631 7 | 0 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 4278255488 8388672 8323135 8 | 4294967295 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 4227923456 33554688 33489151 9 | 4294967295 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 4026595328 134218752 134153215 10 | 4294967295 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 3221282816 536875008 536809471 11 | 4294967295 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 32768 2147500032 2147434495 12 | .e 13 | -------------------------------------------------------------------------------- /data/plufiles/mcomp4x4.plu: -------------------------------------------------------------------------------- 1 | .i 8 2 | .o 3 3 | .p 8 4 | 0 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 4294770686 131073 65536 5 | 0 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 4293984248 524292 458755 6 | 0 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 4290838496 2097168 2031631 7 | 0 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 4278255488 8388672 8323135 8 | 4294967295 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 4227923456 33554688 33489151 9 | 4294967295 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 4026595328 134218752 134153215 10 | 4294967295 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 3221282816 536875008 536809471 11 | 4294967295 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 32768 2147500032 2147434495 12 | .e 13 | -------------------------------------------------------------------------------- /data/plufiles/mcomp5.plu: -------------------------------------------------------------------------------- 1 | .i 10 2 | .o 3 3 | .p 32 4 | 0 0 0 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 4294967294 1 0 5 | 0 0 0 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 4294967292 2 1 6 | 0 0 0 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 4294967288 4 3 7 | 0 0 0 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 4294967280 8 7 8 | 0 0 4294967295 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 4294967264 16 15 9 | 0 0 4294967295 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 4294967232 32 31 10 | 0 0 4294967295 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 4294967168 64 63 11 | 0 0 4294967295 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 4294967040 128 127 12 | 0 4294967295 0 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 4294966784 256 255 13 | 0 4294967295 0 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 4294966272 512 511 14 | 0 4294967295 0 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 4294965248 1024 1023 15 | 0 4294967295 0 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 4294963200 2048 2047 16 | 0 4294967295 4294967295 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 4294959104 4096 4095 17 | 0 4294967295 4294967295 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 4294950912 8192 8191 18 | 0 4294967295 4294967295 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 4294934528 16384 16383 19 | 0 4294967295 4294967295 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 4294901760 32768 32767 20 | 4294967295 0 0 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 4294836224 65536 65535 21 | 4294967295 0 0 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 4294705152 131072 131071 22 | 4294967295 0 0 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 4294443008 262144 262143 23 | 4294967295 0 0 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 4293918720 524288 524287 24 | 4294967295 0 4294967295 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 4292870144 1048576 1048575 25 | 4294967295 0 4294967295 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 4290772992 2097152 2097151 26 | 4294967295 0 4294967295 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 4286578688 4194304 4194303 27 | 4294967295 0 4294967295 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 4278190080 8388608 8388607 28 | 4294967295 4294967295 0 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 4261412864 16777216 16777215 29 | 4294967295 4294967295 0 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 4227858432 33554432 33554431 30 | 4294967295 4294967295 0 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 4160749568 67108864 67108863 31 | 4294967295 4294967295 0 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 4026531840 134217728 134217727 32 | 4294967295 4294967295 4294967295 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 3758096384 268435456 268435455 33 | 4294967295 4294967295 4294967295 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 3221225472 536870912 536870911 34 | 4294967295 4294967295 4294967295 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 2147483648 1073741824 1073741823 35 | 4294967295 4294967295 4294967295 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 0 2147483648 2147483647 36 | .e 37 | -------------------------------------------------------------------------------- /data/plufiles/mcomp5x5.plu: -------------------------------------------------------------------------------- 1 | .i 10 2 | .o 3 3 | .p 32 4 | 0 0 0 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 4294967294 1 0 5 | 0 0 0 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 4294967292 2 1 6 | 0 0 0 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 4294967288 4 3 7 | 0 0 0 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 4294967280 8 7 8 | 0 0 4294967295 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 4294967264 16 15 9 | 0 0 4294967295 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 4294967232 32 31 10 | 0 0 4294967295 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 4294967168 64 63 11 | 0 0 4294967295 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 4294967040 128 127 12 | 0 4294967295 0 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 4294966784 256 255 13 | 0 4294967295 0 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 4294966272 512 511 14 | 0 4294967295 0 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 4294965248 1024 1023 15 | 0 4294967295 0 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 4294963200 2048 2047 16 | 0 4294967295 4294967295 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 4294959104 4096 4095 17 | 0 4294967295 4294967295 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 4294950912 8192 8191 18 | 0 4294967295 4294967295 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 4294934528 16384 16383 19 | 0 4294967295 4294967295 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 4294901760 32768 32767 20 | 4294967295 0 0 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 4294836224 65536 65535 21 | 4294967295 0 0 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 4294705152 131072 131071 22 | 4294967295 0 0 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 4294443008 262144 262143 23 | 4294967295 0 0 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 4293918720 524288 524287 24 | 4294967295 0 4294967295 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 4292870144 1048576 1048575 25 | 4294967295 0 4294967295 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 4290772992 2097152 2097151 26 | 4294967295 0 4294967295 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 4286578688 4194304 4194303 27 | 4294967295 0 4294967295 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 4278190080 8388608 8388607 28 | 4294967295 4294967295 0 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 4261412864 16777216 16777215 29 | 4294967295 4294967295 0 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 4227858432 33554432 33554431 30 | 4294967295 4294967295 0 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 4160749568 67108864 67108863 31 | 4294967295 4294967295 0 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 4026531840 134217728 134217727 32 | 4294967295 4294967295 4294967295 0 0 4294901760 4278255360 4042322160 3435973836 2863311530 3758096384 268435456 268435455 33 | 4294967295 4294967295 4294967295 0 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 3221225472 536870912 536870911 34 | 4294967295 4294967295 4294967295 4294967295 0 4294901760 4278255360 4042322160 3435973836 2863311530 2147483648 1073741824 1073741823 35 | 4294967295 4294967295 4294967295 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 0 2147483648 2147483647 36 | .e 37 | -------------------------------------------------------------------------------- /data/plufiles/mul3.plu: -------------------------------------------------------------------------------- 1 | .i 6 2 | .o 6 3 | .p 2 4 | 0 4294901760 4278255360 4042322160 3435973836 2863311530 0 3221225472 955252736 3033329664 1722469376 2852170240 5 | 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 3770712064 2553835760 1421110476 510024362 1722469376 2852170240 6 | .e 7 | -------------------------------------------------------------------------------- /data/plufiles/mul4.plu: -------------------------------------------------------------------------------- 1 | .i 8 2 | .o 8 3 | .t 8 4 | 0000000000 0000000000 0000000000 4294901760 4278255360 4042322160 3435973836 2863311530 0000000000 0000000000 0000000000 0000000000 4278190080 4042260480 3435921408 2863267840 5 | 0000000000 0000000000 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 0000000000 0000000000 4160749568 0130088704 3342397680 3031747788 1718004394 2863267840 6 | 0000000000 4294967295 0000000000 4294901760 4278255360 4042322160 3435973836 2863311530 0000000000 3758096384 0528547584 0477163760 2473381068 1515891370 3435921408 2863267840 7 | 0000000000 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 0000000000 4227921920 3286239168 0865650488 2874455220 0505308774 1718004394 2863267840 8 | 4294967295 0000000000 0000000000 4294901760 4278255360 4042322160 3435973836 2863311530 2147483648 2130771712 2029056240 1724697804 1437248170 4042260480 3435921408 2863267840 9 | 4294967295 0000000000 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 4026589184 0264249216 2386041968 1227133804 1838307930 3031747788 1718004394 2863267840 10 | 4294967295 4294967295 0000000000 4294901760 4278255360 4042322160 3435973836 2863311530 4227921920 2212497344 1662568248 1385477300 0969303654 1515891370 3435921408 2863267840 11 | 4294967295 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 4261477376 3789603808 2576888728 1431612244 0033431070 0505308774 1718004394 2863267840 12 | .e 13 | -------------------------------------------------------------------------------- /data/plufiles/mult3.plu: -------------------------------------------------------------------------------- 1 | .i 6 2 | .o 6 3 | .p 2 4 | 0 4294901760 4278255360 4042322160 3435973836 2863311530 0 3221225472 955252736 3033329664 1722469376 2852170240 5 | 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 3770712064 2553835760 1421110476 510024362 1722469376 2852170240 6 | .e 7 | -------------------------------------------------------------------------------- /data/plufiles/mult4.plu: -------------------------------------------------------------------------------- 1 | .i 8 2 | .o 8 3 | .t 8 4 | 0000000000 0000000000 0000000000 4294901760 4278255360 4042322160 3435973836 2863311530 0000000000 0000000000 0000000000 0000000000 4278190080 4042260480 3435921408 2863267840 5 | 0000000000 0000000000 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 0000000000 0000000000 4160749568 0130088704 3342397680 3031747788 1718004394 2863267840 6 | 0000000000 4294967295 0000000000 4294901760 4278255360 4042322160 3435973836 2863311530 0000000000 3758096384 0528547584 0477163760 2473381068 1515891370 3435921408 2863267840 7 | 0000000000 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 0000000000 4227921920 3286239168 0865650488 2874455220 0505308774 1718004394 2863267840 8 | 4294967295 0000000000 0000000000 4294901760 4278255360 4042322160 3435973836 2863311530 2147483648 2130771712 2029056240 1724697804 1437248170 4042260480 3435921408 2863267840 9 | 4294967295 0000000000 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 4026589184 0264249216 2386041968 1227133804 1838307930 3031747788 1718004394 2863267840 10 | 4294967295 4294967295 0000000000 4294901760 4278255360 4042322160 3435973836 2863311530 4227921920 2212497344 1662568248 1385477300 0969303654 1515891370 3435921408 2863267840 11 | 4294967295 4294967295 4294967295 4294901760 4278255360 4042322160 3435973836 2863311530 4261477376 3789603808 2576888728 1431612244 0033431070 0505308774 1718004394 2863267840 12 | .e 13 | -------------------------------------------------------------------------------- /data/statfiles/1706782556952.stat: -------------------------------------------------------------------------------- 1 | Job # 1 :: Evaluations: 9608 :: Best Fitness: 2.12636 :: Runtime (s): 0.0415812 2 | -------------------------------------------------------------------------------- /fitness/Fitness.h: -------------------------------------------------------------------------------- 1 | // CGP++: Modern C++ Implementation of Cartesian Genetic Programming 2 | // =============================================================================== 3 | // File: Fitness.h 4 | // =============================================================================== 5 | // 6 | // =============================================================================== 7 | // Copyright (C) 2024 8 | // 9 | // 10 | // License: Academic Free License v. 3.0 11 | // ================================================================================ 12 | #ifndef FITNESS_FITNESS_H_ 13 | #define FITNESS_FITNESS_H_ 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | #include "../parameters/Parameters.h" 21 | 22 | /// @brief Class representing the handling of the fitness. 23 | /// @details Provides functions to check for better and ideal fitness. 24 | /// @tparam F Fitness type 25 | template 26 | class Fitness { 27 | private: 28 | bool minimize = true; 29 | bool strict = true; 30 | 31 | F ideal_fitness; 32 | 33 | public: 34 | Fitness(std::shared_ptr p_parameters, F p_ideal_fitness); 35 | virtual ~Fitness() = default; 36 | 37 | F worst_value(); 38 | 39 | bool is_better(F f1, F f2); 40 | bool is_ideal(F f); 41 | 42 | bool is_minimize() const; 43 | void set_minimize(bool p_minimize); 44 | 45 | bool is_strict() const; 46 | void set_strict(bool strict); 47 | 48 | F get_ideal_fitness() const; 49 | void set_ideal_fitness(F p_ideal_fitness); 50 | }; 51 | 52 | template 53 | Fitness::Fitness(std::shared_ptr p_parameters, F p_ideal_fitness) { 54 | 55 | if (p_parameters != nullptr) { 56 | this->minimize = p_parameters->is_minimizing_fitness(); 57 | this->ideal_fitness = p_ideal_fitness; 58 | } else { 59 | throw std::invalid_argument( 60 | "Nullpointer exception in fitnessclass!"); 61 | } 62 | 63 | if (std::is_arithmetic::value == false) { 64 | throw std::invalid_argument( 65 | "This class supports only arithmetic types!"); 66 | } 67 | } 68 | 69 | 70 | /// @brief Returns the worst fitness value that is possible in the respective domain 71 | /// @return worst possible fitness value 72 | template 73 | F Fitness::worst_value() { 74 | if (this->minimize) { 75 | return std::numeric_limits::max(); 76 | } 77 | return std::numeric_limits::min(); 78 | } 79 | 80 | 81 | /// @brief Checks if the first fitness value is better than the second fitness value. 82 | /// @details Distinguishes between strict and non-strict selection. Strict selection 83 | /// prefers individuals of better fitness while non-strict also considers equal fitness. 84 | /// @param f1 The first fitness value. 85 | /// @param f2 The second fitness value. 86 | /// @return True if f1 is better than f2, false otherwise. 87 | template 88 | bool Fitness::is_better(F f1, F f2) { 89 | if (this->minimize) { 90 | if (this->strict) { 91 | return f1 < f2; 92 | } 93 | return f1 <= f2; 94 | } else { 95 | if (this->strict) { 96 | return f1 > f2; 97 | } 98 | return f1 >= f2; 99 | } 100 | } 101 | 102 | /// @brief Checks for ideal fitness. 103 | /// @param f fitness to be checked 104 | /// @return status if fitness is ideal 105 | template 106 | bool Fitness::is_ideal(F f) { 107 | 108 | if (minimize) { 109 | return f <= ideal_fitness; 110 | } else { 111 | return f >= ideal_fitness; 112 | } 113 | } 114 | 115 | // Getter and Setter of the fitness class 116 | 117 | template 118 | bool Fitness::is_minimize() const { 119 | return minimize; 120 | } 121 | 122 | template 123 | void Fitness::set_minimize(bool p_minimize) { 124 | this->minimize = p_minimize; 125 | } 126 | 127 | template 128 | bool Fitness::is_strict() const { 129 | return strict; 130 | } 131 | 132 | template 133 | F Fitness::get_ideal_fitness() const { 134 | return this->ideal_fitness; 135 | } 136 | 137 | template 138 | void Fitness::set_ideal_fitness(F p_ideal_fitness) { 139 | this->ideal_fitness = p_ideal_fitness; 140 | } 141 | 142 | template 143 | void Fitness::set_strict(bool strict) { 144 | this->strict = strict; 145 | } 146 | 147 | #endif /* FITNESS_FITNESS_H_ */ 148 | -------------------------------------------------------------------------------- /functions/BooleanFunctions.h: -------------------------------------------------------------------------------- 1 | // CGP++: Modern C++ Implementation of Cartesian Genetic Programming 2 | // =============================================================================== 3 | // File BooleanFunctions.h 4 | // =============================================================================== 5 | // 6 | // =============================================================================== 7 | // Copyright (C) 2024 8 | // 9 | // 10 | // License: Academic Free License v. 3.0 11 | // ================================================================================ 12 | 13 | #ifndef FUNCTIONS_BOOLEANFUNCTIONS_H_ 14 | #define FUNCTIONS_BOOLEANFUNCTIONS_H_ 15 | 16 | #include "Functions.h" 17 | #include "../parameters/Parameters.h" 18 | 19 | #include 20 | #include 21 | 22 | /// @brief Class to represent a function set of Boolean functions 23 | /// @details Ensures that only datatypes such as long, unsigned int and unsigned long 24 | /// that fit the domain of the considered Boolean functions are used with this class 25 | /// @tparam E Evaluation type 26 | template 27 | class FunctionsBoolean: public Functions { 28 | public: 29 | FunctionsBoolean(std::shared_ptr p_parameters); 30 | virtual ~FunctionsBoolean() = default; 31 | 32 | E call_function(E inputs[], int function) override; 33 | std::string input_name(int input) override; 34 | std::string function_name(int function) override; 35 | 36 | int arity_of(int function) override; 37 | 38 | }; 39 | 40 | template 41 | FunctionsBoolean::FunctionsBoolean(std::shared_ptr p_parameters) : 42 | Functions(p_parameters) { 43 | 44 | if constexpr (!std::is_same::value) { 45 | if constexpr (!std::is_same::value) { 46 | if constexpr (!std::is_same::value) { 47 | if constexpr (!std::is_same::value) { 48 | throw std::invalid_argument( 49 | "This class only supports (signed/unsigned) long and int!"); 50 | } 51 | } 52 | } 53 | } 54 | 55 | } 56 | 57 | /// @brief Provides a Boolean functions such as AND, OR, NAND, NOR. 58 | /// @details Configuration is commonly used for a reduced function set in logic synthesis 59 | /// as approached with genetic programming. 60 | /// @param inputs pair of inputs values 61 | /// @param function index of the functions to call 62 | /// @return result of the function call 63 | template 64 | E FunctionsBoolean::call_function(E inputs[], int function) { 65 | 66 | E result; 67 | 68 | switch (function) { 69 | 70 | case 0: 71 | result = inputs[0] & inputs[1]; 72 | break; 73 | 74 | case 1: 75 | result = inputs[0] | inputs[1]; 76 | break; 77 | 78 | case 2: 79 | result = ~(inputs[0] & inputs[1]); 80 | break; 81 | 82 | case 3: 83 | result = ~(inputs[0] | inputs[1]); 84 | break; 85 | 86 | default: 87 | throw std::invalid_argument("Illegal function number!"); 88 | 89 | } 90 | 91 | return result; 92 | 93 | } 94 | 95 | 96 | template 97 | std::string FunctionsBoolean::FunctionsBoolean::function_name(int function) { 98 | 99 | std::string name = ""; 100 | 101 | switch (function) { 102 | 103 | case 0: 104 | name = "AND"; 105 | break; 106 | 107 | case 1: 108 | name = "OR"; 109 | break; 110 | 111 | case 2: 112 | name = "NAND"; 113 | break; 114 | 115 | case 3: 116 | name = "NOR"; 117 | break; 118 | 119 | default: 120 | throw std::invalid_argument("Illegal function number!"); 121 | 122 | } 123 | 124 | return name; 125 | } 126 | 127 | template 128 | std::string FunctionsBoolean::input_name(int input) { 129 | std::string input_name = "x" + std::to_string(input); 130 | return input_name; 131 | } 132 | 133 | template 134 | int FunctionsBoolean::arity_of(int function) { 135 | return 2; 136 | } 137 | 138 | #endif /* FUNCTIONS_BOOLEANFUNCTIONS_H_ */ 139 | -------------------------------------------------------------------------------- /functions/Functions.h: -------------------------------------------------------------------------------- 1 | // CGP++: Modern C++ Implementation of Cartesian Genetic Programming 2 | // =============================================================================== 3 | // File Function.h 4 | // =============================================================================== 5 | // 6 | // =============================================================================== 7 | // Copyright (C) 2024 8 | // 9 | // 10 | // License: Academic Free License v. 3.0 11 | // ================================================================================ 12 | 13 | #ifndef FUNCTIONS_FUNCTIONS_H_ 14 | #define FUNCTIONS_FUNCTIONS_H_ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | #include "../parameters/Parameters.h" 22 | 23 | /// @brief Abstract base class to represent function set. 24 | /// @details Ensures that every function set that inherits from this class 25 | /// has member fucntions to call the functions and to obtain the function and input names. 26 | /// @tparam E Evaluation type 27 | template 28 | class Functions { 29 | protected: 30 | Functions(std::shared_ptr p_parameters); 31 | int num_operators; 32 | public: 33 | virtual ~Functions() = default; 34 | virtual E call_function(E inputs[], int function) = 0; 35 | 36 | /// @brief Returns the function name 37 | /// @param function index of the functions 38 | /// @return function name 39 | virtual std::string function_name(int function) = 0; 40 | 41 | /// @brief Returns the input name 42 | /// @param input index of the input 43 | /// @return name of the input 44 | virtual std::string input_name(int input) = 0; 45 | 46 | /// @brief Returns the arity of a function 47 | /// @param function index of the function 48 | /// @return funcion arity 49 | virtual int arity_of(int function) = 0; 50 | }; 51 | 52 | template 53 | Functions::Functions(std::shared_ptr p_parameters) { 54 | if (p_parameters != nullptr) { 55 | num_operators = p_parameters->get_max_arity(); 56 | } else { 57 | throw std::invalid_argument( 58 | "Nullpointer exception in evaluator class!"); 59 | } 60 | } 61 | 62 | 63 | #endif /* FUNCTIONS_FUNCTIONS_H_ */ 64 | -------------------------------------------------------------------------------- /functions/MathematicalFunctions.h: -------------------------------------------------------------------------------- 1 | // CGP++: Modern C++ Implementation of Cartesian Genetic Programming 2 | // =============================================================================== 3 | // File MathematicalFunctions.h 4 | // =============================================================================== 5 | // 6 | // =============================================================================== 7 | // Copyright (C) 2024 8 | // 9 | // 10 | // License: Academic Free License v. 3.0 11 | // ================================================================================ 12 | 13 | 14 | #ifndef FUNCTIONS_MATHEMATICALFUNCTIONS_H_ 15 | #define FUNCTIONS_MATHEMATICALFUNCTIONS_H_ 16 | 17 | #include "Functions.h" 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | /// @brief Represents a minimalistic mathematical function set. 24 | /// @details Ensures that only data type domains such as integer and floats are used 25 | /// for the template paramter 26 | /// @tparam E Evation type 27 | template 28 | class FunctionsMathematical: public Functions { 29 | public: 30 | FunctionsMathematical(std::shared_ptr p_parameters); 31 | virtual ~FunctionsMathematical() = default; 32 | 33 | E call_function(E inputs[], int function) override; 34 | std::string input_name(int input) override; 35 | std::string function_name(int function) override; 36 | 37 | int arity_of(int function) override; 38 | 39 | }; 40 | 41 | template 42 | FunctionsMathematical::FunctionsMathematical(std::shared_ptr p_parameters) : 43 | Functions(p_parameters) { 44 | 45 | if constexpr (!std::is_same::value) { 46 | if constexpr (!std::is_same::value) { 47 | throw std::invalid_argument( 48 | "This class only supports float and double!"); 49 | } 50 | } 51 | } 52 | 53 | template 54 | E FunctionsMathematical::call_function(E inputs[], int function) { 55 | 56 | E result; 57 | 58 | switch (function) { 59 | 60 | case 0: 61 | result = inputs[0] + inputs[1]; 62 | break; 63 | 64 | case 1: 65 | result = inputs[0] - inputs[1]; 66 | break; 67 | 68 | case 2: 69 | result = inputs[0] * inputs[1]; 70 | break; 71 | 72 | case 3: 73 | if (inputs[1] == 0) { 74 | result = 1; 75 | } 76 | else { 77 | result = inputs[0] / inputs[1]; 78 | } 79 | break; 80 | 81 | default: 82 | throw std::invalid_argument("Illegal function number!"); 83 | 84 | } 85 | 86 | return result; 87 | 88 | } 89 | 90 | template 91 | std::string FunctionsMathematical::function_name(int function) { 92 | 93 | std::string name = ""; 94 | 95 | switch (function) { 96 | 97 | case 0: 98 | name = "ADD"; 99 | break; 100 | 101 | case 1: 102 | name = "SUB"; 103 | break; 104 | 105 | case 2: 106 | name = "MUL"; 107 | break; 108 | 109 | case 3: 110 | name = "DIV"; 111 | break; 112 | 113 | default: 114 | throw std::invalid_argument("Illegal function number!"); 115 | 116 | } 117 | 118 | return name; 119 | } 120 | 121 | template 122 | std::string FunctionsMathematical::input_name(int input) { 123 | std::string input_name = "x" + std::to_string(input); 124 | return input_name; 125 | } 126 | 127 | template 128 | int FunctionsMathematical::arity_of(int function) { 129 | return 2; 130 | } 131 | 132 | 133 | #endif /* FUNCTIONS_MATHEMATICALFUNCTIONS_H_ */ 134 | -------------------------------------------------------------------------------- /initializer/BlackBoxInitializer.h: -------------------------------------------------------------------------------- 1 | // CGP++: Modern C++ Implementation of Cartesian Genetic Programming 2 | // =============================================================================== 3 | // File: BlackBoxInitializer.h 4 | // =============================================================================== 5 | // 6 | // =============================================================================== 7 | // Copyright (C) 2024 8 | // 9 | // 10 | // License: Academic Free License v. 3.0 11 | // ================================================================================ 12 | 13 | #ifndef INITIALIZER_BLACKBOXINITIALIZER_H_ 14 | #define INITIALIZER_BLACKBOXINITIALIZER_H_ 15 | 16 | #include 17 | #include "Initializer.h" 18 | 19 | template 20 | class BlackBoxInitializer: public Initializer { 21 | protected: 22 | std::shared_ptr> > inputs; 23 | std::shared_ptr> > outputs; 24 | int num_instances; 25 | public: 26 | BlackBoxInitializer(const std::string &p_benchmark_file); 27 | virtual ~BlackBoxInitializer() = default; 28 | virtual void init_problem() = 0; 29 | virtual void init_functions() = 0; 30 | void read_data(); 31 | }; 32 | 33 | template 34 | BlackBoxInitializer::BlackBoxInitializer( 35 | const std::string &p_benchmark_file) : 36 | Initializer(p_benchmark_file) { 37 | } 38 | 39 | template 40 | void BlackBoxInitializer::read_data() { 41 | 42 | std::shared_ptr> bechmark_reader = std::make_shared< 43 | BenchmarkFileReader>(); 44 | 45 | bechmark_reader->read_benchmark_file(this->benchmark_file); 46 | 47 | this->inputs = bechmark_reader->get_input_data(); 48 | this->outputs = bechmark_reader->get_output_data(); 49 | 50 | int num_inputs = bechmark_reader->get_num_inputs(); 51 | int num_outputs = bechmark_reader->get_num_outputs(); 52 | 53 | this->parameters->set_num_variables(num_inputs); 54 | this->parameters->set_num_outputs(num_outputs); 55 | this->num_instances = bechmark_reader->get_num_instances(); 56 | } 57 | 58 | #endif /* INITIALIZER_BLACKBOXINITIALIZER_H_ */ 59 | -------------------------------------------------------------------------------- /initializer/LogicSynthesisInitializer.h: -------------------------------------------------------------------------------- 1 | // CGP++: Modern C++ Implementation of Cartesian Genetic Programming 2 | // =============================================================================== 3 | // File: LogicSynthesisInitializer.h 4 | // =============================================================================== 5 | // 6 | // =============================================================================== 7 | // Copyright (C) 2024 8 | // 9 | // 10 | // License: Academic Free License v. 3.0 11 | // ================================================================================ 12 | 13 | #ifndef INITIALIZER_LOGICSYNTHESISINITIALIZER_H_ 14 | #define INITIALIZER_LOGICSYNTHESISINITIALIZER_H_ 15 | 16 | #include 17 | 18 | #include "../functions/BooleanFunctions.h" 19 | #include "../problems/LogicSynthesisProblem.h" 20 | #include "../functions/BooleanFunctions.h" 21 | #include "BlackBoxInitializer.h" 22 | 23 | 24 | /// @brief Derived intializer class for logic synthesis problems. 25 | /// @details Initializes the defined logic synthesis problem. 26 | /// @tparam E Evaluation Type 27 | /// @tparam G Genotype Type 28 | /// @tparam F Fitness Type 29 | template 30 | class LogicSynthesisInitializer: public BlackBoxInitializer { 31 | 32 | public: 33 | LogicSynthesisInitializer(const std::string &p_benchmark_file); 34 | ~LogicSynthesisInitializer() = default; 35 | void init_problem() override; 36 | void init_functions() override; 37 | }; 38 | 39 | template 40 | LogicSynthesisInitializer::LogicSynthesisInitializer( 41 | const std::string &p_benchmark_file) : 42 | BlackBoxInitializer(p_benchmark_file) { 43 | } 44 | 45 | /// @brief Initializes the logic synthesis problem instance. 46 | template 47 | void LogicSynthesisInitializer::init_problem() { 48 | 49 | std::shared_ptr> problem = std::make_shared< 50 | LogicSynthesisProblem>(this->parameters, this->evaluator, 51 | this->inputs, this->outputs, this->constants, this->num_instances); 52 | 53 | this->composite->set_problem(problem); 54 | } 55 | 56 | 57 | /// @brief Initializes the funcion set used for logic synthesis problems. 58 | template 59 | void LogicSynthesisInitializer::init_functions() { 60 | this->functions = std::make_shared>(this->parameters); 61 | } 62 | 63 | 64 | #endif /* INITIALIZER_LOGICSYNTHESISINITIALIZER_H_ */ 65 | -------------------------------------------------------------------------------- /initializer/SymbolicRegressionInitializer.h: -------------------------------------------------------------------------------- 1 | // CGP++: Modern C++ Implementation of Cartesian Genetic Programming 2 | // =============================================================================== 3 | // File: SymbolicRegressionInitializer.h 4 | // =============================================================================== 5 | // 6 | // =============================================================================== 7 | // Copyright (C) 2024 8 | // 9 | // 10 | // License: Academic Free License v. 3.0 11 | // ================================================================================ 12 | 13 | #ifndef INITIALIZER_SYMBOLICREGRESSIONINITIALIZER_H_ 14 | #define INITIALIZER_SYMBOLICREGRESSIONINITIALIZER_H_ 15 | 16 | #include "../functions/BooleanFunctions.h" 17 | #include "../problems/SymbolicRegressionProblem.h" 18 | #include "../functions/MathematicalFunctions.h" 19 | #include "BlackBoxInitializer.h" 20 | 21 | /// @brief Derived intializer class for symbolic regression problems. 22 | /// @details Initializes the defined symbolic regression problem. 23 | /// @tparam E Evaluation Type 24 | /// @tparam G Genotype Type 25 | /// @tparam F Fitness Type 26 | template 27 | class SymbolicRegressionInitializer: public BlackBoxInitializer { 28 | public: 29 | SymbolicRegressionInitializer(const std::string &p_benchmark_file); 30 | ~SymbolicRegressionInitializer() = default; 31 | void init_problem() override; 32 | void init_functions() override; 33 | }; 34 | 35 | template 36 | SymbolicRegressionInitializer::SymbolicRegressionInitializer( 37 | const std::string &p_benchmark_file) : 38 | BlackBoxInitializer(p_benchmark_file) { 39 | } 40 | 41 | /// @brief Initializes the funcion set used for symbolic regression problems. 42 | template 43 | void SymbolicRegressionInitializer::init_problem() { 44 | std::shared_ptr> problem = std::make_shared< 45 | SymbolicRegressionProblem>(this->parameters, this->evaluator, 46 | this->inputs, this->outputs, this->constants, this->num_instances); 47 | 48 | this->composite->set_problem(problem); 49 | } 50 | 51 | template 52 | void SymbolicRegressionInitializer::init_functions() { 53 | this->functions = std::make_shared>(this->parameters); 54 | } 55 | 56 | 57 | 58 | #endif /* INITIALIZER_SYMBOLICREGRESSIONINITIALIZER_H_ */ 59 | -------------------------------------------------------------------------------- /mutation/Mutation.h: -------------------------------------------------------------------------------- 1 | // CGP++: Modern C++ Implementation of Cartesian Genetic Programming 2 | // =============================================================================== 3 | // File: Mutation.h 4 | // =============================================================================== 5 | // 6 | // =============================================================================== 7 | // Copyright (C) 2024 8 | // 9 | // 10 | // License: Academic Free License v. 3.0 11 | // ================================================================================ 12 | 13 | #ifndef MUTATION_H_ 14 | #define MUTATION_H_ 15 | 16 | #include "../parameters/Parameters.h" 17 | #include "../random/Random.h" 18 | #include "../representation/Species.h" 19 | #include "../representation/Individual.h" 20 | #include "MutationPipeline.h" 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | /// @brief Class to represents that handles the mutation procedure. 27 | /// @tparam G Genome Type 28 | /// @tparam F Fitness Type 29 | template 30 | class Mutation { 31 | private: 32 | std::shared_ptr parameters; 33 | std::shared_ptr random; 34 | std::shared_ptr> species; 35 | float mutation_rate; 36 | MUTATION_TYPE mutation_type; 37 | 38 | std::shared_ptr> pipeline; 39 | 40 | public: 41 | Mutation(std::shared_ptr p_parameters, 42 | std::shared_ptr p_random, 43 | std::shared_ptr> p_species); 44 | virtual ~Mutation() = default; 45 | void mutate(std::shared_ptr> parent); 46 | void print(); 47 | const std::shared_ptr >& get_pipeline() const; 48 | void set_pipeline(const std::shared_ptr > &pipeline); 49 | }; 50 | 51 | 52 | /// @brief Constructor that sets the hyperparameters required for mutation 53 | /// @details Instantiates the mutation pipeline by that referenced with a shared pointer 54 | /// @param p_parameters shared pointer to paramter object 55 | /// @param p_random shared pointer torandom generator instance 56 | /// @param p_species shared pointer to species instance 57 | template 58 | Mutation::Mutation(std::shared_ptr p_parameters, 59 | std::shared_ptr p_random, 60 | std::shared_ptr> p_species) { 61 | 62 | if (p_parameters != nullptr) { 63 | this->parameters = p_parameters; 64 | this->mutation_rate = p_parameters->get_mutation_rate(); 65 | this->mutation_type = p_parameters->get_mutation_type(); 66 | } else { 67 | throw std::invalid_argument("p_parameters is null in mutation class!"); 68 | } 69 | 70 | if (p_random != nullptr) { 71 | this->random = p_random; 72 | } else { 73 | throw std::invalid_argument("p_random is null in mutation class!"); 74 | } 75 | 76 | if (p_species != nullptr) { 77 | this->species = p_species; 78 | } else { 79 | throw std::invalid_argument("p_species is null in mutation class!"); 80 | } 81 | 82 | this->pipeline = std::make_shared>(p_parameters, p_random, p_species); 83 | } 84 | 85 | /// @brief Triggers the variation process of the configured mutation pipeline. 86 | /// @param parent selected parent individual 87 | template 88 | void Mutation::mutate(std::shared_ptr> parent) { 89 | this->pipeline->breed(parent); 90 | } 91 | 92 | template 93 | inline const std::shared_ptr >& Mutation::get_pipeline() const { 94 | return this->pipeline; 95 | } 96 | 97 | template 98 | inline void Mutation::set_pipeline( 99 | const std::shared_ptr > &p_pipeline) { 100 | this->pipeline = p_pipeline; 101 | } 102 | 103 | template 104 | void Mutation::print() { 105 | std::cout<<"Mutation: "; 106 | this->pipeline->print(); 107 | } 108 | 109 | 110 | 111 | #endif /* MUTATION_H_ */ 112 | -------------------------------------------------------------------------------- /mutation/MutationPipeline.h: -------------------------------------------------------------------------------- 1 | // CGP++: Modern C++ Implementation of Cartesian Genetic Programming 2 | // =============================================================================== 3 | // File: MutationPipeline.h 4 | // =============================================================================== 5 | // 6 | // =============================================================================== 7 | // Copyright (C) 2024 8 | // 9 | // 10 | // License: Academic Free License v. 3.0 11 | // ================================================================================ 12 | 13 | #ifndef MUTATION_MUTATIONPIPELINE_H_ 14 | #define MUTATION_MUTATIONPIPELINE_H_ 15 | 16 | #include 17 | #include 18 | #include 19 | 20 | #include "../parameters/Parameters.h" 21 | #include "../variation/UnaryOperator.h" 22 | #include "../variation/mutation/Duplication.h" 23 | #include "../variation/mutation/Inversion.h" 24 | #include "../variation/mutation/ProbabilisticPoint.h" 25 | #include "../variation/mutation/SingleActiveGene.h" 26 | 27 | /// @brief Class to represent the mutation pipeline 28 | /// @details Pipelining is established by using a vector that is iterated 29 | /// when the breeding procedure is called. The mutation operators pushed in the vector 30 | /// derive from UnaryOperator class. 31 | /// @see UnaryOperator in the variation package 32 | /// @tparam G Genome Type 33 | /// @tparam F Fitness Type 34 | template 35 | class MutationPipeline { 36 | private: 37 | std::shared_ptr>>> pipeline; 38 | std::shared_ptr> operators; 39 | std::shared_ptr parameters; 40 | std::shared_ptr random; 41 | std::shared_ptr> species; 42 | 43 | public: 44 | 45 | MutationPipeline(std::shared_ptr p_parameters, 46 | std::shared_ptr p_random, 47 | std::shared_ptr> p_species); 48 | virtual ~MutationPipeline() = default; 49 | 50 | void init(); 51 | void breed(std::shared_ptr> ind); 52 | void print(); 53 | 54 | }; 55 | 56 | /// @brief Constructor of MutationPipeline 57 | /// @param p_parameters shared pointer to parameter instance 58 | /// @param p_random shared pointer to random generator instance 59 | /// @param p_species shared pointer to species instance 60 | template 61 | MutationPipeline::MutationPipeline( 62 | std::shared_ptr p_parameters, 63 | std::shared_ptr p_random, 64 | std::shared_ptr> p_species) { 65 | 66 | if (p_parameters != nullptr && p_random != nullptr 67 | && p_species != nullptr) { 68 | parameters = p_parameters; 69 | random = p_random; 70 | species = p_species; 71 | operators = p_parameters->get_mutation_operators(); 72 | } else { 73 | throw std::invalid_argument( 74 | "Nullpointer exception in mutation pipeline class!"); 75 | } 76 | 77 | pipeline = std::make_shared< 78 | std::vector>>>(); 79 | 80 | this->init(); 81 | 82 | } 83 | 84 | /// @brief Initializes the mutation pipeline 85 | /// @details Instantiates the mutation operators according the configuation 86 | /// and adds it to the pipeline vector 87 | template 88 | void MutationPipeline::init() { 89 | 90 | std::shared_ptr> op; 91 | 92 | for (MUTATION_TYPE type : *operators) { 93 | 94 | if (type == parameters->PROBABILISTIC_POINT_MUTATION) { 95 | op = std::make_shared>( 96 | this->parameters, this->random, this->species); 97 | 98 | pipeline->push_back(op); 99 | 100 | } else if (type == parameters->SINGLE_ACTIVE_GENE_MUTATION) { 101 | op = std::make_shared>( 102 | this->parameters, this->random, this->species); 103 | pipeline->push_back(op); 104 | 105 | } else if (type == parameters->DUPLICATION_MUTATION) { 106 | op = std::make_shared>( 107 | this->parameters, this->random, this->species); 108 | pipeline->push_back(op); 109 | 110 | } else if (type == parameters->INVERSION_MUTATION) { 111 | op = std::make_shared>( 112 | this->parameters, this->random, this->species); 113 | pipeline->push_back(op); 114 | } 115 | } 116 | } 117 | 118 | /// @brief Prints the mutation operators of the pipeline 119 | template 120 | void MutationPipeline::print() { 121 | int i = 1; 122 | for (auto it = this->pipeline->begin(); it != this->pipeline->end(); ++it) { 123 | std::cout<<"["<< i <<"] "<<(*it)->get_name()<<" "; 124 | i++; 125 | } 126 | 127 | } 128 | 129 | /// @brief Performs the breeding procedure 130 | /// @details Iterates over the pipeline and calls the varation method 131 | template 132 | void MutationPipeline::breed(std::shared_ptr> ind) { 133 | for (auto it = this->pipeline->begin(); it != this->pipeline->end(); ++it) { 134 | it->get()->variate(ind); 135 | } 136 | } 137 | 138 | 139 | 140 | #endif /* MUTATION_MUTATIONPIPELINE_H_ */ 141 | -------------------------------------------------------------------------------- /parameters/Parameters.h: -------------------------------------------------------------------------------- 1 | // CGP++: Modern C++ Implementation of Cartesian Genetic Programming 2 | // =============================================================================== 3 | // File Parameters.h 4 | // =============================================================================== 5 | // 6 | // =============================================================================== 7 | // Copyright (C) 2024 8 | // 9 | // 10 | // License: Academic Free License v. 3.0 11 | // ================================================================================ 12 | 13 | #ifndef PARAMETERS_PARAMETERS_H_ 14 | #define PARAMETERS_PARAMETERS_H_ 15 | 16 | typedef unsigned int EVAL_METHOD; 17 | typedef unsigned int MUTATION_TYPE; 18 | typedef unsigned int CROSSOVER_TYPE; 19 | typedef unsigned int ALGORITHM; 20 | typedef unsigned int PROBLEM; 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | #include "../template/template_types.h" 30 | #include "../constants/erc_types.h" 31 | 32 | /// @brief Class to represent the CGP++ configuration 33 | /// @details Provides getter and setter for the respective parameter and settings and 34 | /// severtal configuration types defined by typedef. 35 | class Parameters { 36 | public: 37 | const EVAL_METHOD FITNESS_EVALUATIONS_TO_TERMINATION = 0; 38 | const EVAL_METHOD BEST_FITNESS_OF_RUN = 1; 39 | 40 | const MUTATION_TYPE PROBABILISTIC_POINT_MUTATION = 0; 41 | const MUTATION_TYPE SINGLE_ACTIVE_GENE_MUTATION = 1; 42 | const MUTATION_TYPE INVERSION_MUTATION = 2; 43 | const MUTATION_TYPE DUPLICATION_MUTATION = 3; 44 | 45 | const CROSSOVER_TYPE BLOCK_CROSSOVER = 0; 46 | const CROSSOVER_TYPE DISCRETE_CROSSOVER = 1; 47 | 48 | const ALGORITHM ONE_PLUS_LAMBDA = 0; 49 | const ALGORITHM MU_PLUS_LAMBDA = 1; 50 | 51 | const PROBLEM SYMBOLIC_REGRESSION = 0; 52 | const PROBLEM LOGIC_SYNTHESIS = 1; 53 | 54 | const std::string STAT_FILE_DIR = "data/statfiles/"; 55 | const std::string CHECKPOINT_FILE_DIR = "data/checkpoints/"; 56 | 57 | private: 58 | 59 | int genome_size; 60 | int num_function_nodes; 61 | int num_inputs; 62 | int num_outputs; 63 | int num_variables; 64 | int num_functions; 65 | int num_constants; 66 | 67 | ERC_TYPE erc_type; 68 | 69 | int num_jobs; 70 | int num_eval_threads; 71 | int eval_chunk_size; 72 | 73 | int max_arity; 74 | 75 | long long max_fitness_evaluations; 76 | long long max_generations; 77 | 78 | long long global_seed; 79 | 80 | FITNESS_TYPE ideal_fitness; 81 | 82 | float mutation_rate; 83 | float crossover_rate; 84 | 85 | MUTATION_TYPE mutation_type; 86 | CROSSOVER_TYPE crossover_type; 87 | 88 | ALGORITHM algorithm; 89 | PROBLEM problem; 90 | 91 | std::shared_ptr> mutation_operators; 92 | 93 | float inversion_rate; 94 | float duplication_rate; 95 | 96 | int max_inversion_depth; 97 | int max_duplication_depth; 98 | 99 | int population_size; 100 | int mu; 101 | int lambda; 102 | int levels_back; 103 | int num_offspring; 104 | int num_parents; 105 | 106 | bool neutral_genetic_drift; 107 | 108 | bool evaluate_expression; 109 | bool minimizing_fitness; 110 | bool report_during_job; 111 | bool report_after_job; 112 | bool report_simple; 113 | bool print_configuration; 114 | bool generate_random_seed; 115 | bool write_statfile; 116 | bool checkpointing; 117 | 118 | int report_interval; 119 | int checkpoint_modulo; 120 | int simple_report_type; 121 | 122 | public: 123 | Parameters(); 124 | virtual ~Parameters() = default; 125 | 126 | void print(); 127 | 128 | void set_eval_chunk_size(); 129 | int get_eval_chunk_size() const; 130 | 131 | void set_genome_size(); 132 | 133 | int get_genome_size() const; 134 | void set_genome_size(int p_genome_size); 135 | 136 | int get_max_arity() const; 137 | void set_max_arity(int p_max_arity); 138 | 139 | int get_num_functions() const; 140 | void set_num_functions(int p_num_functions); 141 | 142 | int get_num_constants() const; 143 | void set_num_constants(int p_num_constants); 144 | 145 | ERC_TYPE get_erc_type() const; 146 | void set_erc_type(ERC_TYPE p_erc_type); 147 | 148 | int get_num_variables() const; 149 | void set_num_variables(int p_num_variables); 150 | 151 | int get_num_inputs() const; 152 | void set_num_inputs(int p_num_inputs); 153 | 154 | int get_num_function_nodes() const; 155 | void set_num_function_nodes(int p_num_nodes); 156 | 157 | int get_num_outputs() const; 158 | void set_num_outputs(int p_num_outputs); 159 | 160 | float get_mutation_rate() const; 161 | void set_mutation_rate(float p_mutation_rate); 162 | 163 | float get_crossover_rate() const; 164 | void set_crossover_rate(float p_crossover_rate); 165 | 166 | CROSSOVER_TYPE get_crossover_type() const; 167 | void set_crossover_type(CROSSOVER_TYPE p_crossover_type); 168 | 169 | MUTATION_TYPE get_mutation_type() const; 170 | void set_mutation_type(MUTATION_TYPE p_mutation_type); 171 | 172 | 173 | FITNESS_TYPE get_ideal_fitness() const; 174 | void set_ideal_fitness(FITNESS_TYPE p_ideal_fitness); 175 | 176 | long long get_max_fitness_evaluations() const; 177 | void set_max_fitness_evaluations(long long p_max_fitness_evaluations); 178 | 179 | long long get_max_generations() const; 180 | void set_max_generations(long long p_max_generations); 181 | 182 | int get_population_size() const; 183 | void set_population_size(int p_population_size); 184 | 185 | void set_mu(int p_mu); 186 | int get_mu() const; 187 | 188 | void set_lambda(int p_lambda); 189 | int get_lambda() const; 190 | 191 | int get_num_parents() const; 192 | void set_num_parents(int p_num_parents); 193 | 194 | int get_num_offspring() const; 195 | void set_num_offspring(int p_num_offspring); 196 | 197 | int get_levels_back() const; 198 | void set_levels_back(int p_levels_back); 199 | 200 | bool is_minimizing_fitness() const; 201 | void set_minimizing_fitness(bool p_miniming_fitness); 202 | 203 | int get_num_jobs() const; 204 | void set_num_jobs(int p_num_jobs); 205 | 206 | int get_num_eval_threads() const; 207 | void set_num_eval_threads(int p_num_eval_threads); 208 | 209 | int get_report_interval() const; 210 | void set_report_interval(int p_report_interval); 211 | 212 | bool is_report_during_job() const; 213 | void set_report_during_job(bool p_report_during_job); 214 | 215 | bool is_report_after_job() const; 216 | void set_report_after_job(bool p_report_after_job); 217 | 218 | bool is_report_simple() const; 219 | void set_report_simple(bool p_report_simple); 220 | 221 | int get_simple_report_type() const; 222 | void set_simple_report_type(int p_simple_report_type); 223 | 224 | bool is_evaluate_expression() const; 225 | void set_evaluate_expression(bool p_evaluate_expression); 226 | 227 | bool is_neutral_genetic_drift() const; 228 | void set_neutral_genetic_drift(bool p_neutral_genetic_drift); 229 | 230 | bool is_print_configuration() const; 231 | void set_print_configuration(bool p_print_parameters); 232 | 233 | long long get_global_seed() const; 234 | void set_global_seed(long long globalSeed); 235 | 236 | const std::shared_ptr >& get_mutation_operators() const; 237 | void set_mutation_operators(const std::shared_ptr > &p_mutation_operators); 238 | 239 | ALGORITHM get_algorithm() const; 240 | void set_algorithm(ALGORITHM p_algorithm); 241 | 242 | bool is_generate_random_seed() const; 243 | void set_generate_random_seed(bool p_generate_random_seed); 244 | 245 | bool is_write_statfile() const; 246 | void set_write_statfile(bool p_write_output_file); 247 | 248 | bool is_checkpointing() const; 249 | void set_checkpointing(bool p_checkpointing); 250 | 251 | int get_checkpoint_modulo() const; 252 | void set_checkpoint_modulo(int p_checkpoint_modulo); 253 | 254 | float get_inversion_rate() const; 255 | void set_inversion_rate(float p_inversion_rate); 256 | 257 | float get_duplication_rate() const; 258 | void set_duplication_rate(float p_duplication_rate); 259 | 260 | int get_max_inversion_depth() const; 261 | void set_max_inversion_depth(int p_max_inversion_depth); 262 | 263 | int get_max_duplication_depth() const; 264 | void set_max_duplication_depth(int p_max_duplication_depth); 265 | PROBLEM get_problem() const; 266 | void set_problem(PROBLEM problem); 267 | }; 268 | 269 | #endif /* PARAMETERS_PARAMETERS_H_ */ 270 | -------------------------------------------------------------------------------- /population/AbstractPopulation.h: -------------------------------------------------------------------------------- 1 | // CGP++: Modern C++ Implementation of Cartesian Genetic Programming 2 | // =============================================================================== 3 | // File: AbstractPopulation.h 4 | // =============================================================================== 5 | // 6 | // =============================================================================== 7 | // Copyright (C) 2024 8 | // 9 | // 10 | // License: Academic Free License v. 3.0 11 | // ================================================================================ 12 | 13 | #ifndef POPULATION_ABSTRACTPOPULATION_H_ 14 | #define POPULATION_ABSTRACTPOPULATION_H_ 15 | 16 | #include 17 | 18 | #include "../parameters/Parameters.h" 19 | #include "../representation/Individual.h" 20 | #include "../random/Random.h" 21 | 22 | /// @brief Abstract base class to represent static and dynamic populations. 23 | /// @details Provides core functions for the handling of the invidiuals and initiliaziation from checkspoints. 24 | /// @tparam G Genome Type 25 | /// @tparam F Fitness Type 26 | template 27 | class AbstractPopulation { 28 | protected: 29 | int population_size; 30 | 31 | std::shared_ptr parameters; 32 | std::shared_ptr random; 33 | 34 | virtual void init() = 0; 35 | 36 | public: 37 | AbstractPopulation(std::shared_ptr p_random, 38 | std::shared_ptr p_parameters); 39 | 40 | virtual ~AbstractPopulation() = default; 41 | 42 | virtual void print() = 0; 43 | virtual void reset() = 0; 44 | virtual int size() = 0; 45 | virtual void sort() = 0; 46 | 47 | virtual void init_from_checkpoint(std::shared_ptr>> genomes) = 0; 48 | 49 | virtual std::shared_ptr > get_individual(int index) const = 0; 50 | virtual void set_individual(std::shared_ptr > individual, int index) = 0; 51 | 52 | }; 53 | 54 | template 55 | AbstractPopulation::AbstractPopulation(std::shared_ptr p_random, 56 | std::shared_ptr p_parameters) { 57 | 58 | if (p_parameters != nullptr || p_random != nullptr) { 59 | parameters = p_parameters; 60 | random = p_random; 61 | population_size = p_parameters->get_population_size(); 62 | } else { 63 | throw std::invalid_argument("Nullpointer exception in abstract population class!"); 64 | } 65 | } 66 | 67 | #endif /* POPULATION_ABSTRACTPOPULATION_H_ */ 68 | -------------------------------------------------------------------------------- /population/DynamicPopulation.h: -------------------------------------------------------------------------------- 1 | // CGP++: Modern C++ Implementation of Cartesian Genetic Programming 2 | // =============================================================================== 3 | // File: DynamicPopulation.h 4 | // =============================================================================== 5 | // 6 | // =============================================================================== 7 | // Copyright (C) 2024 8 | // 9 | // 10 | // License: Academic Free License v. 3.0 11 | // ================================================================================ 12 | 13 | #ifndef POPULATION_DYNAMICPOPULATION_H_ 14 | #define POPULATION_DYNAMICPOPULATION_H_ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | 22 | #include "../parameters/Parameters.h" 23 | #include "../representation/Individual.h" 24 | #include "../random/Random.h" 25 | #include "AbstractPopulation.h" 26 | 27 | /// @brief Concept for a dynamic class that can vary in size. 28 | /// @details Unfinished work and currently not supported 29 | /// @tparam G Genome Type 30 | /// @tparam F Fitness Type 31 | template 32 | class DynamicPopulation : public AbstractPopulation { 33 | private: 34 | int population_size; 35 | std::vector>> individuals; 36 | std::shared_ptr parameters; 37 | std::shared_ptr random; 38 | 39 | void init() override; 40 | 41 | public: 42 | DynamicPopulation(std::shared_ptr p_random, 43 | std::shared_ptr p_parameters); 44 | virtual ~DynamicPopulation(); 45 | void print() override; 46 | void clear() override; 47 | void reset() override; 48 | void add(std::shared_ptr> individual); 49 | const std::vector > >& get_individuals() const; 50 | std::shared_ptr > get_individual(int index) const override; 51 | void set_individual(std::shared_ptr > individual, int index) override; 52 | }; 53 | 54 | template 55 | DynamicPopulation::DynamicPopulation(std::shared_ptr p_random, 56 | std::shared_ptr p_parameters) : AbstractPopulation( p_random,p_parameters) { 57 | 58 | this->init(); 59 | } 60 | 61 | template 62 | DynamicPopulation::~DynamicPopulation() { 63 | this->clear(); 64 | } 65 | 66 | 67 | template 68 | void DynamicPopulation::reset() { 69 | this->clear(); 70 | this->init(); 71 | } 72 | 73 | template 74 | void DynamicPopulation::init() { 75 | for (int i = 0; i < this->population_size; i++) { 76 | std::shared_ptr> ind = std::make_unique>(random,parameters); 77 | this->individuals.push_back(ind); 78 | } 79 | } 80 | 81 | template 82 | void DynamicPopulation::print() { 83 | int i=0; 84 | for (auto it = individuals.begin(); it != individuals.end(); ++it) { 85 | 86 | std::string genome_str = (*it)->to_string(); 87 | std::cout<<"Individual #"<get_fitness()<<" :: Genome: "< 94 | void DynamicPopulation::clear() { 95 | this->individuals.clear(); 96 | } 97 | 98 | template 99 | void DynamicPopulation::add(std::shared_ptr> individual) { 100 | assert(individual != nullptr); 101 | this->individuals.push_back(individual); 102 | } 103 | 104 | 105 | template 106 | std::shared_ptr > DynamicPopulation::get_individual(int index) const { 107 | return individuals.at(index); 108 | } 109 | 110 | template 111 | const std::vector > >& DynamicPopulation::get_individuals() const { 112 | return individuals; 113 | } 114 | 115 | template 116 | void DynamicPopulation::set_individual(std::shared_ptr > individual, int index) { 117 | assert(index >= 0 && index < this->population_size); 118 | this->individuals[index] = individual; 119 | } 120 | 121 | #endif /* POPULATION_DYNAMICPOPULATION_H_ */ 122 | -------------------------------------------------------------------------------- /population/StaticPopulation.h: -------------------------------------------------------------------------------- 1 | // CGP++: Modern C++ Implementation of Cartesian Genetic Programming 2 | // =============================================================================== 3 | // File: StaticPopulation.h 4 | // =============================================================================== 5 | // 6 | // =============================================================================== 7 | // Copyright (C) 2024 8 | // 9 | // 10 | // License: Academic Free License v. 3.0 11 | // ================================================================================ 12 | 13 | #ifndef POPULATION_STATICPOPULATION_H_ 14 | #define POPULATION_STATICPOPULATION_H_ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #include "../population/AbstractPopulation.h" 24 | #include "../parameters/Parameters.h" 25 | #include "../representation/Individual.h" 26 | #include "../random/Random.h" 27 | 28 | /// @brief Represents a static population 29 | /// @details Static array is used to store the individuals 30 | /// @tparam G Genome Type 31 | /// @tparam F Fitness Type 32 | template 33 | class StaticPopulation: public AbstractPopulation { 34 | private: 35 | std::shared_ptr>[]> individuals; 36 | 37 | void init() override; 38 | 39 | public: 40 | StaticPopulation(std::shared_ptr p_random, 41 | std::shared_ptr p_parameters); 42 | virtual ~StaticPopulation() = default; 43 | void print() override; 44 | void reset() override; 45 | int size() override; 46 | void sort() override; 47 | void init_from_checkpoint( 48 | std::shared_ptr>> genomes); 49 | std::shared_ptr > get_individual(int index) const override; 50 | std::shared_ptr>[]> init_population_ptr(); 51 | void set_individual(std::shared_ptr > individual, 52 | int index) override; 53 | }; 54 | 55 | template 56 | StaticPopulation::StaticPopulation(std::shared_ptr p_random, 57 | std::shared_ptr p_parameters) : 58 | AbstractPopulation(p_random, p_parameters) { 59 | 60 | this->individuals = this->init_population_ptr(); 61 | 62 | this->init(); 63 | } 64 | 65 | /// @brief Resets the population by iterating over the individuals and 66 | /// resetting the genomes 67 | template 68 | void StaticPopulation::reset() { 69 | for (int i = 0; i < this->population_size; i++) { 70 | std::shared_ptr> ind = this->get_individual(i); 71 | ind->reset(); 72 | } 73 | } 74 | 75 | /// @brief Initializes the population by instantiating the individuals 76 | /// that are reference by a shared pointer 77 | template 78 | void StaticPopulation::init() { 79 | for (int i = 0; i < this->population_size; i++) { 80 | std::shared_ptr> ind = std::make_shared< 81 | Individual>(this->random, this->parameters); 82 | this->individuals[i] = ind; 83 | } 84 | } 85 | 86 | /// @brief Initializes the population and the correspndonding shared pointer that 87 | /// is used for referencing 88 | /// @return shared pointer to the population instance 89 | template 90 | std::shared_ptr>[]> StaticPopulation::init_population_ptr() { 91 | 92 | std::shared_ptr>[]> shared_population_ptr( 93 | new std::shared_ptr>[this->population_size](), 94 | std::default_delete>[]>()); 95 | 96 | //std::shared_ptr>[]> shared_population_ptr = 97 | // std::make_shared>[]>( 98 | // this->population_size); 99 | 100 | return shared_population_ptr; 101 | 102 | } 103 | 104 | /// @brief Initializes the population from the genomes provided by a checkpoint. 105 | /// @param genomes genomes read from the checkpoint 106 | template 107 | void StaticPopulation::init_from_checkpoint( 108 | std::shared_ptr>> genomes) { 109 | 110 | bool real_valued = this->individuals[0]->is_real_valued(); 111 | int size = genomes->at(0).size(); 112 | 113 | for (int i = 0; i < this->population_size; i++) { 114 | 115 | std::vector& genome_vec = genomes->at(i); 116 | std::shared_ptr genome(new G[size](), std::default_delete()); 117 | 118 | for (int j = 0; j < size; j++) { 119 | std::string s = genome_vec.at(j); 120 | if (real_valued) { 121 | genome[j] = std::stoi(s); 122 | } else { 123 | genome[j] = std::stof(s); 124 | } 125 | } 126 | this->individuals[i]->set_genome(genome); 127 | } 128 | } 129 | 130 | /// @brief Sorts the population on this basis of the respective fitness 131 | /// @details Uses lambda a lambda function for the comparison 132 | template 133 | void StaticPopulation::sort() { 134 | std::sort(this->individuals.get(), this->individuals.get() + this->size(), 135 | [](auto const ind1, auto const ind2) { 136 | return ind1->get_fitness() < ind2->get_fitness(); 137 | }); 138 | } 139 | 140 | /// @brief Print out the fitness and genome of the individuals 141 | template 142 | void StaticPopulation::print() { 143 | for (int i = 0; i < this->population_size; i++) { 144 | std::string genome_str = individuals[i]->to_string(); 145 | std::cout << "Individual #" << i << " :: Fitness: " 146 | << individuals[i]->get_fitness() << " :: Genome: " << genome_str 147 | << std::endl; 148 | } 149 | } 150 | 151 | /// @brief Return the population size 152 | /// @return number of individuals 153 | template 154 | int StaticPopulation::size() { 155 | return this->population_size; 156 | } 157 | 158 | template 159 | std::shared_ptr > StaticPopulation::get_individual( 160 | int index) const { 161 | assert(index >= 0 && index < this->population_size); 162 | return individuals[index]; 163 | } 164 | 165 | template 166 | void StaticPopulation::set_individual( 167 | std::shared_ptr > individual, int index) { 168 | assert(index >= 0 && index < this->population_size); 169 | this->individuals[index] = individual; 170 | } 171 | 172 | #endif /* POPULATION_STATICPOPULATION_H_ */ 173 | -------------------------------------------------------------------------------- /problems/LogicSynthesisProblem.h: -------------------------------------------------------------------------------- 1 | // CGP++: Modern C++ Implementation of Cartesian Genetic Programming 2 | // =============================================================================== 3 | // File: LogicSynthesisProblem.h 4 | // =============================================================================== 5 | // 6 | // =============================================================================== 7 | // Copyright (C) 2024 8 | // 9 | // 10 | // License: Academic Free License v. 3.0 11 | // -=============================================================================== 12 | 13 | #ifndef PROBLEMS_LOGICSYNTHESISPROBLEM_H_ 14 | #define PROBLEMS_LOGICSYNTHESISPROBLEM_H_ 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #include "../problems/BlackBoxProblem.h" 23 | 24 | /// @brief Class to represent a logic synthesis problem. 25 | /// @details Hamming distance is used to as fitness metric. 26 | /// Each instance represents one chunk of the compressed truth table. 27 | /// @tparam E Evalation type 28 | /// @tparam G Genome type 29 | /// @tparam F Fitness type 30 | template 31 | class LogicSynthesisProblem: public BlackBoxProblem { 32 | private: 33 | int num_bits; 34 | const int MAX_BITS = 32; 35 | 36 | public: 37 | LogicSynthesisProblem(std::shared_ptr p_parameters, 38 | std::shared_ptr> p_evalutor, 39 | std::shared_ptr>> p_inputs, 40 | std::shared_ptr>> p_outputs, 41 | std::shared_ptr> p_constants, 42 | int p_num_instances); 43 | 44 | ~LogicSynthesisProblem() = default; 45 | 46 | int get_bit(E n, E k); 47 | F evaluate(E output_real, E output_individual); 48 | 49 | F evaluate(std::shared_ptr> outputs_real, 50 | std::shared_ptr> outputs_individual) override; 51 | LogicSynthesisProblem* clone() override; 52 | 53 | }; 54 | 55 | template 56 | LogicSynthesisProblem::LogicSynthesisProblem(std::shared_ptr p_parameters, 57 | std::shared_ptr> p_evaluator, 58 | std::shared_ptr>> p_inputs, 59 | std::shared_ptr>> p_outputs, 60 | std::shared_ptr> p_constants, 61 | int p_num_instances) : 62 | BlackBoxProblem(p_parameters, p_evaluator, p_inputs, p_outputs , p_constants, p_num_instances) { 63 | 64 | this->name = "Logic Synthesis Problem"; 65 | this->num_bits = std::pow(2, this->num_inputs); 66 | 67 | if(num_bits > MAX_BITS) { 68 | num_bits = MAX_BITS; 69 | } 70 | 71 | } 72 | 73 | /// @brief Return a the bit value at position k from a output mask 74 | /// @param n output mask 75 | /// @param k position of bit balue 76 | /// @return bit value at positon k 77 | template 78 | int LogicSynthesisProblem::get_bit(E n, E k) { 79 | return (n >> k) & 1; 80 | } 81 | 82 | /// @brief Evaluates the outputs on an individual against the real outputs of the problem. 83 | /// @details Uses hamming distance for the fitness calculation. 84 | /// @param outputs_real real output values of the truth table 85 | /// @param outputs_individual outputs obtained from the evaluation of the genome 86 | /// @return 87 | template 88 | F LogicSynthesisProblem::evaluate( 89 | std::shared_ptr> outputs_real, 90 | std::shared_ptr> outputs_individual) { 91 | int diff = 0; 92 | 93 | 94 | for (int i = 0; i < this->num_outputs; i++) { 95 | diff += this->evaluate(outputs_real->at(i), outputs_individual->at(i)); 96 | } 97 | return diff; 98 | } 99 | 100 | template 101 | F LogicSynthesisProblem::evaluate(E output_real, E output_individual) { 102 | int diff = 0; 103 | 104 | /// XOR the two outputs to filter out similar bit values 105 | E compare = output_individual ^ output_real; 106 | 107 | // Caculate the hamming distance based on the number of bits considered for each chunk 108 | for (int j = 0; j < this->num_bits; j++) { 109 | E temp = compare; 110 | // Obtain the bit value at jth position and add it to the difference 111 | diff = diff + get_bit(temp, j); 112 | } 113 | return diff; 114 | } 115 | 116 | template 117 | LogicSynthesisProblem* LogicSynthesisProblem::clone() { 118 | return new LogicSynthesisProblem(*this); 119 | } 120 | 121 | #endif /* PROBLEMS_LOGICSYNTHESISPROBLEM_H_ */ 122 | -------------------------------------------------------------------------------- /problems/SymbolicRegressionProblem.h: -------------------------------------------------------------------------------- 1 | // CGP++: Modern C++ Implementation of Cartesian Genetic Programming 2 | // =============================================================================== 3 | // File: SymbolicRegressionProblem.h 4 | // =============================================================================== 5 | // 6 | // =============================================================================== 7 | // Copyright (C) 2024 8 | // 9 | // 10 | // License: Academic Free License v. 3.0 11 | // ================================================================================ 12 | 13 | #ifndef PROBLEMS_SYMBOLICREGRESSIONPROBLEM_H_ 14 | #define PROBLEMS_SYMBOLICREGRESSIONPROBLEM_H_ 15 | 16 | #include "../problems/BlackBoxProblem.h" 17 | 18 | #include 19 | 20 | /// @brief Class to represent of a sybolic regression problem. 21 | /// @details Absolute difference is used fitness calculation. 22 | /// @tparam E Evalation type 23 | /// @tparam G Genome type 24 | /// @tparam F Fitness type 25 | template 26 | class SymbolicRegressionProblem: public BlackBoxProblem { 27 | private: 28 | 29 | public: 30 | SymbolicRegressionProblem(std::shared_ptr p_parameters, 31 | std::shared_ptr> p_evaluator, 32 | std::shared_ptr>> p_inputs, 33 | std::shared_ptr>> p_outputs, 34 | std::shared_ptr> p_constants, int p_num_instances); 35 | 36 | ~SymbolicRegressionProblem() = default; 37 | 38 | SymbolicRegressionProblem* clone() override; 39 | F evaluate(std::shared_ptr> outputs_real, 40 | std::shared_ptr> outputs_individual) override; 41 | }; 42 | 43 | template 44 | SymbolicRegressionProblem::SymbolicRegressionProblem( 45 | std::shared_ptr p_parameters, 46 | std::shared_ptr> p_evaluator, 47 | std::shared_ptr>> p_inputs, 48 | std::shared_ptr>> p_outputs, 49 | std::shared_ptr> p_constants, int p_num_instances) : 50 | BlackBoxProblem(p_parameters, p_evaluator, p_inputs, p_outputs, 51 | p_constants, p_num_instances) { 52 | 53 | this->name = "Symbolic Regression Problem"; 54 | 55 | } 56 | 57 | /// @brief Evaluates the outputs on an individual against the real outputs of the problem. 58 | /// @details Fitness is obtained by calculation the sum of the absolute difference between the real 59 | /// function values and values obtained after evaluation of the individual. 60 | /// @param outputs_real 61 | /// @param outputs_individual 62 | /// @return 63 | template 64 | F SymbolicRegressionProblem::evaluate( 65 | std::shared_ptr> outputs_real, 66 | std::shared_ptr> outputs_individual) { 67 | float diff = 0; 68 | 69 | for (int i = 0; i < this->num_outputs; i++) { 70 | diff += abs(outputs_individual->at(i) - outputs_real->at(i)); 71 | } 72 | 73 | return diff; 74 | } 75 | 76 | template 77 | SymbolicRegressionProblem* SymbolicRegressionProblem::clone() { 78 | return new SymbolicRegressionProblem(*this); 79 | } 80 | 81 | 82 | #endif /* PROBLEMS_SYMBOLICREGRESSIONPROBLEM_H_ */ 83 | -------------------------------------------------------------------------------- /random/Random.cpp: -------------------------------------------------------------------------------- 1 | // CGP++: Modern C++ Implementation of Cartesian Genetic Programming 2 | // =============================================================================== 3 | // File: Random.cpp 4 | // =============================================================================== 5 | // 6 | // =============================================================================== 7 | // Copyright (C) 2024 8 | // 9 | // 10 | // License: Academic Free License v. 3.0 11 | // ================================================================================ 12 | 13 | #include "Random.h" 14 | 15 | /// @brief Constructor to set the global seed. 16 | /// @param p_global_seed global seed 17 | /// @param p_parameters shared pointer to the parameter object 18 | Random::Random(long long p_global_seed, std::shared_ptr p_parameters) { 19 | 20 | if (p_global_seed <= 0) { 21 | throw std::invalid_argument("Seed must be positive and greater zero!"); 22 | } 23 | 24 | if (p_parameters != nullptr) { 25 | this->parameters = p_parameters; 26 | } else { 27 | throw std::invalid_argument("Nullpointer exception in fitnessclass!"); 28 | } 29 | 30 | this->set_seed(p_global_seed); 31 | } 32 | 33 | Random::Random(std::shared_ptr p_parameters) { 34 | 35 | if (p_parameters != nullptr) { 36 | this->parameters = p_parameters; 37 | } else { 38 | throw std::invalid_argument("Nullpointer exception in fitnessclass!"); 39 | } 40 | 41 | this->set_random_seed(); 42 | } 43 | 44 | /// @brief Return a random integer drawn from uniform distribution 45 | /// in the clossed interval [a,b] 46 | /// @param a lower bound of the interval 47 | /// @param b higher bound of the interval 48 | /// @return random integer 49 | int Random::random_integer(int a, int b) { 50 | std::uniform_int_distribution<> distrib(a, b); 51 | return distrib(rng); 52 | } 53 | 54 | 55 | /// @brief Return a random float drawn from uniform distribution 56 | /// in the clossed interval [a,b] 57 | /// @param a lower bound of the interval 58 | /// @param b higher bound of the interval 59 | /// @return random integer number 60 | float Random::random_float(float a, float b) { 61 | std::uniform_real_distribution<> distrib(a, b); 62 | return distrib(rng); 63 | } 64 | 65 | /// @brief Return a random Boolean value drawn from uniform real distribution 66 | /// @param a probability used to draw the Boolean value by chance 67 | /// @return randon Boolean value 68 | bool Random::random_bool(float p) { 69 | std::uniform_real_distribution<> distrib(0.0, 1.0); 70 | return (distrib(rng) < p); 71 | } 72 | 73 | void Random::set_seed(long long p_global_seed) { 74 | this->global_seed = p_global_seed; 75 | rng.seed(this->global_seed); 76 | } 77 | 78 | void Random::set_random_seed() { 79 | this->global_seed = 80 | chrono::high_resolution_clock::now().time_since_epoch().count(); 81 | rng.seed(this->global_seed); 82 | this->parameters->set_global_seed(this->global_seed); 83 | } 84 | 85 | long long Random::get_global_seed() const { 86 | return this->global_seed; 87 | } 88 | -------------------------------------------------------------------------------- /random/Random.h: -------------------------------------------------------------------------------- 1 | // CGP++: Modern C++ Implementation of Cartesian Genetic Programming 2 | // =============================================================================== 3 | // File: Random.h 4 | // =============================================================================== 5 | // 6 | // =============================================================================== 7 | // Copyright (C) 2024 8 | // 9 | // 10 | // License: Academic Free License v. 3.0 11 | // -=============================================================================== 12 | 13 | 14 | #ifndef RANDOM_RANDOM_H_ 15 | #define RANDOM_RANDOM_H_ 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #include "../parameters/Parameters.h" 24 | 25 | using namespace std; 26 | 27 | /// @brief Class to represent a random generator instance. 28 | /// @details Uses the mt19937 random genrator. 29 | class Random { 30 | private: 31 | long long global_seed; 32 | std::random_device rd; 33 | std::mt19937 rng; 34 | 35 | std::shared_ptr parameters; 36 | 37 | public: 38 | Random(long long p_global_seed, std::shared_ptr p_parameters); 39 | Random(std::shared_ptr p_parameters); 40 | virtual ~Random() = default; 41 | 42 | int random_integer(int a, int b); 43 | float random_float(float a, float b); 44 | bool random_bool(float p = 0.5); 45 | 46 | void set_seed(long long p_global_seed); 47 | void set_random_seed(); 48 | long long get_global_seed() const; 49 | }; 50 | 51 | 52 | 53 | #endif /* RANDOM_RANDOM_H_ */ 54 | 55 | -------------------------------------------------------------------------------- /recombination/Recombination.h: -------------------------------------------------------------------------------- 1 | // CGP++: Modern C++ Implementation of Cartesian Genetic Programming 2 | // =============================================================================== 3 | // File: Recombination.h 4 | // =============================================================================== 5 | // 6 | // =============================================================================== 7 | // Copyright (C) 2024 8 | // 9 | // 10 | // License: Academic Free License v. 3.0 11 | // ================================================================================ 12 | 13 | 14 | #ifndef RECOMBINATION_RECOMBINATION_H_ 15 | #define RECOMBINATION_RECOMBINATION_H_ 16 | 17 | #include "../parameters/Parameters.h" 18 | #include "../random/Random.h" 19 | #include "../representation/Species.h" 20 | #include "../representation/Individual.h" 21 | 22 | #include "../variation/crossover/BlockCrossover.h" 23 | #include "../variation/crossover/DiscreteCrossover.h" 24 | 25 | #include 26 | #include 27 | 28 | 29 | /// @brief Class to represent and handle the recombination procedure. 30 | /// @tparam G Genome type 31 | /// @tparam F Fitness type 32 | template 33 | class Recombination { 34 | private: 35 | std::shared_ptr parameters; 36 | std::shared_ptr random; 37 | std::shared_ptr> species; 38 | 39 | float crossover_rate; 40 | MUTATION_TYPE crossover_type; 41 | 42 | std::unique_ptr> block_crossover; 43 | std::unique_ptr> discrete_crossover; 44 | 45 | std::unique_ptr> op; 46 | 47 | public: 48 | Recombination(std::shared_ptr p_parameters, 49 | std::shared_ptr p_random, 50 | std::shared_ptr> p_species); 51 | virtual ~Recombination() = default; 52 | void crossover(std::shared_ptr> p1, 53 | std::shared_ptr> p2); 54 | void print(); 55 | }; 56 | 57 | /// @brief Constructor to instantiate the crossover operator. 58 | /// @details Crossover is chosen based on the setting in the parameter object. 59 | /// @param p_parameters shared pointer to parameter object 60 | /// @param p_random shared pointer to random generator instance 61 | /// @param p_species shared pointer to species instance 62 | template 63 | Recombination::Recombination(std::shared_ptr p_parameters, 64 | std::shared_ptr p_random, 65 | std::shared_ptr> p_species) { 66 | 67 | if (p_parameters != nullptr) { 68 | this->parameters = p_parameters; 69 | this->crossover_rate = p_parameters->get_crossover_rate(); 70 | this->crossover_type = p_parameters->get_crossover_type(); 71 | } else { 72 | throw std::invalid_argument("p_parameters is null in mutation class!"); 73 | } 74 | 75 | if (p_random != nullptr) { 76 | this->random = p_random; 77 | } else { 78 | throw std::invalid_argument("p_random is null in mutation class!"); 79 | } 80 | 81 | if (p_species != nullptr) { 82 | this->species = p_species; 83 | } else { 84 | throw std::invalid_argument("p_species is null in mutation class!"); 85 | } 86 | 87 | 88 | if (crossover_type == this->parameters->BLOCK_CROSSOVER) { 89 | this->op = std::make_unique>(p_parameters, 90 | p_random, p_species); 91 | } else if (crossover_type == this->parameters->DISCRETE_CROSSOVER) { 92 | this->op = std::make_unique>(p_parameters, 93 | p_random, p_species); 94 | } 95 | } 96 | 97 | /// @brief Trigger the recombination procedure. 98 | /// @param p1 first parent 99 | /// @param p2 second parent 100 | template 101 | void Recombination::crossover(std::shared_ptr> p1, 102 | std::shared_ptr> p2) { 103 | this->op->variate(p1, p2); 104 | } 105 | 106 | /// @brief Print the recobination name. 107 | template 108 | void Recombination::print() { 109 | std::cout<<"Recombination: "; 110 | if(this->op != nullptr) { 111 | std::cout<op->get_name()< 17 | #include "../template/template_types.h" 18 | 19 | class Validation { 20 | public: 21 | Validation(); 22 | 23 | static bool constexpr validate_ls_type() { 24 | if constexpr (!std::is_same::value) { 25 | if constexpr (!std::is_same::value) { 26 | if constexpr (!std::is_same::value) { 27 | if constexpr (!std::is_same::value) { 28 | return false; 29 | } 30 | } 31 | } 32 | } 33 | return true; 34 | } 35 | 36 | static bool constexpr validate_sr_type() { 37 | if constexpr (!std::is_same::value) { 38 | if constexpr (!std::is_same::value) { 39 | return false; 40 | } 41 | } 42 | return true; 43 | } 44 | }; 45 | 46 | #endif /* VALIDATION_VALIDATION_H_ */ 47 | -------------------------------------------------------------------------------- /variation/BinaryOperator.h: -------------------------------------------------------------------------------- 1 | // CGP++: Modern C++ Implementation of Cartesian Genetic Programming 2 | // =============================================================================== 3 | // File: BinaryOperator.h 4 | // =============================================================================== 5 | // 6 | // =============================================================================== 7 | // Copyright (C) 2024 8 | // 9 | // 10 | // License: Academic Free License v. 3.0 11 | // ================================================================================ 12 | 13 | #ifndef VARIATION_BINARYOPERATOR_H_ 14 | #define VARIATION_BINARYOPERATOR_H_ 15 | 16 | #include "GeneticOperator.h" 17 | #include "../representation/Individual.h" 18 | 19 | #include 20 | 21 | /// @brief Abstract base class to represent a binary genetic operator such as recombination. 22 | /// @tparam G Genome type 23 | /// @tparam F Fitness type 24 | template 25 | class BinaryOperator : public GeneticOperator { 26 | public: 27 | BinaryOperator(std::shared_ptr p_parameters, 28 | std::shared_ptr p_random, 29 | std::shared_ptr> p_species) : GeneticOperator(p_parameters, p_random, p_species) {} 30 | virtual ~BinaryOperator() = default; 31 | 32 | virtual void variate(std::shared_ptr> p1, std::shared_ptr> p2) = 0; 33 | }; 34 | 35 | #endif /* VARIATION_BINARYOPERATOR_H_ */ 36 | -------------------------------------------------------------------------------- /variation/GeneticOperator.h: -------------------------------------------------------------------------------- 1 | // CGP++: Modern C++ Implementation of Cartesian Genetic Programming 2 | // =============================================================================== 3 | // File: GeneticOperator.h 4 | // =============================================================================== 5 | // 6 | // =============================================================================== 7 | // Copyright (C) 2024 8 | // 9 | // 10 | // License: Academic Free License v. 3.0 11 | // ================================================================================ 12 | 13 | #ifndef VARIATION_GENETICOPERATOR_H_ 14 | #define VARIATION_GENETICOPERATOR_H_ 15 | 16 | #include "../parameters/Parameters.h" 17 | #include "../random/Random.h" 18 | #include "../representation/Species.h" 19 | 20 | /// @brief Abstract base class to represent a genetic operator 21 | /// @tparam G Genome type 22 | /// @tparam F Fitness type 23 | template 24 | class GeneticOperator { 25 | protected: 26 | std::shared_ptr parameters; 27 | std::shared_ptr random; 28 | std::shared_ptr> species; 29 | std::string name; 30 | 31 | public: 32 | GeneticOperator(std::shared_ptr p_parameters, 33 | std::shared_ptr p_random, 34 | std::shared_ptr> p_species); 35 | virtual ~GeneticOperator() = default; 36 | 37 | const std::string& get_name() const; 38 | void set_name(const std::string &name); 39 | }; 40 | 41 | template 42 | const std::string& GeneticOperator::get_name() const { 43 | return this->name; 44 | } 45 | 46 | template 47 | void GeneticOperator::set_name(const std::string &name) { 48 | this->name = name; 49 | } 50 | 51 | template 52 | GeneticOperator::GeneticOperator(std::shared_ptr p_parameters, 53 | std::shared_ptr p_random, 54 | std::shared_ptr> p_species) { 55 | 56 | if (p_parameters != nullptr) { 57 | this->parameters = p_parameters; 58 | } else { 59 | throw std::invalid_argument( 60 | "p_parameters is null in genetic operator class!"); 61 | } 62 | 63 | if (p_random != nullptr) { 64 | this->random = p_random; 65 | } else { 66 | throw std::invalid_argument( 67 | "p_random is null in genetic operator class!"); 68 | } 69 | 70 | if (p_species != nullptr) { 71 | this->species = p_species; 72 | } else { 73 | throw std::invalid_argument( 74 | "p_species is null in genetic operator class!"); 75 | } 76 | 77 | } 78 | 79 | #endif /* VARIATION_GENETICOPERATOR_H_ */ 80 | -------------------------------------------------------------------------------- /variation/UnaryOperator.h: -------------------------------------------------------------------------------- 1 | // CGP++: Modern C++ Implementation of Cartesian Genetic Programming 2 | // =============================================================================== 3 | // File: UnaryOperator.h 4 | // =============================================================================== 5 | // 6 | // =============================================================================== 7 | // Copyright (C) 2024 8 | // 9 | // 10 | // License: Academic Free License v. 3.0 11 | // ================================================================================ 12 | 13 | #ifndef VARIATION_UNARYOPERATOR_H_ 14 | #define VARIATION_UNARYOPERATOR_H_ 15 | 16 | #include "GeneticOperator.h" 17 | #include "../representation/Individual.h" 18 | #include 19 | 20 | /// @brief Abstract base class to represent a unary genetic operator such as mutation. 21 | /// @tparam G Genome type 22 | /// @tparam F Fitness type 23 | template 24 | class UnaryOperator : public GeneticOperator { 25 | public: 26 | UnaryOperator(std::shared_ptr p_parameters, 27 | std::shared_ptr p_random, 28 | std::shared_ptr> p_species) : GeneticOperator(p_parameters, p_random, p_species) {} 29 | virtual ~UnaryOperator() = default; 30 | virtual void variate(std::shared_ptr> individual) = 0; 31 | }; 32 | 33 | #endif /* VARIATION_UNARYOPERATOR_H_ */ 34 | -------------------------------------------------------------------------------- /variation/crossover/BlockCrossover.h: -------------------------------------------------------------------------------- 1 | // CGP++: Modern C++ Implementation of Cartesian Genetic Programming 2 | // =============================================================================== 3 | // File: BlockCrossover.h 4 | // =============================================================================== 5 | // 6 | // =============================================================================== 7 | // Copyright (C) 2024 8 | // 9 | // 10 | // License: Academic Free License v. 3.0 11 | // ================================================================================ 12 | 13 | 14 | #ifndef VARIATION_CROSSOVER_BLOCKCROSSOVER_H_ 15 | #define VARIATION_CROSSOVER_BLOCKCROSSOVER_H_ 16 | 17 | #include 18 | #include "../BinaryOperator.h" 19 | 20 | /// @brief Class for the representation of the block crossover that has proposed for CGP. 21 | /// @details Block crossover swaps blocks of active function genes between two individuals. 22 | /// The block crossover uses a parameter blockSize which defines the maximum block size. 23 | /// Reasonable results were obtained on several symbolic regression benchmarks (Kalkreuth (2021)). 24 | /// @see Husa, J., Kalkreuth, R. (2018). A Comparative Study on Crossover in Cartesian Genetic Programming 25 | /// https://doi.org/10.1007/978-3-319-77553-1_13 26 | /// @see Kalkreuth R. (2021). Reconsideration and extension of Cartesian genetic programming 27 | /// http://dx.doi.org/10.17877/DE290R-22504 28 | /// @tparam G Genome type 29 | /// @tparam F Fitness type 30 | template 31 | class BlockCrossover: public BinaryOperator { 32 | public: 33 | 34 | int block_size; 35 | 36 | BlockCrossover(std::shared_ptr p_parameters, 37 | std::shared_ptr p_random, 38 | std::shared_ptr> p_species) : 39 | BinaryOperator(p_parameters, p_random, p_species) { 40 | this->name = "Block Crossover"; 41 | this->block_size = 2; 42 | } 43 | 44 | virtual ~BlockCrossover() = default; 45 | 46 | void determine_swap_nodes(int block_size, std::vector &active_nodes, 47 | std::vector &swap_nodes); 48 | int calc_swap_index(int swap_node_number); 49 | 50 | void variate(std::shared_ptr> p1, 51 | std::shared_ptr> p2) override; 52 | }; 53 | 54 | /// @brief Determines bunch of active nodes that are used for the swap by chance. 55 | /// @details Number of nodes depends on the block size. 56 | /// @param block_size block size parameter. 57 | /// @param active_nodes active nodes of the parent. 58 | /// @param swap_nodes nodes that are used for the swap 59 | template 60 | void BlockCrossover::determine_swap_nodes(int block_size, 61 | std::vector &active_nodes, std::vector &swap_nodes) { 62 | 63 | int j = 0; 64 | int rand_index; 65 | int node_number; 66 | 67 | std::vector possible_nodes(active_nodes); 68 | 69 | swap_nodes.clear(); 70 | 71 | while (j < block_size) { 72 | 73 | rand_index = this->random->random_integer(0, possible_nodes.size() - 1); 74 | node_number = possible_nodes.at(rand_index); 75 | 76 | swap_nodes.push_back(node_number); 77 | 78 | possible_nodes.erase(possible_nodes.begin() + rand_index); 79 | 80 | j++; 81 | } 82 | 83 | } 84 | 85 | template 86 | int BlockCrossover::calc_swap_index(int swap_node_number) { 87 | 88 | int num_inputs = this->parameters->get_num_inputs(); 89 | int max_arity = this->parameters->get_max_arity(); 90 | 91 | return (swap_node_number - num_inputs) * (1 + max_arity); 92 | 93 | } 94 | 95 | template 96 | void BlockCrossover::variate(std::shared_ptr> p1, 97 | std::shared_ptr> p2) { 98 | 99 | if (p1->num_active_nodes() == 0 || p2->num_active_nodes() == 0) { 100 | return; 101 | } 102 | 103 | int swap_node1 = 0; 104 | int swap_node2 = 0; 105 | int swap_index1 = 0; 106 | int swap_index2 = 0; 107 | int block_size; 108 | 109 | std::vector swap_nodes1; 110 | std::vector swap_nodes2; 111 | 112 | if (p1->num_active_nodes() < this->block_size 113 | || p2->num_active_nodes() < this->block_size) { 114 | block_size = std::min(p1->num_active_nodes(), p2->num_active_nodes()); 115 | } else { 116 | block_size = this->block_size; 117 | } 118 | 119 | // 120 | std::shared_ptr> active_nodes1 = p1->get_active_nodes(); 121 | std::shared_ptr> active_nodes2 = p2->get_active_nodes(); 122 | 123 | std::shared_ptr g1 = p1->get_genome(); 124 | std::shared_ptr g2 = p2->get_genome(); 125 | 126 | determine_swap_nodes(block_size, *active_nodes1, swap_nodes1); 127 | determine_swap_nodes(block_size, *active_nodes2, swap_nodes2); 128 | 129 | int j = 0; 130 | int temp = 0; // used to store values during swapping 131 | 132 | for (j = 0; j < block_size; j++) { 133 | 134 | swap_node1 = swap_nodes1.at(j); 135 | swap_node2 = swap_nodes2.at(j); 136 | 137 | swap_index1 = calc_swap_index(swap_node1); 138 | swap_index2 = calc_swap_index(swap_node2); 139 | 140 | temp = g1[swap_index1]; 141 | 142 | g1[swap_index1] = g2[swap_index2]; 143 | g2[swap_index2] = temp; 144 | 145 | } 146 | 147 | } 148 | 149 | #endif /* VARIATION_CROSSOVER_BLOCKCROSSOVER_H_ */ 150 | -------------------------------------------------------------------------------- /variation/crossover/DiscreteCrossover.h: -------------------------------------------------------------------------------- 1 | // CGP++: Modern C++ Implementation of Cartesian Genetic Programming 2 | // =============================================================================== 3 | // File: DiscreteCrossover.h 4 | // =============================================================================== 5 | // 6 | // =============================================================================== 7 | // Copyright (C) 2024 8 | // 9 | // 10 | // License: Academic Free License v. 3.0 11 | // ================================================================================ 12 | 13 | 14 | #ifndef VARIATION_CROSSOVER_DISCRETECROSSOVER_H_ 15 | #define VARIATION_CROSSOVER_DISCRETECROSSOVER_H_ 16 | 17 | #include 18 | 19 | #include "../BinaryOperator.h" 20 | 21 | /// @brief Class for the representation of discrete recombination that has been proposed for CGP. 22 | /// @details Adaption of discrete/uniform recombination in CGP. This is a phenotypic variation 23 | /// method for discrete recombination in CGP. It adapts discrete recombination in CGP by means of 24 | /// phenotypic functional variation which is performed through the exchange of function genes of active function nodes. 25 | /// Reasonable results were obtained on several symbolic regression benchmarks (Kalkreuth (2021)) 26 | /// @see Kalkreuth, R. (2022). Towards Discrete Phenotypic Recombination in Cartesian Genetic Programming. 27 | /// https://doi.org/10.1007/978-3-031-14721-0_5 28 | /// @see Kalkreuth R. (2021). Reconsideration and extension of Cartesian genetic programming 29 | /// http://dx.doi.org/10.17877/DE290R-22504 30 | /// @tparam G Genome type 31 | /// @tparam F Fitness type 32 | template 33 | class DiscreteCrossover: public BinaryOperator { 34 | public: 35 | DiscreteCrossover(std::shared_ptr p_parameters, 36 | std::shared_ptr p_random, 37 | std::shared_ptr> p_species) : 38 | BinaryOperator(p_parameters, p_random, p_species) { 39 | this->name = "Discrete Crossover"; 40 | } 41 | 42 | virtual ~DiscreteCrossover() = default; 43 | 44 | void variate(std::shared_ptr> p1, 45 | std::shared_ptr> p2) override; 46 | }; 47 | 48 | template 49 | void DiscreteCrossover::variate(std::shared_ptr> p1, 50 | std::shared_ptr> p2) { 51 | 52 | if (p1->num_active_nodes() == 0 || p2->num_active_nodes() == 0) { 53 | return; 54 | } 55 | 56 | int tmp = 0; 57 | int num_inputs = this->parameters->get_num_inputs(); 58 | int max_arity = this->parameters->get_max_arity(); 59 | 60 | // Boundary extension is activated by default 61 | bool boundary_extension = true; 62 | 63 | std::shared_ptr g1 = p1->get_genome(); 64 | std::shared_ptr g2 = p2->get_genome(); 65 | 66 | // Node numbers are stored if two nodes are selected for the swap of the function gene 67 | int swap_node1 = 0; 68 | int swap_node2 = 0; 69 | 70 | // Indices for the function genes 71 | int index1 = 0; 72 | int index2 = 0; 73 | 74 | // Determine the phenotypic length 75 | std::shared_ptr> active_nodes1 = p1->get_active_nodes(); 76 | std::shared_ptr> active_nodes2 = p2->get_active_nodes(); 77 | 78 | // Determine the phenotypic length 79 | int len1 = active_nodes1->size(); 80 | int len2 = active_nodes2->size(); 81 | 82 | // check that the chromosomes are equally long (true in most cases) 83 | int min = std::min(len1, len2); 84 | int max = std::max(len1, len2); 85 | 86 | // Iterate over the minimum phenotypic length 87 | for (int x = 0; x < min; x++) { 88 | 89 | // Decide uniformly at random whether a gene swap will be performed or not 90 | if (this->random->random_bool()) { 91 | 92 | // If boundary extension is activated, we select a swap node for 93 | // the phenotypically larger parent beyond the minimum number of 94 | // active nodes of both parents 95 | if (boundary_extension && x == (min - 1) && len1 != len2) { 96 | 97 | // Choose the extension by chance 98 | int r = this->random->random_integer(0, max - x - 1); 99 | 100 | if (len1 < len2) { 101 | swap_node1 = active_nodes1->at(x); 102 | swap_node2 = active_nodes2->at(x + r); 103 | } else { 104 | swap_node1 = active_nodes1->at(x + r); 105 | swap_node2 = active_nodes2->at(x); 106 | } 107 | 108 | } else { // Just choose the swap nodes "in-line" without any extension 109 | swap_node1 = active_nodes1->at(x); 110 | swap_node2 = active_nodes2->at(x); 111 | } 112 | 113 | // calculate the swap indexes 114 | index1 = (swap_node1 - num_inputs) * (1 + max_arity); 115 | index2 = (swap_node2 - num_inputs) * (1 + max_arity); 116 | 117 | // perform the swaps 118 | tmp = g1[index1]; 119 | g1[index1] = g2[index2]; 120 | g2[index2] = tmp; 121 | } 122 | } 123 | 124 | } 125 | 126 | #endif /* VARIATION_CROSSOVER_DISCRETECROSSOVER_H_ */ 127 | -------------------------------------------------------------------------------- /variation/mutation/Duplication.h: -------------------------------------------------------------------------------- 1 | // CGP++: Modern C++ Implementation of Cartesian Genetic Programming 2 | // =============================================================================== 3 | // File: Duplication.h 4 | // =============================================================================== 5 | // 6 | // =============================================================================== 7 | // Copyright (C) 2024 8 | // 9 | // 10 | // License: Academic Free License v. 3.0 11 | // ================================================================================ 12 | 13 | #ifndef VARIATION_MUTATION_DUPLICATION_H_ 14 | #define VARIATION_MUTATION_DUPLICATION_H_ 15 | 16 | #include "Phenotypic.h" 17 | 18 | /// @brief Represents the duplication mutation operator that has been proposed for CGP. 19 | /// @details Duplicates the function gene of a randomly selected active node to a following sequence of active nodes. 20 | /// The size of the sequence is determined by chance and in respect to the number of active nodes. 21 | /// @see Kalkreuth R. (2022): Phenotypic duplication and inversion in cartesian genetic programming applied to boolean function learning 22 | /// https://doi.org/10.1145/3520304.3529065 23 | /// @tparam G Genome type 24 | /// @tparam F Fitness type 25 | template 26 | class Duplication: public Phenotypic { 27 | public: 28 | Duplication(std::shared_ptr p_parameters, 29 | std::shared_ptr p_random, 30 | std::shared_ptr> p_species); 31 | virtual ~Duplication() = default; 32 | 33 | void variate(std::shared_ptr> individual) override; 34 | }; 35 | 36 | template 37 | Duplication::Duplication( 38 | std::shared_ptr p_parameters, 39 | std::shared_ptr p_random, std::shared_ptr> p_species) : 40 | Phenotypic(p_parameters, p_random, p_species) { 41 | 42 | this->name = "Duplication"; 43 | this->rate = this->parameters->get_duplication_rate(); 44 | this->max_depth = this->parameters->get_max_duplication_depth(); 45 | } 46 | ; 47 | 48 | /// @brief Mutate an individual by means of duplication. 49 | /// @details Selects a random start position in the genome and duplicates the function gene 50 | /// to a set of subsequent function nodes. 51 | /// @param individual CGP individual to mutate 52 | template 53 | void Duplication::variate( 54 | std::shared_ptr> individual) { 55 | 56 | int num_active_nodes = individual->num_active_nodes(); 57 | 58 | // We need at least two active function nodes 59 | if (num_active_nodes <= 1) { 60 | return; 61 | } 62 | 63 | int depth; 64 | int start; 65 | int end; 66 | int position; 67 | int node; 68 | int function; 69 | 70 | std::shared_ptr> active_nodes = individual->get_active_nodes(); 71 | std::shared_ptr genome = individual->get_genome(); 72 | 73 | // Determine a valid inversion depth by chance and get a suitable start index 74 | depth = this->stochastic_depth(this->max_depth, 75 | num_active_nodes); 76 | start = this->start_index(num_active_nodes, depth); 77 | 78 | end = start + depth; 79 | 80 | // Get the node number with respect to the determined start index 81 | node = active_nodes->at(start); 82 | 83 | // Get the position of the function gene 84 | position = this->species->position_from_node_number(node); 85 | 86 | // Get the function gene value 87 | function = genome[position]; 88 | 89 | // Finally duplicate the gene with the respective depth 90 | for (int i = start + 1; i <= end; i++) { 91 | node = active_nodes->at(i); 92 | position = this->species->position_from_node_number(node); 93 | genome[position] = function; 94 | } 95 | 96 | } 97 | 98 | #endif /* VARIATION_MUTATION_DUPLICATION_H_ */ 99 | -------------------------------------------------------------------------------- /variation/mutation/Inversion.h: -------------------------------------------------------------------------------- 1 | // CGP++: Modern C++ Implementation of Cartesian Genetic Programming 2 | // =============================================================================== 3 | // File: Inversion.h 4 | // =============================================================================== 5 | // 6 | // =============================================================================== 7 | // Copyright (C) 2024 8 | // 9 | // 10 | // License: Academic Free License v. 3.0 11 | // ================================================================================ 12 | 13 | #ifndef VARIATION_MUTATION_INVERSION_H_ 14 | #define VARIATION_MUTATION_INVERSION_H_ 15 | 16 | #include 17 | 18 | #include "Phenotypic.h" 19 | 20 | /// @brief Represents the inversion mutation operator that has been proposed for CGP. 21 | /// @details Inverts the order of function genes of a randomly selected set of active nodes. The size of the set 22 | /// is determined by chance and in respect to the number of active nodes. 23 | /// @see Kalkreuth R. (2022): Phenotypic duplication and inversion in cartesian genetic programming applied to boolean function learning 24 | /// https://doi.org/10.1145/3520304.3529065 25 | /// @tparam G Genome type 26 | /// @tparam F Fitness type 27 | template 28 | class Inversion: public Phenotypic { 29 | public: 30 | Inversion(std::shared_ptr p_parameters, 31 | std::shared_ptr p_random, 32 | std::shared_ptr> p_species); 33 | virtual ~Inversion() = default; 34 | 35 | void variate(std::shared_ptr> individual) override; 36 | }; 37 | 38 | template 39 | Inversion::Inversion(std::shared_ptr p_parameters, 40 | std::shared_ptr p_random, 41 | std::shared_ptr> p_species) : Phenotypic(p_parameters, p_random, p_species) { 42 | 43 | this->name = "Inversion"; 44 | 45 | this->rate = this->parameters->get_inversion_rate(); 46 | this->max_depth = this->parameters->get_max_inversion_depth(); 47 | 48 | }; 49 | 50 | /// @brief Mutate an individual by means of inversion. 51 | /// @details Selects a random start position in the genome and inverts a subsequent 52 | /// set of function genes of the respective function nodes. 53 | /// @param individual CGP individual to mutate 54 | template 55 | void Inversion::variate( 56 | std::shared_ptr> individual) { 57 | 58 | int num_active_nodes = individual->num_active_nodes(); 59 | 60 | // We need at least two active function nodes 61 | if (num_active_nodes <= 1) { 62 | return; 63 | } 64 | 65 | int depth; 66 | int start; 67 | int end; 68 | int left_node; 69 | int left_position; 70 | int right_node; 71 | int right_position; 72 | int middle; 73 | int tmp; 74 | 75 | std::shared_ptr> active_nodes = 76 | individual->get_active_nodes(); 77 | 78 | std::shared_ptr genome = individual->get_genome(); 79 | 80 | // Determine a valid inversion depth by chance and get a suitable start index 81 | depth = this->stochastic_depth(this->max_depth, num_active_nodes); 82 | start = this->start_index(num_active_nodes, depth); 83 | 84 | // Calculate end point and middle for the set of nodes which will be mutated 85 | end = start + depth; 86 | middle = round(depth / 2.0); 87 | 88 | // Perform the inversion by iterating until the middle is reached and pairwise exchanging 89 | // the function genes 90 | for (int i = 0; i < middle; i++) { 91 | left_node = active_nodes->at(start + i); 92 | right_node = active_nodes->at(end - i); 93 | 94 | left_position = this->species->position_from_node_number(left_node); 95 | right_position = this->species->position_from_node_number(right_node); 96 | 97 | tmp = genome[left_position]; 98 | genome[left_position] = genome[right_position]; 99 | genome[right_position] = tmp; 100 | } 101 | 102 | } 103 | 104 | #endif /* VARIATION_MUTATION_INVERSION_H_ */ 105 | -------------------------------------------------------------------------------- /variation/mutation/Phenotypic.h: -------------------------------------------------------------------------------- 1 | // CGP++: Modern C++ Implementation of Cartesian Genetic Programming 2 | // =============================================================================== 3 | // File: Phenotypic.h 4 | // =============================================================================== 5 | // 6 | // =============================================================================== 7 | // Copyright (C) 2024 8 | // 9 | // 10 | // License: Academic Free License v. 3.0 11 | // ================================================================================ 12 | 13 | #ifndef VARIATION_MUTATION_PHENOTYPIC_H_ 14 | #define VARIATION_MUTATION_PHENOTYPIC_H_ 15 | 16 | #include "../UnaryOperator.h" 17 | 18 | /// @brief Abstract base class for the implementation of phenotypic mutation in CGP. 19 | /// @tparam G Genome type 20 | /// @tparam F Fitness type 21 | template 22 | class Phenotypic : public UnaryOperator { 23 | protected: 24 | float rate; 25 | int max_depth; 26 | public: 27 | Phenotypic(std::shared_ptr p_parameters, 28 | std::shared_ptr p_random, 29 | std::shared_ptr> p_species) : UnaryOperator(p_parameters, p_random, p_species) {}; 30 | virtual ~Phenotypic() = default; 31 | 32 | void variate(std::shared_ptr> individual) = 0; 33 | 34 | int start_index(int num_active_nodes, int depth); 35 | int stochastic_depth(int max_depth, int num_active_nodes); 36 | }; 37 | 38 | /// @brief Determines a start position for the mutation within the genome by chance. 39 | /// @param num_active_nodes number of active function nodes 40 | /// @param depth mutation depth, number of function genes that will be considered 41 | /// @return start position in the genome 42 | template 43 | int Phenotypic::start_index(int num_active_nodes, int depth) { 44 | int start_max = num_active_nodes - depth; 45 | int start; 46 | 47 | if (start_max <= 0) { 48 | start = 0; 49 | } else { 50 | start = this->random->random_integer(0, start_max - 1); 51 | } 52 | 53 | return start; 54 | } 55 | 56 | /// @brief Determnes the depth of the mutation by chance 57 | /// @param max_depth maximum depth of the mutation 58 | /// @param num_active_nodes number of active function nodes 59 | /// @return mutation depth 60 | template 61 | int Phenotypic::stochastic_depth(int max_depth, int num_active_nodes) { 62 | int depth; 63 | int max; 64 | 65 | if (num_active_nodes <= max_depth) { 66 | max = num_active_nodes - 1; 67 | } else { 68 | max = max_depth; 69 | } 70 | 71 | depth = this->random->random_integer(1, max); 72 | 73 | return depth; 74 | } 75 | 76 | 77 | #endif /* VARIATION_MUTATION_PHENOTYPIC_H_ */ 78 | -------------------------------------------------------------------------------- /variation/mutation/ProbabilisticPoint.h: -------------------------------------------------------------------------------- 1 | // CGP++: Modern C++ Implementation of Cartesian Genetic Programming 2 | // =============================================================================== 3 | // File: ProbabilisticPoint.h 4 | // =============================================================================== 5 | // 6 | // =============================================================================== 7 | // Copyright (C) 2024 8 | // 9 | // 10 | // License: Academic Free License v. 3.0 11 | // ================================================================================ 12 | 13 | #ifndef VARIATION_POINTMUTATION_H_ 14 | #define VARIATION_POINTMUTATION_H_ 15 | 16 | #include "../UnaryOperator.h" 17 | 18 | /// @brief Standard probabilistic point mutation commonly used in CGP. 19 | /// @see Miller, J.F. (2011). Cartesian Genetic Programming. 20 | /// https://doi.org/10.1007/978-3-642-17310-3_2 21 | /// @tparam G Genome type 22 | /// @tparam F Fitness type 23 | template 24 | class ProbabilisticPoint : public UnaryOperator { 25 | private: 26 | float mutation_rate; 27 | public: 28 | ProbabilisticPoint(std::shared_ptr p_parameters, 29 | std::shared_ptr p_random, 30 | std::shared_ptr> p_species); 31 | virtual ~ProbabilisticPoint() = default; 32 | 33 | void variate(std::shared_ptr> individual) override; 34 | }; 35 | 36 | template 37 | ProbabilisticPoint::ProbabilisticPoint(std::shared_ptr p_parameters, 38 | std::shared_ptr p_random, 39 | std::shared_ptr> p_species) : UnaryOperator(p_parameters, p_random, p_species ) { 40 | 41 | this->name = "Probabilistic Point"; 42 | this->mutation_rate = this->parameters->get_mutation_rate(); 43 | } 44 | 45 | /// @brief Performs the standard (probabilistic) point mutation. 46 | /// @details Selects gene by chanc according to a mutation rate and mutates 47 | /// the gene values in the legal range. 48 | /// @param individual CGP individual to mutate 49 | template 50 | void ProbabilisticPoint::variate(std::shared_ptr> individual) { 51 | 52 | std::shared_ptr genome = individual-> get_genome(); 53 | 54 | int genome_size = this->parameters->get_genome_size(); 55 | int max_gene; 56 | int min_gene; 57 | 58 | int num_mutations = this->mutation_rate * genome_size; 59 | int random_pos; 60 | 61 | for (int i = 0; i < num_mutations; i++) { 62 | 63 | random_pos = this->random->random_integer(0, genome_size - 1); 64 | 65 | if (this->species->is_real_valued()) { 66 | genome[random_pos] = this->random->random_float(0.0, 1.0); 67 | } else { 68 | min_gene = this->species->min_gene(random_pos); 69 | max_gene = this->species->max_gene(random_pos); 70 | genome[random_pos] = this->random->random_integer( 71 | min_gene, max_gene); 72 | } 73 | 74 | } 75 | 76 | } 77 | 78 | #endif /* VARIATION_POINTMUTATION_H_ */ 79 | -------------------------------------------------------------------------------- /variation/mutation/SingleActiveGene.h: -------------------------------------------------------------------------------- 1 | // CGP++: Modern C++ Implementation of Cartesian Genetic Programming 2 | // =============================================================================== 3 | // File: SingleActiveGene.h 4 | // =============================================================================== 5 | // 6 | // =============================================================================== 7 | // Copyright (C) 2024 8 | // 9 | // 10 | // License: Academic Free License v. 3.0 11 | // ================================================================================ 12 | 13 | 14 | #ifndef VARIATION_SINGLEACTIVEGENEMUTATION_H_ 15 | #define VARIATION_SINGLEACTIVEGENEMUTATION_H_ 16 | 17 | #include "../UnaryOperator.h" 18 | 19 | /// @brief Represents the single active gene mutation that has been proposed for CGP. 20 | /// @details Mutates exactly one active gene per mutation. 21 | /// @see Goldman, B.W., Punch, W.F. (2013): Reducing Wasted Evaluations in Cartesian Genetic Programming 22 | /// https://doi.org/10.1007/978-3-642-37207-0_6 23 | /// @tparam G Genome type 24 | /// @tparam F Fitness type 25 | template 26 | class SingleActiveGene: public UnaryOperator { 27 | public: 28 | SingleActiveGene(std::shared_ptr p_parameters, 29 | std::shared_ptr p_random, 30 | std::shared_ptr> p_species); 31 | 32 | virtual ~SingleActiveGene() = default; 33 | 34 | void variate(std::shared_ptr> individual) override; 35 | }; 36 | 37 | template 38 | SingleActiveGene::SingleActiveGene(std::shared_ptr p_parameters, 39 | std::shared_ptr p_random, 40 | std::shared_ptr> p_species) : UnaryOperator(p_parameters, p_random, p_species ) { 41 | this->name = "Single Active Gene"; 42 | } 43 | 44 | /// @brief Selects one active gene by chance which is then mutated 45 | /// @param individual CGP individual to mutate 46 | template 47 | void SingleActiveGene::variate( 48 | std::shared_ptr> individual) { 49 | 50 | std::shared_ptr> active_nodes = individual->get_active_nodes(); 51 | std::shared_ptr genome = individual-> get_genome(); 52 | 53 | int num_active_nodes = active_nodes->size(); 54 | 55 | if (num_active_nodes == 0) { 56 | return; 57 | } 58 | 59 | int max_arity = this->parameters->get_max_arity(); 60 | 61 | int rand_node_index = this->random->random_integer(0, num_active_nodes - 1); 62 | int rand_node_number = active_nodes->at(rand_node_index); 63 | int rand_gene_index = this->random->random_integer(0, max_arity); 64 | 65 | int mutation_pos = this->species->position_from_node_number( 66 | rand_node_number) + rand_gene_index; 67 | 68 | int min_gene = this->species->min_gene(mutation_pos); 69 | int max_gene = this->species->max_gene(mutation_pos); 70 | 71 | genome[mutation_pos] = this->random->random_integer(min_gene, 72 | max_gene); 73 | 74 | } 75 | 76 | #endif /* VARIATION_SINGLEACTIVEGENEMUTATION_H_ */ 77 | --------------------------------------------------------------------------------