Skip to content

Adding elements to the generator component

Dominik Drexler edited this page Sep 1, 2021 · 6 revisions

Introduction

The generator component is capable of automatically generating features by exhaustively stacking the elements of the core components. The generator accepts a set of states such that newly generated features are pruned if its state evaluations are identical to those of a feature that was generated before. Adding new features to the generator is a simple two-step procedure.

Step 1: Adding a generator function

// src/generator/feature_generator.h
private:
    void generate_equal_boolean(const States& states, int iteration, FeatureCollection& feature_collection);
// src/generator/feature_generator.cpp
void FeatureGenerator::generate_equal_boolean(const States& states, int iteration, FeatureCollection& feature_collection) {
    for (int i = 1; i < iteration; ++i) {
        int j = iteration - i;
        for (const auto& boolean_left : m_boolean_elements_by_complexity[i]) {
            for (const auto& boolean_right : m_boolean_elements_by_complexity[j]) {
                if (reached_limit()) return;
                else add_boolean(states, m_factory->make_equal_boolean(boolean_left, boolean_right), feature_collection);
            }
        }
        // Add construction over pairs of Numerical, etc.
        // ...
    }
}

Step 2: Adding the generator function to the loop

// src/generator/feature_generator.cpp
void FeatureGenerator::generate_inductively(const States& states, FeatureCollection& feature_collection) {
    for (int i = 1; i < iteration; ++i) {
        // ...
        generate_equal_boolean(states, iteration, feature_collection);
        // ...
    }
}

Clone this wiki locally