From 1d60a5ab7bac488d4715df307645bb6047fe230a Mon Sep 17 00:00:00 2001 From: Samuel Stante Date: Fri, 19 Jul 2024 18:20:40 +0200 Subject: [PATCH] add r_til_c generator --- src/generator/rules/roles/til_c.cpp | 41 +++++++-------------------- tests/generator/delivery/delivery.cpp | 1 + 2 files changed, 12 insertions(+), 30 deletions(-) diff --git a/src/generator/rules/roles/til_c.cpp b/src/generator/rules/roles/til_c.cpp index 753f9f00..de86d8c2 100644 --- a/src/generator/rules/roles/til_c.cpp +++ b/src/generator/rules/roles/til_c.cpp @@ -7,37 +7,18 @@ namespace dlplan::generator::rules { void TilCRole::generate_impl(const core::States& states, int target_complexity, GeneratorData& data, core::DenotationsCaches& caches) { - return; - //TODO - if (target_complexity == 3) - { + if (target_complexity == 3) { core::SyntacticElementFactory& factory = data.m_factory; - for (int i = 1; i < target_complexity - 1; ++i) - { - int j = target_complexity - i - 1; - for (const auto& r1 : data.m_roles_by_iteration[i]) - { - auto r1_primitive_role = std::dynamic_pointer_cast(r1); - if (r1_primitive_role) - { - std::string r1_predicate_name = r1_primitive_role->get_predicate().get_name(); - for (const auto& r2 : data.m_roles_by_iteration[j]) - { - auto r2_primitive_role = std::dynamic_pointer_cast(r2); - if (r2_primitive_role) - { - std::string r2_predicate_name = r2_primitive_role->get_predicate().get_name(); - if ((r1_predicate_name) == r2_predicate_name + "_g") { - auto element = factory.make_and_role(r1, r2); - auto denotations = element->evaluate(states, caches); - if (data.m_role_hash_table.insert(denotations).second) - { - std::get<3>(data.m_generated_features).push_back(element); - data.m_roles_by_iteration[target_complexity].push_back(std::move(element)); - increment_generated(); - } - } - } + for (int i = 1; i < target_complexity - 1; ++i) { + int j = target_complexity - i - 1 ; + for (const auto& r : data.m_roles_by_iteration[i]) { + for (const auto& c : data.m_concepts_by_iteration[j]) { + auto element = factory.make_til_c_role(r, c); + auto denotations = element->evaluate(states, caches); + if (data.m_role_hash_table.insert(denotations).second) { + std::get<3>(data.m_generated_features).push_back(element); + data.m_roles_by_iteration[target_complexity].push_back(std::move(element)); + increment_generated(); } } } diff --git a/tests/generator/delivery/delivery.cpp b/tests/generator/delivery/delivery.cpp index f8f845f0..6178bb6d 100644 --- a/tests/generator/delivery/delivery.cpp +++ b/tests/generator/delivery/delivery.cpp @@ -30,6 +30,7 @@ TEST(DLPTests, GeneratorDeliveryTest) { feature_generator.set_generate_not_role(false); feature_generator.set_generate_or_role(false); feature_generator.set_generate_top_role(false); + feature_generator.set_generate_til_c_role(false); feature_generator.set_generate_transitive_reflexive_closure_role(false); SyntacticElementFactory syntactic_element_factory(vocabulary_info); States states;