Skip to content

Commit 0de6174

Browse files
committed
allow the use of both goal-directed and non-goal-directed R
1 parent a05c7e7 commit 0de6174

File tree

1 file changed

+30
-23
lines changed

1 file changed

+30
-23
lines changed

src/search/drivers/sbfws/iw_run.hxx

+30-23
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ protected:
207207
Config _config;
208208

209209
//! _all_paths[i] contains all paths in the simulation that reach a node that satisfies goal atom 'i'.
210-
std::vector<std::vector<NodePT>> _all_paths;
210+
// std::vector<std::vector<NodePT>> _all_paths;
211211

212212
std::vector<NodePT> _optimal_paths;
213213

@@ -244,7 +244,7 @@ public:
244244
IWRun(const StateModel& model, const FeatureSetT& featureset, const IWRun::Config& config) :
245245
Base(model, OpenListT(), ClosedListT()),
246246
_config(config),
247-
_all_paths(model.num_subgoals()),
247+
// _all_paths(model.num_subgoals()),
248248
_optimal_paths(model.num_subgoals()),
249249
_unreached(),
250250
_in_seed(model.num_subgoals(), false),
@@ -302,39 +302,46 @@ public:
302302
}
303303

304304

305+
std::vector<bool> compute_R(const StateT& seed) {
306+
if (_config._use_goal_directed_info) {
307+
return compute_goal_directed_R(seed);
308+
} else {
309+
return compute_R_IW1(seed);
310+
}
311+
}
312+
305313
std::vector<bool> compute_R_IW1(const StateT& seed) {
314+
LPT_INFO("cout", "IW Simulation - Computing blind R");
315+
_config._max_width = 1;
316+
_config._bound = -1; // No bound
317+
std::vector<NodePT> seed_nodes;
318+
_compute_R(seed, seed_nodes);
319+
320+
LPT_INFO("cout", "IW Simulation - Number of seed nodes: " << seed_nodes.size());
321+
std::vector<bool> rel_blind = _evaluator.reached_atoms();
322+
LPT_INFO("cout", "IW Simulation - Blind |R| = " << std::count(rel_blind.begin(), rel_blind.end(), true));
323+
return rel_blind;
324+
}
325+
326+
std::vector<bool> compute_goal_directed_R(const StateT& seed) {
327+
LPT_INFO("cout", "IW Simulation - Computing goal-directed R");
306328
const AtomIndex& index = Problem::getInstance().get_tuple_index();
307-
// _config._max_width = 1;
329+
_config._max_width = 2;
308330
_config._bound = -1; // No bound
309331
std::vector<NodePT> seed_nodes;
310-
compute_R(seed, seed_nodes);
332+
_compute_R(seed, seed_nodes);
311333

312334

313335
LPT_INFO("cout", "IW Simulation - Number of seed nodes: " << seed_nodes.size());
314336

315-
// COMPUTE BOTH OPTIONS, FOR THE SAKE OF INFORMATIVENESS
316337
std::vector<bool> rel_goal_directed(index.size(), false);
317338
mark_atoms_in_path_to_subgoal(seed_nodes, rel_goal_directed);
318-
319-
std::vector<bool> rel_blind = _evaluator.reached_atoms();
320-
321-
322339
LPT_INFO("cout", "IW Simulation - Goal-directed |R| = " << std::count(rel_goal_directed.begin(), rel_goal_directed.end(), true));
323-
LPT_INFO("cout", "IW Simulation - Blind |R| = " << std::count(rel_blind.begin(), rel_blind.end(), true));
324-
325-
if (_config._use_goal_directed_info) {
326-
LPT_INFO("cout", "IW Simulation - Using goal-directed R");
327-
return rel_goal_directed;
328-
} else {
329-
LPT_INFO("cout", "IW Simulation - Using blind R");
330-
return rel_blind;
331-
}
332-
}
333-
334-
340+
return rel_goal_directed;
341+
}
335342

336343

337-
std::vector<AtomIdx> compute_R(const StateT& seed, std::vector<NodePT>& seed_nodes) {
344+
std::vector<AtomIdx> _compute_R(const StateT& seed, std::vector<NodePT>& seed_nodes) {
338345

339346
_config._complete = false;
340347

@@ -477,7 +484,7 @@ protected:
477484

478485
if (this->_model.goal(state, subgoal_idx)) {
479486
node->satisfies_subgoal = true;
480-
_all_paths[subgoal_idx].push_back(node);
487+
// _all_paths[subgoal_idx].push_back(node);
481488
if (!_optimal_paths[subgoal_idx]) _optimal_paths[subgoal_idx] = node;
482489
it = _unreached.erase(it);
483490
} else {

0 commit comments

Comments
 (0)