Skip to content

Commit

Permalink
style
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonDold committed Feb 16, 2024
1 parent 1845863 commit 8b8247a
Show file tree
Hide file tree
Showing 11 changed files with 98 additions and 102 deletions.
36 changes: 18 additions & 18 deletions src/search/potentials/diverse_potential_heuristics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ using namespace std;

namespace potentials {
DiversePotentialHeuristics::DiversePotentialHeuristics(
int num_samples,
int max_num_heuristics,
double max_potential,
lp::LPSolverType lpsolver,
const shared_ptr<AbstractTask> &transform,
int random_seed,
utils::Verbosity verbosity
)
int num_samples,
int max_num_heuristics,
double max_potential,
lp::LPSolverType lpsolver,
const shared_ptr<AbstractTask> &transform,
int random_seed,
utils::Verbosity verbosity
)
: optimizer(
transform,
lpsolver,
max_potential),
transform,
lpsolver,
max_potential),
max_num_heuristics(max_num_heuristics),
num_samples(num_samples),
rng(utils::get_rng(random_seed)),
Expand Down Expand Up @@ -179,20 +179,20 @@ class DiversePotentialMaxHeuristicFeature : public plugins::TypedFeature<Evaluat

virtual shared_ptr<PotentialMaxHeuristic> create_component(const plugins::Options &opts, const utils::Context &) const override {
return make_shared<PotentialMaxHeuristic>( // TODO issue1082 use make_shared_from_arg_tuples
DiversePotentialHeuristics(
DiversePotentialHeuristics(
opts.get<int>("num_samples"),
opts.get<int>("max_num_heuristics"),
opts.get<double>("max_potential"),
opts.get<lp::LPSolverType>("lpsolver"),
opts.get<shared_ptr<AbstractTask>>("transform"),
opts.get<int>("random_seed"),
opts.get<utils::Verbosity>("verbosity")
).find_functions(),
opts.get<shared_ptr<AbstractTask>>("transform"),
opts.get<bool>("cache_estimates"),
opts.get<string>("description"),
opts.get<utils::Verbosity>("verbosity")
);
).find_functions(),
opts.get<shared_ptr<AbstractTask>>("transform"),
opts.get<bool>("cache_estimates"),
opts.get<string>("description"),
opts.get<utils::Verbosity>("verbosity")
);
}
};

Expand Down
15 changes: 7 additions & 8 deletions src/search/potentials/diverse_potential_heuristics.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,13 @@ class DiversePotentialHeuristics {

public:
DiversePotentialHeuristics(
int num_samples,
int max_num_heuristics,
double max_potential,
lp::LPSolverType lpsolver,
const std::shared_ptr<AbstractTask> &transform,
int random_seed,
utils::Verbosity verbosity
);
int num_samples,
int max_num_heuristics,
double max_potential,
lp::LPSolverType lpsolver,
const std::shared_ptr<AbstractTask> &transform,
int random_seed,
utils::Verbosity verbosity);
~DiversePotentialHeuristics() = default;

// Sample states, then cover them.
Expand Down
12 changes: 6 additions & 6 deletions src/search/potentials/potential_heuristic.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ using namespace std;

namespace potentials {
PotentialHeuristic::PotentialHeuristic(
unique_ptr<PotentialFunction> function,
const shared_ptr<AbstractTask> &transform,
bool cache_estimates,
const string &description,
utils::Verbosity verbosity
)
unique_ptr<PotentialFunction> function,
const shared_ptr<AbstractTask> &transform,
bool cache_estimates,
const string &description,
utils::Verbosity verbosity
)
: Heuristic(transform, cache_estimates, description, verbosity),
function(move(function)) {
}
Expand Down
12 changes: 5 additions & 7 deletions src/search/potentials/potential_heuristic.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@ class PotentialHeuristic : public Heuristic {

public:
explicit PotentialHeuristic(
std::unique_ptr<PotentialFunction> function,
const std::shared_ptr<AbstractTask> &transform,
bool cache_estimates,
const std::string &description,
utils::Verbosity verbosity
);

std::unique_ptr<PotentialFunction> function,
const std::shared_ptr<AbstractTask> &transform,
bool cache_estimates,
const std::string &description,
utils::Verbosity verbosity);
};
}

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

namespace potentials {
PotentialMaxHeuristic::PotentialMaxHeuristic(
vector<unique_ptr<PotentialFunction>> &&functions,
const shared_ptr<AbstractTask> &transform,
bool cache_estimates,
const string &description,
utils::Verbosity verbosity)
vector<unique_ptr<PotentialFunction>> &&functions,
const shared_ptr<AbstractTask> &transform,
bool cache_estimates,
const string &description,
utils::Verbosity verbosity)
: Heuristic(transform, cache_estimates, description, verbosity),
functions(move(functions)) {
}
Expand Down
10 changes: 5 additions & 5 deletions src/search/potentials/potential_max_heuristic.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ class PotentialMaxHeuristic : public Heuristic {

public:
PotentialMaxHeuristic(
std::vector<std::unique_ptr<PotentialFunction>> &&functions,
const std::shared_ptr<AbstractTask> &transform,
bool cache_estimates,
const std::string &description,
utils::Verbosity verbosity);
std::vector<std::unique_ptr<PotentialFunction>> &&functions,
const std::shared_ptr<AbstractTask> &transform,
bool cache_estimates,
const std::string &description,
utils::Verbosity verbosity);
};
}

Expand Down
18 changes: 9 additions & 9 deletions src/search/potentials/potential_optimizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ static int get_undefined_value(VariableProxy var) {
}

