HybridDiscreteFactor docs and minor refactor
parent
573448f126
commit
6d26818e79
|
@ -24,25 +24,28 @@
|
||||||
|
|
||||||
namespace gtsam {
|
namespace gtsam {
|
||||||
|
|
||||||
|
/* ************************************************************************ */
|
||||||
// TODO(fan): THIS IS VERY VERY DIRTY! We need to get DiscreteFactor right!
|
// TODO(fan): THIS IS VERY VERY DIRTY! We need to get DiscreteFactor right!
|
||||||
HybridDiscreteFactor::HybridDiscreteFactor(DiscreteFactor::shared_ptr other)
|
HybridDiscreteFactor::HybridDiscreteFactor(DiscreteFactor::shared_ptr other)
|
||||||
: Base(boost::dynamic_pointer_cast<DecisionTreeFactor>(other)
|
: Base(boost::dynamic_pointer_cast<DecisionTreeFactor>(other)
|
||||||
->discreteKeys()) {
|
->discreteKeys()),
|
||||||
inner = other;
|
inner_(other) {}
|
||||||
}
|
|
||||||
|
|
||||||
|
/* ************************************************************************ */
|
||||||
HybridDiscreteFactor::HybridDiscreteFactor(DecisionTreeFactor &&dtf)
|
HybridDiscreteFactor::HybridDiscreteFactor(DecisionTreeFactor &&dtf)
|
||||||
: Base(dtf.discreteKeys()),
|
: Base(dtf.discreteKeys()),
|
||||||
inner(boost::make_shared<DecisionTreeFactor>(std::move(dtf))) {}
|
inner_(boost::make_shared<DecisionTreeFactor>(std::move(dtf))) {}
|
||||||
|
|
||||||
|
/* ************************************************************************ */
|
||||||
bool HybridDiscreteFactor::equals(const HybridFactor &lf, double tol) const {
|
bool HybridDiscreteFactor::equals(const HybridFactor &lf, double tol) const {
|
||||||
return false;
|
return Base::equals(lf, tol);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ************************************************************************ */
|
||||||
void HybridDiscreteFactor::print(const std::string &s,
|
void HybridDiscreteFactor::print(const std::string &s,
|
||||||
const KeyFormatter &formatter) const {
|
const KeyFormatter &formatter) const {
|
||||||
HybridFactor::print(s, formatter);
|
HybridFactor::print(s, formatter);
|
||||||
inner->print("inner: ", formatter);
|
inner_->print("inner: ", formatter);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace gtsam
|
} // namespace gtsam
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
* @file HybridDiscreteFactor.h
|
* @file HybridDiscreteFactor.h
|
||||||
* @date Mar 11, 2022
|
* @date Mar 11, 2022
|
||||||
* @author Fan Jiang
|
* @author Fan Jiang
|
||||||
|
* @author Varun Agrawal
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
@ -29,12 +30,16 @@ namespace gtsam {
|
||||||
* inheritance.
|
* inheritance.
|
||||||
*/
|
*/
|
||||||
class HybridDiscreteFactor : public HybridFactor {
|
class HybridDiscreteFactor : public HybridFactor {
|
||||||
|
private:
|
||||||
|
DiscreteFactor::shared_ptr inner_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
using Base = HybridFactor;
|
using Base = HybridFactor;
|
||||||
using This = HybridDiscreteFactor;
|
using This = HybridDiscreteFactor;
|
||||||
using shared_ptr = boost::shared_ptr<This>;
|
using shared_ptr = boost::shared_ptr<This>;
|
||||||
|
|
||||||
DiscreteFactor::shared_ptr inner;
|
/// @name Constructors
|
||||||
|
/// @{
|
||||||
|
|
||||||
// Implicit conversion from a shared ptr of DF
|
// Implicit conversion from a shared ptr of DF
|
||||||
HybridDiscreteFactor(DiscreteFactor::shared_ptr other);
|
HybridDiscreteFactor(DiscreteFactor::shared_ptr other);
|
||||||
|
@ -42,11 +47,18 @@ class HybridDiscreteFactor : public HybridFactor {
|
||||||
// Forwarding constructor from concrete DecisionTreeFactor
|
// Forwarding constructor from concrete DecisionTreeFactor
|
||||||
HybridDiscreteFactor(DecisionTreeFactor &&dtf);
|
HybridDiscreteFactor(DecisionTreeFactor &&dtf);
|
||||||
|
|
||||||
public:
|
/// @}
|
||||||
|
/// @name Testable
|
||||||
|
/// @{
|
||||||
virtual bool equals(const HybridFactor &lf, double tol) const override;
|
virtual bool equals(const HybridFactor &lf, double tol) const override;
|
||||||
|
|
||||||
void print(
|
void print(
|
||||||
const std::string &s = "HybridFactor\n",
|
const std::string &s = "HybridFactor\n",
|
||||||
const KeyFormatter &formatter = DefaultKeyFormatter) const override;
|
const KeyFormatter &formatter = DefaultKeyFormatter) const override;
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
/// Return pointer to the internal discrete factor
|
||||||
|
DiscreteFactor::shared_ptr inner() const { return inner_; }
|
||||||
};
|
};
|
||||||
} // namespace gtsam
|
} // namespace gtsam
|
||||||
|
|
Loading…
Reference in New Issue