-
Notifications
You must be signed in to change notification settings - Fork 147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
issue992 #246
base: main
Are you sure you want to change the base?
issue992 #246
Conversation
a088dc1
to
4982fc3
Compare
4982fc3
to
c93adef
Compare
d0f3880
to
a5ea42f
Compare
a5ea42f
to
c724ad5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left a few comments, nothing big.
The biggest surprise to me was that the landmarkgraph is now treated as an iterable with the begin and end function (which is an indirection to the begin and end function of the nodes filed).
LGTM overall.
And it got a lot more pleasant to read, especially the parts that used single letter variable names :-)
using const_iterator = | ||
std::vector<std::unique_ptr<LandmarkNode>>::const_iterator; | ||
const const_iterator begin() const { | ||
return nodes.cbegin(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On use for cbegin
is to communicate that a functor receiving the iterator does not change it.
With the function name LandmarkGraph::begin()
this is not communicated anymore.
You are not using it this way and
LandmarkGraph::begin()
is more readable than LandmarkGraph::cbegin()
though.
So I am fine with it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understood Remo correctly, naming the iterator cbegin
didn't work with the range-based for loops as intended, but naming it begin
did. Do you think it would make sense to write a comment about this or is it fine as is?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is fine as is.
for (const auto &parent_and_edge : node->parents) { | ||
const LandmarkNode *parent = parent_and_edge.first; | ||
open.reserve(node->parents.size()); | ||
for (const auto &[parent, type] : node->parents) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for (const auto &[parent, type] : node->parents) { | |
for (const auto &[parent, _] : node->parents) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you find the suggested option more readable? I know doing this is common practice in languages like Python because the symbol _
is actually interpreted differently than a variable name. However, in C++ both type
and _
are (as of today) valid variable names and for the compiler it doesn't make a difference which one is used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it communicates "we don't care about this part of the tuple".
I agree that it is a very pythonic suggestion and I am also fine to keep it as is.
const LandmarkNode *parent = parent_and_edge.first; | ||
FactPair ancestor_atom = get_atom(ancestor->get_landmark()); | ||
groups[ancestor_atom.var].push_back(ancestor_atom.value); | ||
for (const auto &[parent, type] : ancestor->parents) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as above
} | ||
unary_operators.reserve(num_unary_ops); | ||
unary_operators.reserve( | ||
compute_number_of_unary_operators(operators, axioms)); | ||
|
||
// Build unary operators for operators and axioms. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment should be removed.
[precondition_fact.value]); | ||
|
||
vector<Proposition *> precondition_propositions = | ||
get_sorted_precondition_propositions(preconditions, effect); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems a bit wasteful to sort the combination of preconditions+effectcondition for each effect.
Instead one could sort the preconditions outside the for loop and then sort the effectconditions for each effect and combine the two like mergesort does.
const FactPair pre_fact(pre.first, pre.second); | ||
if (!lm_graph->contains_simple_landmark(pre_fact)) { | ||
preconditions[disj_class].push_back(pre_fact); | ||
const FactPair atom(pre.first, pre.second); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const FactPair atom(pre.first, pre.second); | |
const FactPair precondition(pre.first, pre.second); |
} | ||
|
||
LandmarkNode &LandmarkGraph::add_landmark(Landmark &&landmark_to_add) { | ||
assert(landmark_to_add.is_conjunctive || all_of( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert(landmark_to_add.is_conjunctive || all_of( | |
assert(landmark_to_add.is_conjunctive || | |
all_of(landmark_to_add.atoms.begin(), landmark_to_add.atoms.end(), | |
 [&](const FactPair &atom) {return !contains_landmark(atom);})); |
LandmarkNode &parent_node = *(parent.first); | ||
parent_node.children.erase(node); | ||
assert(parent_node.children.find(node) == parent_node.children.end()); | ||
for (const auto &[parent, type] : node->parents) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for (const auto &[parent, type] : node->parents) { | |
for (const auto &[parent, _] : node->parents) { |
LandmarkNode &child_node = *(child.first); | ||
child_node.parents.erase(node); | ||
assert(child_node.parents.find(node) == child_node.parents.end()); | ||
for (const auto &[child, type] : node->children) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for (const auto &[child, type] : node->children) { | |
for (const auto &[child, _] : node->children) { |
return n.get() == node; | ||
}); | ||
const auto it = | ||
find_if(nodes.begin(), nodes.end(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the header you introduce cbegin
and cend
.
Should this be used here too?
No description provided.