diff --git a/src/search/evaluator.cc b/src/search/evaluator.cc index e06dad1835..8532a44152 100644 --- a/src/search/evaluator.cc +++ b/src/search/evaluator.cc @@ -103,9 +103,9 @@ void add_evaluator_options_to_feature(plugins::Feature &feature) { tuple get_evaluator_arguments_from_options( const plugins::Options &opts) { return tuple_cat( - make_tuple(opts.get("description")), - utils::get_log_arguments_from_options(opts) - ); + make_tuple(opts.get("description")), + utils::get_log_arguments_from_options(opts) + ); } static class EvaluatorCategoryPlugin : public plugins::TypedCategoryPlugin { diff --git a/src/search/lp/lp_solver.cc b/src/search/lp/lp_solver.cc index eab0a7ca82..80e63b4b82 100644 --- a/src/search/lp/lp_solver.cc +++ b/src/search/lp/lp_solver.cc @@ -27,7 +27,6 @@ void add_lp_solver_option_to_feature(plugins::Feature &feature) { tuple get_lp_solver_arguments_from_options( const plugins::Options &opts) { return make_tuple(opts.get("lpsolver")); - } LPConstraint::LPConstraint(double lower_bound, double upper_bound) diff --git a/src/search/merge_and_shrink/merge_and_shrink_algorithm.cc b/src/search/merge_and_shrink/merge_and_shrink_algorithm.cc index c6f4f39db7..2663f54a5b 100644 --- a/src/search/merge_and_shrink/merge_and_shrink_algorithm.cc +++ b/src/search/merge_and_shrink/merge_and_shrink_algorithm.cc @@ -463,18 +463,17 @@ void add_merge_and_shrink_algorithm_options_to_feature(plugins::Feature &feature Bounds("0.0", "infinity")); } -tuple,shared_ptr < ShrinkStrategy >,shared_ptr < LabelReduction >,bool,bool,int,int,int,double> get_merge_and_shrink_algorithm_arguments_from_options(const plugins::Options &opts) { - +tuple, shared_ptr < ShrinkStrategy >, shared_ptr < LabelReduction >, bool, bool, int, int, int, double> get_merge_and_shrink_algorithm_arguments_from_options(const plugins::Options &opts) { return tuple_cat( - make_tuple( - opts.get < shared_ptr < MergeStrategyFactory >> ("merge_strategy"), - opts.get < shared_ptr < ShrinkStrategy >> ("shrink_strategy"), - opts.get < shared_ptr < LabelReduction >> ("label_reduction", nullptr), - opts.get("prune_unreachable_states"), - opts.get("prune_irrelevant_states")), - get_transition_system_size_limit_arguments_from_options(opts), - make_tuple(opts.get("main_loop_max_time")) - ); + make_tuple( + opts.get < shared_ptr < MergeStrategyFactory >> ("merge_strategy"), + opts.get < shared_ptr < ShrinkStrategy >> ("shrink_strategy"), + opts.get < shared_ptr < LabelReduction >> ("label_reduction", nullptr), + opts.get("prune_unreachable_states"), + opts.get("prune_irrelevant_states")), + get_transition_system_size_limit_arguments_from_options(opts), + make_tuple(opts.get("main_loop_max_time")) + ); } void add_transition_system_size_limit_options_to_feature(plugins::Feature &feature) { @@ -498,12 +497,12 @@ void add_transition_system_size_limit_options_to_feature(plugins::Feature &featu Bounds("-1", "infinity")); } -tuple get_transition_system_size_limit_arguments_from_options(const plugins::Options &opts){ +tuple get_transition_system_size_limit_arguments_from_options(const plugins::Options &opts) { return make_tuple( - opts.get("max_states"), - opts.get("max_states_before_merge"), - opts.get("threshold_before_merge") - ); + opts.get("max_states"), + opts.get("max_states_before_merge"), + opts.get("threshold_before_merge") + ); } void handle_shrink_limit_options_defaults(plugins::Options &opts, const utils::Context &context) { diff --git a/src/search/merge_and_shrink/merge_and_shrink_algorithm.h b/src/search/merge_and_shrink/merge_and_shrink_algorithm.h index f49a3fd9dc..ac1040242c 100644 --- a/src/search/merge_and_shrink/merge_and_shrink_algorithm.h +++ b/src/search/merge_and_shrink/merge_and_shrink_algorithm.h @@ -72,9 +72,9 @@ class MergeAndShrinkAlgorithm { }; extern void add_merge_and_shrink_algorithm_options_to_feature(plugins::Feature &feature); -std::tuple,std::shared_ptr < ShrinkStrategy >,std::shared_ptr < LabelReduction >,bool,bool,int,int,int,double> get_merge_and_shrink_algorithm_arguments_from_options(const plugins::Options &opts); +std::tuple, std::shared_ptr < ShrinkStrategy >, std::shared_ptr < LabelReduction >, bool, bool, int, int, int, double> get_merge_and_shrink_algorithm_arguments_from_options(const plugins::Options &opts); extern void add_transition_system_size_limit_options_to_feature(plugins::Feature &feature); -std::tuple get_transition_system_size_limit_arguments_from_options(const plugins::Options &opts); +std::tuple get_transition_system_size_limit_arguments_from_options(const plugins::Options &opts); extern void handle_shrink_limit_options_defaults(plugins::Options &opts, const utils::Context &context); } diff --git a/src/search/merge_and_shrink/merge_tree_factory.cc b/src/search/merge_and_shrink/merge_tree_factory.cc index 1b5c797ae9..552ec2712f 100644 --- a/src/search/merge_and_shrink/merge_tree_factory.cc +++ b/src/search/merge_and_shrink/merge_tree_factory.cc @@ -60,9 +60,9 @@ void add_merge_tree_options_to_feature(plugins::Feature &feature) { tuple get_merge_tree_arguments_from_options(const plugins::Options &opts) { return tuple_cat( - utils::get_rng_arguments_from_options(opts), - make_tuple(opts.get("update_option")) - ); + utils::get_rng_arguments_from_options(opts), + make_tuple(opts.get("update_option")) + ); } static class MergeTreeFactoryCategoryPlugin : public plugins::TypedCategoryPlugin { diff --git a/src/search/operator_counting/operator_counting_heuristic.cc b/src/search/operator_counting/operator_counting_heuristic.cc index d5feb3329e..b8ff3dc55a 100644 --- a/src/search/operator_counting/operator_counting_heuristic.cc +++ b/src/search/operator_counting/operator_counting_heuristic.cc @@ -11,13 +11,13 @@ using namespace std; namespace operator_counting { OperatorCountingHeuristic::OperatorCountingHeuristic( - const vector> &constraint_generators, - bool use_integer_operator_counts, - lp::LPSolverType lp_solver_type, - const shared_ptr &transform, - bool cache_estimates, - const string &description, - utils::Verbosity verbosity) + const vector> &constraint_generators, + bool use_integer_operator_counts, + lp::LPSolverType lp_solver_type, + const shared_ptr &transform, + bool cache_estimates, + const string &description, + utils::Verbosity verbosity) : Heuristic(transform, cache_estimates, description, verbosity), constraint_generators(constraint_generators), use_integer_operator_counts(use_integer_operator_counts), @@ -123,7 +123,7 @@ class OperatorCountingHeuristicFeature : public plugins::TypedFeature("use_integer_operator_counts"), lp::get_lp_solver_arguments_from_options(options), Heuristic::get_heuristic_arguments_from_options(options) - ); + ); } }; diff --git a/src/search/pdbs/cegar.cc b/src/search/pdbs/cegar.cc index 1ba27534fc..263bd761f0 100644 --- a/src/search/pdbs/cegar.cc +++ b/src/search/pdbs/cegar.cc @@ -786,7 +786,7 @@ void add_cegar_wildcard_option_to_feature(plugins::Feature &feature) { "plans which are sequences of single operators", "true"); } -tuple get_cegar_wildcard_arguments_from_options(const plugins::Options &opts){ +tuple get_cegar_wildcard_arguments_from_options(const plugins::Options &opts) { return make_tuple(opts.get("use_wildcard_plans")); } } diff --git a/src/search/pdbs/cegar.h b/src/search/pdbs/cegar.h index 5f7a82917b..2469c3d592 100644 --- a/src/search/pdbs/cegar.h +++ b/src/search/pdbs/cegar.h @@ -65,7 +65,6 @@ extern PatternInformation generate_pattern_with_cegar( extern void add_cegar_implementation_notes_to_feature(plugins::Feature &feature); extern void add_cegar_wildcard_option_to_feature(plugins::Feature &feature); std::tuple get_cegar_wildcard_arguments_from_options(const plugins::Options &opts); - } #endif diff --git a/src/search/pdbs/pattern_collection_generator_hillclimbing.cc b/src/search/pdbs/pattern_collection_generator_hillclimbing.cc index ec25b19cb6..b02e0edd40 100644 --- a/src/search/pdbs/pattern_collection_generator_hillclimbing.cc +++ b/src/search/pdbs/pattern_collection_generator_hillclimbing.cc @@ -563,13 +563,13 @@ void add_hillclimbing_options_to_feature(plugins::Feature &feature) { tuple get_hillclimbing_arguments_from_options(const plugins::Options &opts) { return tuple_cat( - make_tuple( - opts.get("pdb_max_size"), - opts.get("collection_max_size"), - opts.get("num_samples"), - opts.get("min_improvement"), - opts.get("max_time")), - utils::get_rng_arguments_from_options(opts)); + make_tuple( + opts.get("pdb_max_size"), + opts.get("collection_max_size"), + opts.get("num_samples"), + opts.get("min_improvement"), + opts.get("max_time")), + utils::get_rng_arguments_from_options(opts)); } static void check_hillclimbing_options( diff --git a/src/search/pdbs/pattern_collection_generator_hillclimbing.h b/src/search/pdbs/pattern_collection_generator_hillclimbing.h index f78eb9f788..a2b9d4ed37 100644 --- a/src/search/pdbs/pattern_collection_generator_hillclimbing.h +++ b/src/search/pdbs/pattern_collection_generator_hillclimbing.h @@ -144,7 +144,6 @@ class PatternCollectionGeneratorHillclimbing : public PatternCollectionGenerator extern void add_hillclimbing_options_to_feature(plugins::Feature &feature); std::tuple get_hillclimbing_arguments_from_options(const plugins::Options &opts); - } #endif diff --git a/src/search/pdbs/pattern_collection_generator_multiple.cc b/src/search/pdbs/pattern_collection_generator_multiple.cc index f4cd6be238..0442dcc63f 100644 --- a/src/search/pdbs/pattern_collection_generator_multiple.cc +++ b/src/search/pdbs/pattern_collection_generator_multiple.cc @@ -335,16 +335,16 @@ void add_multiple_options_to_feature(plugins::Feature &feature) { } tuple - get_multiple_arguments_from_options(const plugins::Options &opts) { +get_multiple_arguments_from_options(const plugins::Options &opts) { return tuple_cat(make_tuple( - opts.get("max_pdb_size"), - opts.get("max_collection_size"), - opts.get("pattern_generation_max_time"), - opts.get("total_max_time"), - opts.get("stagnation_limit"), - opts.get("blacklist_trigger_percentage"), - opts.get("enable_blacklist_on_stagnation") - ), + opts.get("max_pdb_size"), + opts.get("max_collection_size"), + opts.get("pattern_generation_max_time"), + opts.get("total_max_time"), + opts.get("stagnation_limit"), + opts.get("blacklist_trigger_percentage"), + opts.get("enable_blacklist_on_stagnation") + ), utils::get_rng_arguments_from_options(opts), get_generator_arguments_from_options(opts)); } diff --git a/src/search/pdbs/pattern_collection_generator_multiple.h b/src/search/pdbs/pattern_collection_generator_multiple.h index dd4a0be848..f69cf6c05d 100644 --- a/src/search/pdbs/pattern_collection_generator_multiple.h +++ b/src/search/pdbs/pattern_collection_generator_multiple.h @@ -90,7 +90,7 @@ extern void add_multiple_options_to_feature( plugins::Feature &feature); extern std::tuple - get_multiple_arguments_from_options(const plugins::Options &opts); +get_multiple_arguments_from_options(const plugins::Options &opts); } #endif diff --git a/src/search/pdbs/pattern_collection_generator_multiple_random.cc b/src/search/pdbs/pattern_collection_generator_multiple_random.cc index 6f45972075..d87fc3ff0b 100644 --- a/src/search/pdbs/pattern_collection_generator_multiple_random.cc +++ b/src/search/pdbs/pattern_collection_generator_multiple_random.cc @@ -92,8 +92,8 @@ class PatternCollectionGeneratorMultipleRandomFeature : public plugins::TypedFea virtual shared_ptr create_component( const plugins::Options &opts, const utils::Context &) const override { return plugins::make_shared_from_arg_tuples( - get_random_pattern_bidirectional_arguments_from_options(opts), - get_multiple_arguments_from_options(opts) + get_random_pattern_bidirectional_arguments_from_options(opts), + get_multiple_arguments_from_options(opts) ); } }; diff --git a/src/search/plugins/plugin.h b/src/search/plugins/plugin.h index deaf29f304..beda728a0e 100644 --- a/src/search/plugins/plugin.h +++ b/src/search/plugins/plugin.h @@ -122,13 +122,13 @@ class TypedFeature : public FeatureAuto { constructor. The resulting arguments will be used as arguments to make_shared. */ // TODO issue1082 where should this live? optimize with std::forward? -template -std::shared_ptr make_shared_from_arg_tuples(Arguments...arguments) { +template +std::shared_ptr make_shared_from_arg_tuples(Arguments... arguments) { return std::apply( - [](auto...flattened_args) { - return std::make_shared(flattened_args...); + [](auto... flattened_args) { + return std::make_shared(flattened_args ...); }, - utils::flatten_tuple(std::tuple(arguments...))); + utils::flatten_tuple(std::tuple(arguments ...))); } class Plugin { diff --git a/src/search/utils/rng_options.cc b/src/search/utils/rng_options.cc index 5ed85ab875..db995d7afe 100644 --- a/src/search/utils/rng_options.cc +++ b/src/search/utils/rng_options.cc @@ -19,8 +19,8 @@ void add_rng_options_to_feature(plugins::Feature &feature) { tuple get_rng_arguments_from_options(const plugins::Options &opts) { return make_tuple( - opts.get("random_seed") - ); + opts.get("random_seed") + ); } shared_ptr get_rng(int seed) { diff --git a/src/search/utils/tuples.h b/src/search/utils/tuples.h index a4271bcf56..c616e01826 100644 --- a/src/search/utils/tuples.h +++ b/src/search/utils/tuples.h @@ -12,63 +12,69 @@ namespace utils { template struct wrapper { - T* ptr; - wrapper(T& t) : ptr(std::addressof(t)) {} + T *ptr; + wrapper(T &t) : ptr(std::addressof(t)) {} using unwrapped_type = - std::conditional_t{}, T&, T&&>, - std::conditional_t{}, T&&, T&>>; + std::conditional_t < can_move, + std::conditional_t < std::is_lvalue_reference {}, T &, T && >, + std::conditional_t < std::is_rvalue_reference {}, T &&, T & >>; using tuple_element_type = U; - unwrapped_type unwrap() const{ + unwrapped_type unwrap() const { return std::forward(*ptr); } }; -template -auto unwrap_tuple(const std::tuple& t, std::index_sequence) { +template +auto unwrap_tuple(const std::tuple &t, std::index_sequence) { return std::tuple(std::get(t).unwrap()...); } -template -auto unwrap_tuple(const std::tuple& t) { +template +auto unwrap_tuple(const std::tuple &t) { return unwrap_tuple(t, std::index_sequence_for()); } template -auto wrap_and_flatten(T& t, char){ +auto wrap_and_flatten(T &t, char) { return std::make_tuple(wrapper(t)); } -template struct is_tuple : std::false_type {}; -template struct is_tuple> : std::true_type {}; -template struct is_tuple : is_tuple {}; -template struct is_tuple : is_tuple {}; +template +struct is_tuple : std::false_type {}; +template +struct is_tuple> : std::true_type {}; +template +struct is_tuple : is_tuple {}; +template +struct is_tuple : is_tuple {}; template>{}>> -auto wrap_and_flatten(Tuple& t, int); + class = std::enable_if_t < is_tuple>{} > > +auto wrap_and_flatten(Tuple &t, int); template -auto wrap_and_flatten(Tuple& t, std::index_sequence) { +auto wrap_and_flatten(Tuple &t, std::index_sequence) { return std::tuple_cat(wrap_and_flatten>>(std::get(t), 0)...); } template -auto wrap_and_flatten(Tuple& t, int) { - using seq_type = std::make_index_sequence{}>; +auto wrap_and_flatten(Tuple &t, int) { + using seq_type = std::make_index_sequence < std::tuple_size {} + >; return wrap_and_flatten(t, seq_type()); } template -auto wrap_and_flatten_tuple(Tuple&& t){ +auto wrap_and_flatten_tuple(Tuple &&t) { constexpr bool can_move = !std::is_lvalue_reference{}; - using seq_type = std::make_index_sequence>{}>; + using seq_type = std::make_index_sequence < std::tuple_size> {} + >; return wrap_and_flatten(t, seq_type()); } -template -auto flatten_tuple(T&& t) { +template +auto flatten_tuple(T &&t) { return unwrap_tuple(wrap_and_flatten_tuple(std::forward(t))); } }