Skip to content

Commit

Permalink
Update landmark status correctly.
Browse files Browse the repository at this point in the history
  • Loading branch information
ClemensBuechner committed May 11, 2023
1 parent 20320bb commit 840dff1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 36 deletions.
46 changes: 15 additions & 31 deletions src/search/landmarks/landmark_status_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -198,43 +198,27 @@ void LandmarkStatusManager::progress_reasonable_ordering(
}

void LandmarkStatusManager::update_lm_status(const State &ancestor_state) {
/*
TODO: We could get rid of this function by accessing this information from
outside directly, i.e., checking **for a given state** whether the
landmark is past or future or both **in that state** (instead of calling
*get_landmark_status*). This should be possible but I didn't want to do
too many changes at once before we start experimenting.
*/
const BitsetView past = get_past_landmarks(ancestor_state);
const BitsetView fut = get_future_landmarks(ancestor_state);

const int num_landmarks = lm_graph.get_num_landmarks();
/* This first loop is necessary as setup for the needed-again
check in the second loop. */
for (int id = 0; id < num_landmarks; ++id) {
lm_status[id] = past.test(id) ? PAST : FUTURE;
}
for (int id = 0; id < num_landmarks; ++id) {
if (lm_status[id] == PAST
&& landmark_needed_again(id, ancestor_state)) {
if (!past.test(id)) {
assert(fut.test(id));
lm_status[id] = FUTURE;
} else if (!fut.test(id)) {
assert(past.test(id));
lm_status[id] = PAST;
} else {
lm_status[id] = PAST_AND_FUTURE;
}
}
}

bool LandmarkStatusManager::landmark_needed_again(
int id, const State &state) {
LandmarkNode *node = lm_graph.get_node(id);
const Landmark &landmark = node->get_landmark();
if (landmark.is_true_in_state(state)) {
return false;
} else if (landmark.is_true_in_goal) {
return true;
} else {
/*
For all A ->_gn B, if B is not past and A currently not
true, since A is a necessary precondition for actions
achieving B for the first time, A must become true again.
*/
for (const auto &child : node->children) {
if (child.second >= EdgeType::GREEDY_NECESSARY
&& lm_status[child.first->get_id()] == FUTURE) {
return true;
}
}
return false;
}
}
}
7 changes: 2 additions & 5 deletions src/search/landmarks/landmark_status_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,8 @@ class LandmarkStatusManager {
PerStateBitset future_landmarks;
std::vector<LandmarkStatus> lm_status;

bool landmark_needed_again(int id, const State &state);

void progress_initial_state(const State &initial_state,
utils::LogProxy &log);

void progress_initial_state(
const State &initial_state, utils::LogProxy &log);
void progress_basic(
const BitsetView &parent_past, const BitsetView &parent_fut,
const State &parent_ancestor_state, BitsetView &past, BitsetView &fut,
Expand Down

0 comments on commit 840dff1

Please sign in to comment.