PotentialOptimizer::PotentialOptimizer(
const shared_ptr<AbstractTask> &transform,
lp::LPSolverType lpsolver,
double max_potential
)
: task(transform),
task_proxy(*task),
lp_solver(lpsolver),
max_potential(max_potential),
num_lp_vars(0) {
const shared_ptr<AbstractTask> &transform,
lp::LPSolverType lpsolver,
double max_potential
)
: task(transform),
task_proxy(*task),
lp_solver(lpsolver),
max_potential(max_potential),
num_lp_vars(0) {
task_properties::verify_no_axioms(task_proxy);
task_properties::verify_no_conditional_effects(task_proxy);
initialize();
Expand Down
7 changes: 3 additions & 4 deletions src/search/potentials/potential_optimizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,9 @@ class PotentialOptimizer {

public:
PotentialOptimizer(
const std::shared_ptr<AbstractTask> &transform,
lp::LPSolverType lpsolver,
double max_potential
);
const std::shared_ptr<AbstractTask> &transform,
lp::LPSolverType lpsolver,
double max_potential);
~PotentialOptimizer() = default;

std::shared_ptr<AbstractTask> get_task() const;
Expand Down
32 changes: 16 additions & 16 deletions src/search/potentials/sample_based_potential_heuristics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ static void optimize_for_samples(
sets of samples.
*/
static vector<unique_ptr<PotentialFunction>> create_sample_based_potential_functions(
int num_samples,
int num_heuristics,
double max_potential,
lp::LPSolverType lpsolver,
const shared_ptr<AbstractTask> &transform,
int random_seed
) {
int num_samples,
int num_heuristics,
double max_potential,
lp::LPSolverType lpsolver,
const shared_ptr<AbstractTask> &transform,
int random_seed
) {
vector<unique_ptr<PotentialFunction>> functions;
PotentialOptimizer optimizer(transform,
lpsolver,
Expand Down Expand Up @@ -84,19 +84,19 @@ class SampleBasedPotentialMaxHeuristicFeature : public plugins::TypedFeature<Eva

virtual shared_ptr<PotentialMaxHeuristic> create_component(const plugins::Options &opts, const utils::Context &) const override {
return make_shared<PotentialMaxHeuristic>( // TODO issue1082 use make_shared_from_arg_tuples
create_sample_based_potential_functions(
opts.get<int>("num_samples"),
create_sample_based_potential_functions(
opts.get<int>("num_samples"),
opts.get<int>("num_heuristics"),
opts.get<double>("max_potential"),
opts.get<lp::LPSolverType>("lpsolver"),
opts.get<shared_ptr<AbstractTask>>("transform"),
opts.get<int>("random_seed")
),
opts.get<shared_ptr<AbstractTask>>("transform"),
opts.get<bool>("cache_estimates"),
opts.get<string>("description"),
opts.get<utils::Verbosity>("verbosity")
);
opts.get<int>("random_seed")
),
opts.get<shared_ptr<AbstractTask>>("transform"),
opts.get<bool>("cache_estimates"),
opts.get<string>("description"),
opts.get<utils::Verbosity>("verbosity")
);
}
};

Expand Down
40 changes: 20 additions & 20 deletions src/search/potentials/single_potential_heuristics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ enum class OptimizeFor {
};

static unique_ptr<PotentialFunction> create_potential_function(
const shared_ptr<AbstractTask> &transform,
lp::LPSolverType lpsolver,
double max_potential,
OptimizeFor opt_func) {
const shared_ptr<AbstractTask> &transform,
lp::LPSolverType lpsolver,
double max_potential,
OptimizeFor opt_func) {
PotentialOptimizer optimizer(
transform,
lpsolver,
max_potential);
transform,
lpsolver,
max_potential);
const AbstractTask &task = *transform;
TaskProxy task_proxy(task);
switch (opt_func) {
Expand Down Expand Up @@ -50,16 +50,16 @@ class InitialStatePotentialHeuristicFeature : public plugins::TypedFeature<Evalu

virtual shared_ptr<PotentialHeuristic> create_component(const plugins::Options &opts, const utils::Context &) const override {
return make_shared<PotentialHeuristic>(
create_potential_function(
opts.get<shared_ptr<AbstractTask>>("transform"),
opts.get<lp::LPSolverType>("lpsolver"),
opts.get<double>("max_potential"),
OptimizeFor::INITIAL_STATE),
create_potential_function(
opts.get<shared_ptr<AbstractTask>>("transform"),
opts.get<bool>("cache_estimates"),
opts.get<string>("description"),
opts.get<utils::Verbosity>("verbosity")
);
opts.get<lp::LPSolverType>("lpsolver"),
opts.get<double>("max_potential"),
OptimizeFor::INITIAL_STATE),
opts.get<shared_ptr<AbstractTask>>("transform"),
opts.get<bool>("cache_estimates"),
opts.get<string>("description"),
opts.get<utils::Verbosity>("verbosity")
);
}
};

Expand All @@ -77,10 +77,10 @@ class AllStatesPotentialHeuristicFeature : public plugins::TypedFeature<Evaluato

virtual shared_ptr<PotentialHeuristic> create_component(const plugins::Options &opts, const utils::Context &) const override {
return make_shared<PotentialHeuristic>(create_potential_function(
opts.get<shared_ptr<AbstractTask>>("transform"),
opts.get<lp::LPSolverType>("lpsolver"),
opts.get<double>("max_potential"),
OptimizeFor::ALL_STATES),
opts.get<shared_ptr<AbstractTask>>("transform"),
opts.get<lp::LPSolverType>("lpsolver"),
opts.get<double>("max_potential"),
OptimizeFor::ALL_STATES),
opts.get<shared_ptr<AbstractTask>>("transform"),
opts.get<bool>("cache_estimates"),
opts.get<string>("description"),
Expand Down
8 changes: 4 additions & 4 deletions src/search/potentials/util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ void add_admissible_potentials_options_to_feature(plugins::Feature &feature, con

tuple<double, lp::LPSolverType, shared_ptr<AbstractTask>, bool, string, utils::Verbosity> get_admissible_potential_arguments_from_options(const plugins::Options &opts) {
return tuple_cat(
make_tuple(opts.get<double>("max_potential")),
lp::get_lp_solver_arguments_from_options(opts),
get_heuristic_arguments_from_options(opts)
);
make_tuple(opts.get<double>("max_potential")),
lp::get_lp_solver_arguments_from_options(opts),
get_heuristic_arguments_from_options(opts)
);
}
}

0 comments on commit 8b8247a

Please sign in to comment.