diff --git a/src/search/merge_and_shrink/merge_tree_factory_linear.cc b/src/search/merge_and_shrink/merge_tree_factory_linear.cc index 5dcc33ad58..81847d4f5a 100644 --- a/src/search/merge_and_shrink/merge_tree_factory_linear.cc +++ b/src/search/merge_and_shrink/merge_tree_factory_linear.cc @@ -29,7 +29,7 @@ MergeTreeFactoryLinear::MergeTreeFactoryLinear(const options::Options &options) unique_ptr MergeTreeFactoryLinear::compute_merge_tree( const TaskProxy &task_proxy) { - variable_order_finder::VariableOrderFinder vof(task_proxy, variable_order_type, *rng); + variable_order_finder::VariableOrderFinder vof(task_proxy, variable_order_type, rng); MergeTreeNode *root = new MergeTreeNode(vof.next()); while (!vof.done()) { MergeTreeNode *right_child = new MergeTreeNode(vof.next()); @@ -72,7 +72,7 @@ unique_ptr MergeTreeFactoryLinear::compute_merge_tree( skipping all indices not in indices_subset, because these have been set to "used" above. */ - variable_order_finder::VariableOrderFinder vof(task_proxy, variable_order_type, *rng); + variable_order_finder::VariableOrderFinder vof(task_proxy, variable_order_type, rng); int next_var = vof.next(); int ts_index = var_to_ts_index[next_var]; diff --git a/src/search/pdbs/pattern_collection_generator_combo.cc b/src/search/pdbs/pattern_collection_generator_combo.cc index 0b6bf7aa59..db33314290 100644 --- a/src/search/pdbs/pattern_collection_generator_combo.cc +++ b/src/search/pdbs/pattern_collection_generator_combo.cc @@ -9,8 +9,6 @@ #include "../task_proxy.h" #include "../utils/logging.h" -#include "../utils/rng.h" -#include "../utils/rng_options.h" #include "../utils/timer.h" #include @@ -21,8 +19,7 @@ using namespace std; namespace pdbs { PatternCollectionGeneratorCombo::PatternCollectionGeneratorCombo(const Options &opts) - : max_states(opts.get("max_states")), - rng(utils::parse_rng_from_options(opts)) { + : max_states(opts.get("max_states")) { } PatternCollectionInformation PatternCollectionGeneratorCombo::generate( @@ -32,7 +29,7 @@ PatternCollectionInformation PatternCollectionGeneratorCombo::generate( TaskProxy task_proxy(*task); shared_ptr patterns = make_shared(); - PatternGeneratorGreedy large_pattern_generator(max_states, rng); + PatternGeneratorGreedy large_pattern_generator(max_states); Pattern large_pattern = large_pattern_generator.generate(task).get_pattern(); set used_vars(large_pattern.begin(), large_pattern.end()); patterns->push_back(move(large_pattern)); @@ -56,7 +53,6 @@ static shared_ptr _parse(OptionParser &parser) { "maximum abstraction size for combo strategy", "1000000", Bounds("1", "infinity")); - utils::add_rng_options(parser); Options opts = parser.parse(); if (parser.dry_run()) diff --git a/src/search/pdbs/pattern_collection_generator_combo.h b/src/search/pdbs/pattern_collection_generator_combo.h index 79122c6d30..f96b74c737 100644 --- a/src/search/pdbs/pattern_collection_generator_combo.h +++ b/src/search/pdbs/pattern_collection_generator_combo.h @@ -3,16 +3,11 @@ #include "pattern_generator.h" -namespace utils { -class RandomNumberGenerator; -} - namespace pdbs { /* Take one large pattern and then single-variable patterns for all goal variables that are not in the large pattern. */ class PatternCollectionGeneratorCombo : public PatternCollectionGenerator { int max_states; - std::shared_ptr rng; public: explicit PatternCollectionGeneratorCombo(const options::Options &opts); virtual ~PatternCollectionGeneratorCombo() = default; diff --git a/src/search/pdbs/pattern_generator_greedy.cc b/src/search/pdbs/pattern_generator_greedy.cc index ef00df232b..0bff7291d9 100644 --- a/src/search/pdbs/pattern_generator_greedy.cc +++ b/src/search/pdbs/pattern_generator_greedy.cc @@ -10,8 +10,6 @@ #include "../task_utils/variable_order_finder.h" #include "../utils/logging.h" #include "../utils/math.h" -#include "../utils/rng.h" -#include "../utils/rng_options.h" #include "../utils/timer.h" #include @@ -20,14 +18,11 @@ using namespace std; namespace pdbs { PatternGeneratorGreedy::PatternGeneratorGreedy(const Options &opts) - : PatternGeneratorGreedy( - opts.get("max_states"), - utils::parse_rng_from_options(opts)) { + : PatternGeneratorGreedy(opts.get("max_states")) { } -PatternGeneratorGreedy::PatternGeneratorGreedy( - int max_states, const shared_ptr &rng) - : max_states(max_states), rng(rng) { +PatternGeneratorGreedy::PatternGeneratorGreedy(int max_states) + : max_states(max_states) { } PatternInformation PatternGeneratorGreedy::generate(const shared_ptr &task) { @@ -36,7 +31,7 @@ PatternInformation PatternGeneratorGreedy::generate(const shared_ptr _parse(OptionParser &parser) { "maximal number of abstract states in the pattern database.", "1000000", Bounds("1", "infinity")); - utils::add_rng_options(parser); Options opts = parser.parse(); if (parser.dry_run()) diff --git a/src/search/pdbs/pattern_generator_greedy.h b/src/search/pdbs/pattern_generator_greedy.h index 59899d4e88..ed2d287a63 100644 --- a/src/search/pdbs/pattern_generator_greedy.h +++ b/src/search/pdbs/pattern_generator_greedy.h @@ -7,18 +7,12 @@ namespace options { class Options; } -namespace utils { -class RandomNumberGenerator; -} - namespace pdbs { class PatternGeneratorGreedy : public PatternGenerator { int max_states; - std::shared_ptr rng; public: explicit PatternGeneratorGreedy(const options::Options &opts); - explicit PatternGeneratorGreedy( - int max_states, const std::shared_ptr &rng); + explicit PatternGeneratorGreedy(int max_states); virtual ~PatternGeneratorGreedy() = default; virtual PatternInformation generate(const std::shared_ptr &task) override; diff --git a/src/search/task_utils/variable_order_finder.cc b/src/search/task_utils/variable_order_finder.cc index e7449db6cb..8214000c5e 100644 --- a/src/search/task_utils/variable_order_finder.cc +++ b/src/search/task_utils/variable_order_finder.cc @@ -17,7 +17,7 @@ using utils::ExitCode; namespace variable_order_finder { VariableOrderFinder::VariableOrderFinder(const TaskProxy &task_proxy, VariableOrderType variable_order_type, - utils::RandomNumberGenerator &rng) + shared_ptr rng) : task_proxy(task_proxy), variable_order_type(variable_order_type) { int var_count = task_proxy.get_variables().size(); @@ -31,7 +31,12 @@ VariableOrderFinder::VariableOrderFinder(const TaskProxy &task_proxy, if (variable_order_type == CG_GOAL_RANDOM || variable_order_type == RANDOM) { - rng.shuffle(remaining_vars); + if (!rng) { + ABORT("No random number generator passed to VariableOrderFinder " + "although the chosen value for VariableOrderType relies on " + "randomization"); + } + rng->shuffle(remaining_vars); } is_causal_predecessor.resize(var_count, false); diff --git a/src/search/task_utils/variable_order_finder.h b/src/search/task_utils/variable_order_finder.h index 48e176e816..9e83615cb5 100644 --- a/src/search/task_utils/variable_order_finder.h +++ b/src/search/task_utils/variable_order_finder.h @@ -37,9 +37,10 @@ class VariableOrderFinder { void select_next(int position, int var_no); public: - VariableOrderFinder(const TaskProxy &task_proxy, - VariableOrderType variable_order_type, - utils::RandomNumberGenerator &rng); + VariableOrderFinder( + const TaskProxy &task_proxy, + VariableOrderType variable_order_type, + std::shared_ptr rng = nullptr); ~VariableOrderFinder() = default; bool done() const; int next();