Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue1128 #200

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 22 additions & 5 deletions src/search/pdbs/cegar.cc
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class CEGAR {
const int max_collection_size;
const double max_time;
const bool use_wildcard_plans;
const bool use_restricted_goal;
utils::LogProxy &log;
shared_ptr<utils::RandomNumberGenerator> rng;
const shared_ptr<AbstractTask> &task;
Expand Down Expand Up @@ -151,6 +152,7 @@ class CEGAR {
int max_collection_size,
double max_time,
bool use_wildcard_plans,
bool use_restricted_goal,
utils::LogProxy &log,
const shared_ptr<utils::RandomNumberGenerator> &rng,
const shared_ptr<AbstractTask> &task,
Expand All @@ -164,6 +166,7 @@ CEGAR::CEGAR(
int max_collection_size,
double max_time,
bool use_wildcard_plans,
bool use_restricted_goal,
utils::LogProxy &log,
const shared_ptr<utils::RandomNumberGenerator> &rng,
const shared_ptr<AbstractTask> &task,
Expand All @@ -173,6 +176,7 @@ CEGAR::CEGAR(
max_collection_size(max_collection_size),
max_time(max_time),
use_wildcard_plans(use_wildcard_plans),
use_restricted_goal(use_restricted_goal),
log(log),
rng(rng),
task(task),
Expand Down Expand Up @@ -385,7 +389,7 @@ bool CEGAR::get_flaws_for_pattern(
log << "plan did not lead to a goal state: ";
}
bool raise_goal_flaw = false;
for (const FactPair &goal : goals) {
for (const FactPair &goal : use_restricted_goal ? goals : task_properties::get_fact_pairs(task_proxy.get_goals())) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find this a bit unintuitive. At this point goals is something that is passed to the class in the constructor. Instead of passing goals and an option that essential is ignore_the_goal_I_gave_you_and_use_something_else, can we handle the option earlier and just pass a modified goal vector to the class?

int goal_var_id = goal.var;
if (final_state[goal_var_id].get_value() != goal.value &&
!blacklisted_variables.count(goal_var_id)) {
Expand Down Expand Up @@ -564,7 +568,7 @@ PatternCollectionInformation CEGAR::compute_pattern_collection() {
log << "max time: " << max_time << endl;
log << "wildcard plans: " << use_wildcard_plans << endl;
log << "goal variables: ";
for (const FactPair &goal : this->goals) {
for (const FactPair &goal : use_restricted_goal ? this->goals : task_properties::get_fact_pairs(task_proxy.get_goals())) {
log << goal.var << ", ";
}
log << endl;
Expand Down Expand Up @@ -661,6 +665,7 @@ PatternCollectionInformation generate_pattern_collection_with_cegar(
int max_collection_size,
double max_time,
bool use_wildcard_plans,
bool use_restricted_goal,
utils::LogProxy &log,
const shared_ptr<utils::RandomNumberGenerator> &rng,
const shared_ptr<AbstractTask> &task,
Expand All @@ -671,6 +676,7 @@ PatternCollectionInformation generate_pattern_collection_with_cegar(
max_collection_size,
max_time,
use_wildcard_plans,
use_restricted_goal,
log,
rng,
task,
Expand All @@ -683,6 +689,7 @@ PatternInformation generate_pattern_with_cegar(
int max_pdb_size,
double max_time,
bool use_wildcard_plans,
bool use_restricted_goal,
utils::LogProxy &log,
const shared_ptr<utils::RandomNumberGenerator> &rng,
const shared_ptr<AbstractTask> &task,
Expand All @@ -694,6 +701,7 @@ PatternInformation generate_pattern_with_cegar(
max_pdb_size,
max_time,
use_wildcard_plans,
use_restricted_goal,
log,
rng,
task,
Expand Down Expand Up @@ -778,16 +786,25 @@ void add_cegar_implementation_notes_to_feature(plugins::Feature &feature) {
true);
}

void add_cegar_wildcard_option_to_feature(plugins::Feature &feature) {
void add_cegar_options_to_feature(plugins::Feature &feature) {
feature.add_option<bool>(
"use_wildcard_plans",
"if true, compute wildcard plans which are sequences of sets of "
"operators that induce the same transition; otherwise compute regular "
"plans which are sequences of single operators",
"true");

feature.add_option<bool>(
"use_restricted_goal",
"if true, CEGAR considers only those variables for goal flaws that are "
"used to initialize the pattern collection; otherwise all goal "
"variables can occur in goal flaws",
"false");
}
tuple<bool> get_cegar_wildcard_arguments_from_options(

tuple<bool, bool> get_cegar_arguments_from_options(
const plugins::Options &opts) {
return make_tuple(opts.get<bool>("use_wildcard_plans"));
return make_tuple(opts.get<bool>("use_wildcard_plans"),
opts.get<bool>("use_restricted_goal"));
}
}
6 changes: 4 additions & 2 deletions src/search/pdbs/cegar.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ extern PatternCollectionInformation generate_pattern_collection_with_cegar(
int max_collection_size,
double max_time,
bool use_wildcard_plans,
bool use_restricted_goal,
utils::LogProxy &log,
const std::shared_ptr<utils::RandomNumberGenerator> &rng,
const std::shared_ptr<AbstractTask> &task,
Expand All @@ -56,15 +57,16 @@ extern PatternInformation generate_pattern_with_cegar(
int max_pdb_size,
double max_time,
bool use_wildcard_plans,
bool use_restricted_goal,
utils::LogProxy &log,
const std::shared_ptr<utils::RandomNumberGenerator> &rng,
const std::shared_ptr<AbstractTask> &task,
const FactPair &goal,
std::unordered_set<int> &&blacklisted_variables = std::unordered_set<int>());

extern void add_cegar_implementation_notes_to_feature(plugins::Feature &feature);
extern void add_cegar_wildcard_option_to_feature(plugins::Feature &feature);
std::tuple<bool> get_cegar_wildcard_arguments_from_options(
extern void add_cegar_options_to_feature(plugins::Feature &feature);
std::tuple<bool, bool> get_cegar_arguments_from_options(
const plugins::Options &opts);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ using namespace std;
namespace pdbs {
PatternCollectionGeneratorDisjointCegar::PatternCollectionGeneratorDisjointCegar(
int max_pdb_size, int max_collection_size, double max_time,
bool use_wildcard_plans, int random_seed,
bool use_wildcard_plans, bool use_restricted_goal, int random_seed,
utils::Verbosity verbosity)
: PatternCollectionGenerator(verbosity),
max_pdb_size(max_pdb_size),
max_collection_size(max_collection_size),
max_time(max_time),
use_wildcard_plans(use_wildcard_plans),
use_restricted_goal(use_restricted_goal),
rng(utils::get_rng(random_seed)) {
}

Expand All @@ -37,6 +38,7 @@ PatternCollectionInformation PatternCollectionGeneratorDisjointCegar::compute_pa
max_collection_size,
max_time,
use_wildcard_plans,
use_restricted_goal,
log,
rng,
task,
Expand Down Expand Up @@ -77,7 +79,7 @@ class PatternCollectionGeneratorDisjointCegarFeature
"singleton pattern for each goal variable)",
"infinity",
plugins::Bounds("0.0", "infinity"));
add_cegar_wildcard_option_to_feature(*this);
add_cegar_options_to_feature(*this);
utils::add_rng_options_to_feature(*this);
add_generator_options_to_feature(*this);

Expand All @@ -91,7 +93,7 @@ class PatternCollectionGeneratorDisjointCegarFeature
opts.get<int>("max_pdb_size"),
opts.get<int>("max_collection_size"),
opts.get<double>("max_time"),
get_cegar_wildcard_arguments_from_options(opts),
get_cegar_arguments_from_options(opts),
utils::get_rng_arguments_from_options(opts),
get_generator_arguments_from_options(opts)
);
Expand Down
5 changes: 3 additions & 2 deletions src/search/pdbs/pattern_collection_generator_disjoint_cegar.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class PatternCollectionGeneratorDisjointCegar : public PatternCollectionGenerato
const int max_collection_size;
const double max_time;
const bool use_wildcard_plans;
const bool use_restricted_goal;
std::shared_ptr<utils::RandomNumberGenerator> rng;

virtual std::string name() const override;
Expand All @@ -25,8 +26,8 @@ class PatternCollectionGeneratorDisjointCegar : public PatternCollectionGenerato
public:
PatternCollectionGeneratorDisjointCegar(
int max_pdb_size, int max_collection_size, double max_time,
bool use_wildcard_plans, int random_seed,
utils::Verbosity verbosity);
bool use_wildcard_plans, bool use_restricted_goal,
int random_seed, utils::Verbosity verbosity);
};
}

Expand Down
18 changes: 10 additions & 8 deletions src/search/pdbs/pattern_collection_generator_multiple_cegar.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,18 @@ using namespace std;

namespace pdbs {
PatternCollectionGeneratorMultipleCegar::PatternCollectionGeneratorMultipleCegar(
bool use_wildcard_plans, int max_pdb_size, int max_collection_size,
double pattern_generation_max_time, double total_max_time,
double stagnation_limit, double blacklist_trigger_percentage,
bool enable_blacklist_on_stagnation, int random_seed,
utils::Verbosity verbosity)
bool use_wildcard_plans, bool use_restricted_goal, int max_pdb_size,
int max_collection_size, double pattern_generation_max_time,
double total_max_time, double stagnation_limit,
double blacklist_trigger_percentage, bool enable_blacklist_on_stagnation,
int random_seed, utils::Verbosity verbosity)
: PatternCollectionGeneratorMultiple(
max_pdb_size, max_collection_size,
pattern_generation_max_time, total_max_time, stagnation_limit,
blacklist_trigger_percentage, enable_blacklist_on_stagnation,
random_seed, verbosity),
use_wildcard_plans(use_wildcard_plans) {
use_wildcard_plans(use_wildcard_plans),
use_restricted_goal(use_restricted_goal) {
}

string PatternCollectionGeneratorMultipleCegar::id() const {
Expand All @@ -40,6 +41,7 @@ PatternInformation PatternCollectionGeneratorMultipleCegar::compute_pattern(
max_pdb_size,
max_time,
use_wildcard_plans,
use_restricted_goal,
silent_log,
rng,
task,
Expand All @@ -60,7 +62,7 @@ class PatternCollectionGeneratorMultipleCegarFeature
"restricted to a single goal variable. See below for descriptions of "
"the algorithms.");

add_cegar_wildcard_option_to_feature(*this);
add_cegar_options_to_feature(*this);
add_multiple_options_to_feature(*this);

add_cegar_implementation_notes_to_feature(*this);
Expand All @@ -72,7 +74,7 @@ class PatternCollectionGeneratorMultipleCegarFeature
const plugins::Options &opts,
const utils::Context &) const override {
return plugins::make_shared_from_arg_tuples<PatternCollectionGeneratorMultipleCegar>(
get_cegar_wildcard_arguments_from_options(opts),
get_cegar_arguments_from_options(opts),
get_multiple_arguments_from_options(opts)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
namespace pdbs {
class PatternCollectionGeneratorMultipleCegar : public PatternCollectionGeneratorMultiple {
const bool use_wildcard_plans;
const bool use_restricted_goal;

virtual std::string id() const override;
virtual void initialize(const std::shared_ptr<AbstractTask> &) override {}
Expand All @@ -18,7 +19,7 @@ class PatternCollectionGeneratorMultipleCegar : public PatternCollectionGenerato
std::unordered_set<int> &&blacklisted_variables) override;
public:
PatternCollectionGeneratorMultipleCegar(
bool use_wildcard_plans, int max_pdb_size,
bool use_wildcard_plans, bool use_restricted_goal, int max_pdb_size,
int max_collection_size, double pattern_generation_max_time,
double total_max_time, double stagnation_limit,
double blacklist_trigger_percentage,
Expand Down
8 changes: 5 additions & 3 deletions src/search/pdbs/pattern_generator_cegar.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ using namespace std;
namespace pdbs {
PatternGeneratorCEGAR::PatternGeneratorCEGAR(
int max_pdb_size, double max_time, bool use_wildcard_plans,
int random_seed, utils::Verbosity verbosity)
bool use_restricted_goal, int random_seed, utils::Verbosity verbosity)
: PatternGenerator(verbosity),
max_pdb_size(max_pdb_size),
max_time(max_time),
use_wildcard_plans(use_wildcard_plans),
use_restricted_goal(use_restricted_goal),
rng(utils::get_rng(random_seed)) {
}

Expand All @@ -38,6 +39,7 @@ PatternInformation PatternGeneratorCEGAR::compute_pattern(
max_pdb_size,
max_time,
use_wildcard_plans,
use_restricted_goal,
log,
rng,
task,
Expand Down Expand Up @@ -67,7 +69,7 @@ class PatternGeneratorCEGARFeature
"maximum time in seconds for the pattern generation",
"infinity",
plugins::Bounds("0.0", "infinity"));
add_cegar_wildcard_option_to_feature(*this);
add_cegar_options_to_feature(*this);
utils::add_rng_options_to_feature(*this);
add_generator_options_to_feature(*this);

Expand All @@ -80,7 +82,7 @@ class PatternGeneratorCEGARFeature
return plugins::make_shared_from_arg_tuples<PatternGeneratorCEGAR>(
opts.get<int>("max_pdb_size"),
opts.get<double>("max_time"),
get_cegar_wildcard_arguments_from_options(opts),
get_cegar_arguments_from_options(opts),
utils::get_rng_arguments_from_options(opts),
get_generator_arguments_from_options(opts)
);
Expand Down
3 changes: 2 additions & 1 deletion src/search/pdbs/pattern_generator_cegar.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class PatternGeneratorCEGAR : public PatternGenerator {
const int max_pdb_size;
const double max_time;
const bool use_wildcard_plans;
const bool use_restricted_goal;
std::shared_ptr<utils::RandomNumberGenerator> rng;

virtual std::string name() const override;
Expand All @@ -20,7 +21,7 @@ class PatternGeneratorCEGAR : public PatternGenerator {
public:
PatternGeneratorCEGAR(
int max_pdb_size, double max_time, bool use_wildcard_plans,
int random_seed, utils::Verbosity verbosity);
bool use_restricted_goal, int random_seed, utils::Verbosity verbosity);
};
}

Expand Down
Loading