-
Notifications
You must be signed in to change notification settings - Fork 11
Adding elements to the generator component
Dominik Drexler edited this page Jun 14, 2021
·
6 revisions
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.
// 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;
assert(i + j == iteration);
assert(i >= 1 && j >= 1);
int indices[2] = {i, j};
std::sort(indices, indices+2);
do {
for (const auto& concept_left : m_boolean_elements_by_complexity[indices[0]]) {
for (const auto& concept_right : m_boolean_elements_by_complexity[indices[1]]) {
if (!m_timer.is_expired())
add_boolean(states, m_factory->make_equal_boolean(concept_left, concept_right), feature_collection);
}
}
} while (std::next_permutation(indices, indices+2));
// Add construction of role pairs here
// ...
}
}// 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);
// ...
}
}