Skip to content

Commit

Permalink
Add option to decide which set of goals to use.
Browse files Browse the repository at this point in the history
  • Loading branch information
ClemensBuechner committed Jan 9, 2024
1 parent 183e378 commit 5e71b61
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 9 deletions.
21 changes: 17 additions & 4 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,8 +389,7 @@ bool CEGAR::get_flaws_for_pattern(
log << "plan did not lead to a goal state: ";
}
bool raise_goal_flaw = false;
for (const FactProxy &goal_proxy : task_proxy.get_goals()) {
const FactPair &goal = goal_proxy.get_pair();
for (const FactPair &goal : use_restricted_goal ? goals : task_properties::get_fact_pairs(task_proxy.get_goals())) {
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 @@ -565,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 @@ -662,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 @@ -672,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 @@ -684,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 @@ -695,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 @@ -779,12 +786,18 @@ 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");
}
}
4 changes: 3 additions & 1 deletion src/search/pdbs/cegar.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,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 @@ -55,14 +56,15 @@ 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);
extern void add_cegar_options_to_feature(plugins::Feature &feature);
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ PatternCollectionGeneratorDisjointCegar::PatternCollectionGeneratorDisjointCegar
max_collection_size(opts.get<int>("max_collection_size")),
max_time(opts.get<double>("max_time")),
use_wildcard_plans(opts.get<bool>("use_wildcard_plans")),
use_restricted_goal(opts.get<bool>("use_restricted_goal")),
rng(utils::parse_rng_from_options(opts)) {
}

Expand All @@ -35,6 +36,7 @@ PatternCollectionInformation PatternCollectionGeneratorDisjointCegar::compute_pa
max_collection_size,
max_time,
use_wildcard_plans,
use_restricted_goal,
log,
rng,
task,
Expand Down Expand Up @@ -74,7 +76,7 @@ class PatternCollectionGeneratorDisjointCegarFeature : public plugins::TypedFeat
"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);
add_generator_options_to_feature(*this);
utils::add_rng_options(*this);

Expand Down
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 Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ namespace pdbs {
PatternCollectionGeneratorMultipleCegar::PatternCollectionGeneratorMultipleCegar(
const plugins::Options &opts)
: PatternCollectionGeneratorMultiple(opts),
use_wildcard_plans(opts.get<bool>("use_wildcard_plans")) {
use_wildcard_plans(opts.get<bool>("use_wildcard_plans")),
use_restricted_goal(opts.get<bool>("use_restricted_goal")) {
}

string PatternCollectionGeneratorMultipleCegar::id() const {
Expand All @@ -32,6 +33,7 @@ PatternInformation PatternCollectionGeneratorMultipleCegar::compute_pattern(
max_pdb_size,
max_time,
use_wildcard_plans,
use_restricted_goal,
silent_log,
rng,
task,
Expand All @@ -52,7 +54,7 @@ class PatternCollectionGeneratorMultipleCegarFeature : public plugins::TypedFeat
"the algorithms.");

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

add_cegar_implementation_notes_to_feature(*this);
add_multiple_algorithm_implementation_notes_to_feature(*this);
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 Down
4 changes: 3 additions & 1 deletion src/search/pdbs/pattern_generator_cegar.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ PatternGeneratorCEGAR::PatternGeneratorCEGAR(const plugins::Options &opts)
max_pdb_size(opts.get<int>("max_pdb_size")),
max_time(opts.get<double>("max_time")),
use_wildcard_plans(opts.get<bool>("use_wildcard_plans")),
use_restricted_goal(opts.get<bool>("use_restricted_goal")),
rng(utils::parse_rng_from_options(opts)) {
}

Expand All @@ -36,6 +37,7 @@ PatternInformation PatternGeneratorCEGAR::compute_pattern(
max_pdb_size,
max_time,
use_wildcard_plans,
use_restricted_goal,
log,
rng,
task,
Expand Down Expand Up @@ -64,7 +66,7 @@ class PatternGeneratorCEGARFeature : public plugins::TypedFeature<PatternGenerat
"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);
add_generator_options_to_feature(*this);
utils::add_rng_options(*this);

Expand Down
1 change: 1 addition & 0 deletions 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 Down

0 comments on commit 5e71b61

Please sign in to comment.