Skip to content

Commit

Permalink
update cegar generators
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianPommerening committed Feb 9, 2024
1 parent d77141f commit 01da84a
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 12 deletions.
43 changes: 34 additions & 9 deletions src/search/cartesian_abstractions/subtask_generators.cc
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ static Facts filter_and_order_facts(
}


TaskDuplicator::TaskDuplicator(const plugins::Options &opts)
: num_copies(opts.get<int>("copies")) {
TaskDuplicator::TaskDuplicator(int num_copies)
: num_copies(num_copies) {
}

SharedTasks TaskDuplicator::get_subtasks(
Expand All @@ -108,9 +108,9 @@ SharedTasks TaskDuplicator::get_subtasks(
return subtasks;
}

GoalDecomposition::GoalDecomposition(const plugins::Options &opts)
: fact_order(opts.get<FactOrder>("order")),
rng(utils::parse_rng_from_options(opts)) {
GoalDecomposition::GoalDecomposition(FactOrder fact_order, int random_seed)
: fact_order(fact_order),
rng(utils::get_rng(random_seed)) {
}

SharedTasks GoalDecomposition::get_subtasks(
Expand All @@ -128,10 +128,11 @@ SharedTasks GoalDecomposition::get_subtasks(
}


LandmarkDecomposition::LandmarkDecomposition(const plugins::Options &opts)
: fact_order(opts.get<FactOrder>("order")),
combine_facts(opts.get<bool>("combine_facts")),
rng(utils::parse_rng_from_options(opts)) {
LandmarkDecomposition::LandmarkDecomposition(
FactOrder fact_order, bool combine_facts, int random_seed)
: fact_order(fact_order),
combine_facts(combine_facts),
rng(utils::get_rng(random_seed)) {
}

shared_ptr<AbstractTask> LandmarkDecomposition::build_domain_abstracted_task(
Expand Down Expand Up @@ -176,6 +177,11 @@ static void add_fact_order_option(plugins::Feature &feature) {
utils::add_rng_options_to_feature(feature);
}

static tuple<FactOrder, int> get_fact_order_arguments_from_options(const plugins::Options &opts) {
return tuple_cat(make_tuple(opts.get<FactOrder>("order")),
utils::get_rng_arguments_from_options(opts));
}

class TaskDuplicatorFeature : public plugins::TypedFeature<SubtaskGenerator, TaskDuplicator> {
public:
TaskDuplicatorFeature() : TypedFeature("original") {
Expand All @@ -185,6 +191,12 @@ class TaskDuplicatorFeature : public plugins::TypedFeature<SubtaskGenerator, Tas
"1",
plugins::Bounds("1", "infinity"));
}

virtual shared_ptr<TaskDuplicator> create_component(
const plugins::Options &opts, const utils::Context &) const override {
return plugins::make_shared_from_arg_tuples<TaskDuplicator>(
opts.get<int>("copies"));
}
};

static plugins::FeaturePlugin<TaskDuplicatorFeature> _plugin_original;
Expand All @@ -194,6 +206,12 @@ class GoalDecompositionFeature : public plugins::TypedFeature<SubtaskGenerator,
GoalDecompositionFeature() : TypedFeature("goals") {
add_fact_order_option(*this);
}

virtual shared_ptr<GoalDecomposition> create_component(
const plugins::Options &opts, const utils::Context &) const override {
return plugins::make_shared_from_arg_tuples<GoalDecomposition>(
get_fact_order_arguments_from_options(opts));
}
};

static plugins::FeaturePlugin<GoalDecompositionFeature> _plugin_goals;
Expand All @@ -208,6 +226,13 @@ class LandmarkDecompositionFeature : public plugins::TypedFeature<SubtaskGenerat
"combine landmark facts with domain abstraction",
"true");
}

virtual shared_ptr<LandmarkDecomposition> create_component(
const plugins::Options &opts, const utils::Context &) const override {
return plugins::make_shared_from_arg_tuples<LandmarkDecomposition>(
get_fact_order_arguments_from_options(opts),
opts.get<bool>("combine_facts"));
}
};

static plugins::FeaturePlugin<LandmarkDecompositionFeature> _plugin_landmarks;
Expand Down
7 changes: 4 additions & 3 deletions src/search/cartesian_abstractions/subtask_generators.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class TaskDuplicator : public SubtaskGenerator {
int num_copies;

public:
explicit TaskDuplicator(const plugins::Options &opts);
explicit TaskDuplicator(int num_copies);

virtual SharedTasks get_subtasks(
const std::shared_ptr<AbstractTask> &task,
Expand All @@ -67,7 +67,7 @@ class GoalDecomposition : public SubtaskGenerator {
std::shared_ptr<utils::RandomNumberGenerator> rng;

public:
explicit GoalDecomposition(const plugins::Options &opts);
explicit GoalDecomposition(FactOrder fact_order, int random_seed);

virtual SharedTasks get_subtasks(
const std::shared_ptr<AbstractTask> &task,
Expand All @@ -92,7 +92,8 @@ class LandmarkDecomposition : public SubtaskGenerator {
const FactPair &fact) const;

public:
explicit LandmarkDecomposition(const plugins::Options &opts);
explicit LandmarkDecomposition(FactOrder fact_order, bool combine_facts,
int random_seed);

virtual SharedTasks get_subtasks(
const std::shared_ptr<AbstractTask> &task,
Expand Down

0 comments on commit 01da84a

Please sign in to comment.