HybridValues: continuous then discrete
parent
706a8a42bc
commit
69bb4db42d
|
|
@ -218,7 +218,7 @@ HybridValues HybridBayesNet::optimize() const {
|
|||
|
||||
// Given the MPE, compute the optimal continuous values.
|
||||
GaussianBayesNet gbn = choose(mpe);
|
||||
return HybridValues(mpe, gbn.optimize());
|
||||
return HybridValues(gbn.optimize(), mpe);
|
||||
}
|
||||
|
||||
/* ************************************************************************* */
|
||||
|
|
@ -267,7 +267,7 @@ HybridValues HybridBayesNet::sample(const HybridValues &given,
|
|||
GaussianBayesNet gbn = choose(assignment);
|
||||
// Sample from the Gaussian Bayes net.
|
||||
VectorValues sample = gbn.sample(given.continuous(), rng);
|
||||
return {assignment, sample};
|
||||
return {sample, assignment};
|
||||
}
|
||||
|
||||
/* ************************************************************************* */
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ HybridValues HybridBayesTree::optimize() const {
|
|||
}
|
||||
|
||||
VectorValues values = optimize(mpe);
|
||||
return HybridValues(mpe, values);
|
||||
return HybridValues(values, mpe);
|
||||
}
|
||||
|
||||
/* ************************************************************************* */
|
||||
|
|
|
|||
|
|
@ -37,12 +37,12 @@ namespace gtsam {
|
|||
*/
|
||||
class GTSAM_EXPORT HybridValues {
|
||||
private:
|
||||
// DiscreteValue stored the discrete components of the HybridValues.
|
||||
DiscreteValues discrete_;
|
||||
|
||||
// VectorValue stored the continuous components of the HybridValues.
|
||||
VectorValues continuous_;
|
||||
|
||||
// DiscreteValue stored the discrete components of the HybridValues.
|
||||
DiscreteValues discrete_;
|
||||
|
||||
public:
|
||||
/// @name Standard Constructors
|
||||
/// @{
|
||||
|
|
@ -51,8 +51,8 @@ class GTSAM_EXPORT HybridValues {
|
|||
HybridValues() = default;
|
||||
|
||||
/// Construct from DiscreteValues and VectorValues.
|
||||
HybridValues(const DiscreteValues& dv, const VectorValues& cv)
|
||||
: discrete_(dv), continuous_(cv){};
|
||||
HybridValues(const VectorValues& cv, const DiscreteValues& dv)
|
||||
: continuous_(cv), discrete_(dv){};
|
||||
|
||||
/// @}
|
||||
/// @name Testable
|
||||
|
|
@ -62,15 +62,15 @@ class GTSAM_EXPORT HybridValues {
|
|||
void print(const std::string& s = "HybridValues",
|
||||
const KeyFormatter& keyFormatter = DefaultKeyFormatter) const {
|
||||
std::cout << s << ": \n";
|
||||
discrete_.print(" Discrete", keyFormatter); // print discrete components
|
||||
continuous_.print(" Continuous",
|
||||
keyFormatter); // print continuous components
|
||||
keyFormatter); // print continuous components
|
||||
discrete_.print(" Discrete", keyFormatter); // print discrete components
|
||||
};
|
||||
|
||||
/// equals required by Testable for unit testing
|
||||
bool equals(const HybridValues& other, double tol = 1e-9) const {
|
||||
return discrete_.equals(other.discrete_, tol) &&
|
||||
continuous_.equals(other.continuous_, tol);
|
||||
return continuous_.equals(other.continuous_, tol) &&
|
||||
discrete_.equals(other.discrete_, tol);
|
||||
}
|
||||
|
||||
/// @}
|
||||
|
|
@ -130,8 +130,8 @@ class GTSAM_EXPORT HybridValues {
|
|||
std::string html(
|
||||
const KeyFormatter& keyFormatter = DefaultKeyFormatter) const {
|
||||
std::stringstream ss;
|
||||
ss << this->discrete_.html(keyFormatter);
|
||||
ss << this->continuous_.html(keyFormatter);
|
||||
ss << this->discrete_.html(keyFormatter);
|
||||
return ss.str();
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue