6 #include <knowrob/queries/Answer.h>
7 #include "knowrob/Logger.h"
8 #include "knowrob/knowrob.h"
9 #include "knowrob/queries/AnswerYes.h"
10 #include "knowrob/queries/AnswerNo.h"
11 #include "knowrob/queries/AnswerDontKnow.h"
12 #include "knowrob/integration/python/utils.h"
13 #include "knowrob/queries/EndOfEvaluation.h"
18 if (
frame !=
nullptr) {
21 throw std::invalid_argument(
"frame must not be null");
28 frame_->confidence = std::nullopt;
36 if (
frame_->confidence.has_value()) {
37 if (
frame_->confidence.value() < 1.0)
return true;
52 if (confidence.has_value()) {
53 frame_->confidence = confidence;
85 auto &bindings = ((
AnswerYes *)
this)->substitution();
93 return ((
AnswerNo *)
this)->stringFormOfNo();
95 return ((
AnswerYes *)
this)->stringFormOfYes();
103 return ((
AnswerNo *)
this)->humanReadableFormOfNo();
105 return ((
AnswerYes *)
this)->humanReadableFormOfYes();
114 if (a->isNegative()) {
115 if (b->isNegative()) {
117 auto a_negative = std::static_pointer_cast<const AnswerNo>(a);
118 auto b_negative = std::static_pointer_cast<const AnswerNo>(b);
124 }
else if (b->isNegative()) {
127 }
else if (a->isPositive()) {
128 if (b->isPositive()) {
130 auto a_positive = std::static_pointer_cast<const AnswerYes>(a);
131 auto b_positive = std::static_pointer_cast<const AnswerYes>(b);
145 if (!v1)
return false;
147 }
else if (!v1 || v0 == v1) {
149 }
else if (v0->isCertain() != v1->isCertain()) {
150 return v0->isCertain() < v1->isCertain();
151 }
else if (v0->isPositive() != v1->isPositive()) {
152 return v0->isPositive() < v1->isPositive();
153 }
else if (v0->isNegative() != v1->isNegative()) {
154 return v0->isNegative() > v1->isNegative();
156 return v0->hashOfAnswer() < v1->hashOfAnswer();
165 class_<Answer, std::shared_ptr<Answer>, boost::noncopyable, bases<Token>>
176 .def(
"frame", &
Answer::frame, return_value_policy<copy_const_reference>())
179 register_ptr_to_python<std::shared_ptr<const Answer> >();
180 implicitly_convertible<std::shared_ptr<Answer>, std::shared_ptr<const Answer> >();
size_t hashOfAnswer() const
std::string stringFormOfAnswer() const
bool isOccasionallyTrue() const
std::string humanReadableForm() const
auto & reasonerTerm() const
void setIsUncertain(bool val, std::optional< double > confidence)
void applyFrame(const GraphSelector &frame)
void setIsOccasionallyTrue(bool val)
void setFrame(const std::shared_ptr< GraphSelector > &frame)
std::shared_ptr< GraphSelector > frame_
TokenType tokenType() const
void createType< AnswerNo >()
void createType< AnswerYes >()
void createType< Answer >()
void createType< AnswerDontKnow >()
AnswerPtr mergeAnswers(const AnswerPtr &a, const AnswerPtr &b, bool ignoreInconsistencies)
void hashCombine(std::size_t &seed, const std::size_t &v)
AnswerPtr mergePositiveAnswers(const AnswerYesPtr &a, const AnswerYesPtr &b, bool ignoreInconsistencies)
AnswerPtr mergeNegativeAnswers(const AnswerNoPtr &a, const AnswerNoPtr &b)
std::shared_ptr< const Answer > AnswerPtr
bool operator()(const AnswerPtr &v0, const AnswerPtr &v1) const