Go to the documentation of this file.
34 continuousFrontals.
size() + discreteFrontals.
size()) {}
38 const std::shared_ptr<GaussianConditional> &continuousConditional)
40 continuousConditional->nrFrontals()) {
41 inner_ = continuousConditional;
46 const std::shared_ptr<DiscreteConditional> &discreteConditional)
48 discreteConditional->nrFrontals()) {
49 inner_ = discreteConditional;
54 const std::shared_ptr<HybridGaussianConditional> &hybridGaussianCond)
55 :
BaseFactor(hybridGaussianCond->continuousKeys(),
56 hybridGaussianCond->discreteKeys()),
58 inner_ = hybridGaussianCond;
71 if (
isHybrid()) std::cout <<
"Hybrid ";
76 const size_t N =
keys().size();
89 std::cout <<
"(" <<
formatter(dk.first) <<
", " << dk.second <<
")";
99 if (
e ==
nullptr)
return false;
101 auto other =
e->asHybrid();
104 auto other =
e->asGaussian();
107 auto other =
e->asDiscrete();
117 return gc->error(
values.continuous());
121 return dc->error(
values.discrete());
123 throw std::runtime_error(
124 "HybridConditional::error: conditional type not handled");
133 return gm->errorTree(
values);
135 return dc->errorTree();
137 throw std::runtime_error(
138 "HybridConditional::error: conditional type not handled");
144 return gc->logProbability(
values.continuous());
146 return gm->logProbability(
values);
148 return dc->logProbability(
values.discrete());
150 throw std::runtime_error(
151 "HybridConditional::logProbability: conditional type not handled");
157 return gc->negLogConstant();
159 return gm->negLogConstant();
161 return dc->negLogConstant();
163 throw std::runtime_error(
164 "HybridConditional::negLogConstant: conditional type not handled");
void print(const std::string &s="Conditional", const KeyFormatter &formatter=DefaultKeyFormatter) const
HybridGaussianConditional::shared_ptr asHybrid() const
Return HybridConditional as a HybridGaussianConditional.
Array< double, 1, 3 > e(1./3., 0.5, 2.)
HybridConditional()=default
Default constructor needed for serialization.
bool isDiscrete() const
True if this is a factor of discrete variables only.
AlgebraicDecisionTree< Key > errorTree(const VectorValues &values) const override
Compute error of the HybridConditional as a tree.
const KeyFormatter & formatter
DiscreteKeys is a set of keys that can be assembled using the & operator.
const EIGEN_DEVICE_FUNC ExpReturnType exp() const
bool isHybrid() const
True is this is a Discrete-Continuous factor.
FastVector< Key > KeyVector
Define collection type once and for all - also used in wrappers.
double evaluate(const HybridValues &values) const override
Return the probability (or density) of the underlying conditional.
void print(const std::string &s="Hybrid Conditional: ", const KeyFormatter &formatter=DefaultKeyFormatter) const override
GTSAM-style print.
std::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
KeyVector CollectKeys(const KeyVector &continuousKeys, const DiscreteKeys &discreteKeys)
double error(const HybridValues &values) const override
Return the error of the underlying conditional.
DiscreteKeys discreteKeys_
bool isContinuous() const
True if this is a factor of continuous variables only.
std::shared_ptr< Factor > inner_
Type-erased pointer to the inner type.
const KeyVector & keys() const
Access the factor's involved variable keys.
DiscreteConditional::shared_ptr asDiscrete() const
Return conditional as a DiscreteConditional.
double negLogConstant() const override
GaussianConditional::shared_ptr asGaussian() const
Return HybridConditional as a GaussianConditional.
bool equals(const HybridFactor &other, double tol=1e-9) const override
GTSAM-style equals.
double logProbability(const HybridValues &values) const override
Return the log-probability (or density) of the underlying conditional.
DiscreteKeys CollectDiscreteKeys(const DiscreteKeys &key1, const DiscreteKeys &key2)
gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:02:26