Skip to content

Commit

Permalink
added same restriction to r_and as for c_equal
Browse files Browse the repository at this point in the history
  • Loading branch information
drexlerd committed Mar 8, 2024
1 parent b667e6a commit 65bd12b
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 23 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from setuptools import setup, find_packages, Extension
from setuptools.command.build_ext import build_ext

__version__ = "0.3.22"
__version__ = "0.3.23"
HERE = Path(__file__).resolve().parent


Expand Down
26 changes: 15 additions & 11 deletions src/generator/rules/concepts/equal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,29 @@

namespace dlplan::generator::rules {
void EqualConcept::generate_impl(const core::States& states, int target_complexity, GeneratorData& data, core::DenotationsCaches& caches) {
if (target_complexity == 3) {
if (target_complexity == 3)
{
core::SyntacticElementFactory& factory = data.m_factory;
for (int i = 1; i < target_complexity - 1; ++i) {
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]) {
for (const auto& r1 : data.m_roles_by_iteration[i])
{
auto r1_primitive_role = std::dynamic_pointer_cast<const core::PrimitiveRole>(r1);
if (r1_primitive_role) {
if (r1_primitive_role)
{
std::string r1_predicate_name = r1_primitive_role->get_predicate().get_name();
if (r1_predicate_name.substr(r1_predicate_name.size() - 2, 2) != "_g") {
continue;
}
for (const auto& r2 : data.m_roles_by_iteration[j]) {
for (const auto& r2 : data.m_roles_by_iteration[j])
{
auto r2_primitive_role = std::dynamic_pointer_cast<const core::PrimitiveRole>(r2);
if (r2_primitive_role) {
if (r2_primitive_role)
{
std::string r2_predicate_name = r2_primitive_role->get_predicate().get_name();
if (r1_predicate_name.substr(0, r1_predicate_name.size() -2) == r2_predicate_name) {
if ((r1_predicate_name) == r2_predicate_name + "_g") {
auto element = factory.make_equal_concept(r2, r1);
auto denotations = element->evaluate(states, caches);
if (data.m_concept_hash_table.insert(denotations).second) {
if (data.m_concept_hash_table.insert(denotations).second)
{
std::get<2>(data.m_generated_features).push_back(element);
data.m_concepts_by_iteration[target_complexity].push_back(std::move(element));
increment_generated();
Expand Down
43 changes: 32 additions & 11 deletions src/generator/rules/roles/and.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,41 @@

#include "../../generator_data.h"

#include "../../../../include/dlplan/core/elements/roles/primitive.h"


namespace dlplan::generator::rules {
void AndRole::generate_impl(const core::States& states, int target_complexity, GeneratorData& data, core::DenotationsCaches& caches) {
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]) {
for (const auto& r2 : data.m_roles_by_iteration[j]) {
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();
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<const core::PrimitiveRole>(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<const core::PrimitiveRole>(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();
}
}
}
}
}
}
}
Expand Down

0 comments on commit 65bd12b

Please sign in to comment.