9 #include "knowrob/queries/AnswerYes.h"
10 #include "knowrob/knowrob.h"
11 #include "knowrob/Logger.h"
12 #include "knowrob/integration/python/utils.h"
18 substitution_(std::make_shared<
Bindings>()) {
24 substitution_(std::move(substitution)) {
30 positiveGroundings_(other.positiveGroundings_),
31 negativeGroundings_(other.negativeGroundings_),
32 substitution_(std::make_shared<
Bindings>(*other.substitution_)) {
74 auto mergedBindings = std::make_shared<Bindings>(*
substitution_);
75 if (ignoreInconsistencies) {
103 std::stringstream os;
112 os <<
", because:\n";
114 os <<
'\t' << *x.graphSelector() <<
' ' << *x.predicate();
116 os <<
' ' <<
'[' << *x.reasonerTerm() <<
"]";
121 os <<
'\t' << *x.graphSelector() <<
'~' << *x.predicate();
123 os <<
' ' <<
'[' << *x.reasonerTerm() <<
"]";
134 std::stringstream os;
135 os << std::setprecision(4);
136 os <<
"the query is ";
138 if (
frame_->confidence.has_value()) {
139 os <<
"true with a confidence of " << std::setprecision(4) <<
frame_->confidence.value();
141 os <<
"probably true";
147 os <<
" at some time ";
149 if (
frame_->begin.has_value() &&
frame_->end.has_value()) {
150 os <<
" during the time points " <<
frame_->begin.value() <<
" and " <<
frame_->end.value();
151 }
else if (
frame_->begin.has_value()) {
152 os <<
" since " <<
frame_->begin.value();
153 }
else if (
frame_->end.has_value()) {
154 os <<
" until " <<
frame_->end.value();
162 static const auto instance = std::make_shared<const AnswerYes>();
167 if (!a || a->isGenericYes()) {
169 }
else if (!b || b->isGenericYes()) {
173 if (a->isRicherThan(*b)) {
180 auto mergedAnswer = std::make_shared<AnswerYes>(*larger);
181 if (mergedAnswer->mergeWith(*smaller, ignoreInconsistencies)) {
196 class_<AnswerYes, std::shared_ptr<AnswerYes>, bases<Answer>>
197 (
"AnswerYes", init<>())
198 .def(init<BindingsPtr>())
204 return self.addGrounding(
predicate, isNegated);
207 return self.addGrounding(
predicate, isNegated, frame);
216 register_ptr_to_python<std::shared_ptr<const AnswerYes> >();
217 implicitly_convertible<std::shared_ptr<AnswerYes>, std::shared_ptr<const AnswerYes> >();
void setIsPositive(bool val)
std::shared_ptr< GraphSelector > frame_
std::vector< FramedPredicate > positiveGroundings_
auto & positiveGroundings() const
bool mergeWith(const AnswerYes &other, bool ignoreInconsistencies=false)
BindingsPtr substitution_
bool isRicherThan(const AnswerYes &other) const
auto & negativeGroundings() const
std::vector< FramedPredicate > negativeGroundings_
bool isGenericYes() const
bool addGrounding(const std::shared_ptr< Predicate > &predicate, bool isNegated=false, const GraphSelectorPtr &frame=DefaultGraphSelector())
auto & substitution() const
bool hasGrounding(const Variable &var) const
std::string humanReadableFormOfYes() const
std::string stringFormOfYes() const
void createType< AnswerYes >()
std::shared_ptr< const Bindings > BindingsPtr
const std::shared_ptr< const AnswerYes > & GenericYes()
std::shared_ptr< Predicate > PredicatePtr
std::shared_ptr< const GraphSelector > GraphSelectorPtr
AnswerPtr mergePositiveAnswers(const AnswerYesPtr &a, const AnswerYesPtr &b, bool ignoreInconsistencies)
std::shared_ptr< const Answer > AnswerPtr
std::shared_ptr< const AnswerYes > AnswerYesPtr