@@ -63,7 +63,6 @@ class HybridNonlinearFactor : public HybridFactor {
63
63
private:
64
64
// / Decision tree of Gaussian factors indexed by discrete keys.
65
65
Factors factors_;
66
- bool normalized_;
67
66
68
67
public:
69
68
HybridNonlinearFactor () = default ;
@@ -74,12 +73,10 @@ class HybridNonlinearFactor : public HybridFactor {
74
73
* @param keys Vector of keys for continuous factors.
75
74
* @param discreteKeys Vector of discrete keys.
76
75
* @param factors Decision tree with of shared factors.
77
- * @param normalized Flag indicating if the factor error is already
78
- * normalized.
79
76
*/
80
77
HybridNonlinearFactor (const KeyVector& keys, const DiscreteKeys& discreteKeys,
81
- const Factors& factors, bool normalized = false )
82
- : Base(keys, discreteKeys), factors_(factors), normalized_(normalized) {}
78
+ const Factors& factors)
79
+ : Base(keys, discreteKeys), factors_(factors) {}
83
80
84
81
/* *
85
82
* @brief Convenience constructor that generates the underlying factor
@@ -95,15 +92,12 @@ class HybridNonlinearFactor : public HybridFactor {
95
92
* @param discreteKey The discrete key indexing each component factor.
96
93
* @param factors Vector of nonlinear factor and scalar pairs.
97
94
* Same size as the cardinality of discreteKey.
98
- * @param normalized Flag indicating if the factor error is already
99
- * normalized.
100
95
*/
101
96
template <typename FACTOR>
102
97
HybridNonlinearFactor (
103
98
const KeyVector& keys, const DiscreteKey& discreteKey,
104
- const std::vector<std::pair<std::shared_ptr<FACTOR>, double >>& factors,
105
- bool normalized = false )
106
- : Base(keys, {discreteKey}), normalized_(normalized) {
99
+ const std::vector<std::pair<std::shared_ptr<FACTOR>, double >>& factors)
100
+ : Base(keys, {discreteKey}) {
107
101
std::vector<NonlinearFactorValuePair> nonlinear_factors;
108
102
KeySet continuous_keys_set (keys.begin (), keys.end ());
109
103
KeySet factor_keys_set;
@@ -225,11 +219,10 @@ class HybridNonlinearFactor : public HybridFactor {
225
219
};
226
220
if (!factors_.equals (f.factors_ , compare)) return false ;
227
221
228
- // If everything above passes, and the keys_, discreteKeys_ and normalized_
222
+ // If everything above passes, and the keys_ and discreteKeys_
229
223
// member variables are identical, return true.
230
224
return (std::equal (keys_.begin (), keys_.end (), f.keys ().begin ()) &&
231
- (discreteKeys_ == f.discreteKeys_ ) &&
232
- (normalized_ == f.normalized_ ));
225
+ (discreteKeys_ == f.discreteKeys_ ));
233
226
}
234
227
235
228
// / @}
@@ -260,46 +253,6 @@ class HybridNonlinearFactor : public HybridFactor {
260
253
return std::make_shared<HybridGaussianFactor>(
261
254
continuousKeys_, discreteKeys_, linearized_factors);
262
255
}
263
-
264
- /* *
265
- * If the component factors are not already normalized, we want to compute
266
- * their normalizing constants so that the resulting joint distribution is
267
- * appropriately computed. Remember, this is the _negative_ normalizing
268
- * constant for the measurement likelihood (since we are minimizing the
269
- * _negative_ log-likelihood).
270
- */
271
- double nonlinearFactorLogNormalizingConstant (const sharedFactor& factor,
272
- const Values& values) const {
273
- // Information matrix (inverse covariance matrix) for the factor.
274
- Matrix infoMat;
275
-
276
- // If this is a NoiseModelFactor, we'll use its noiseModel to
277
- // otherwise noiseModelFactor will be nullptr
278
- if (auto noiseModelFactor =
279
- std::dynamic_pointer_cast<NoiseModelFactor>(factor)) {
280
- // If dynamic cast to NoiseModelFactor succeeded, see if the noise model
281
- // is Gaussian
282
- auto noiseModel = noiseModelFactor->noiseModel ();
283
-
284
- auto gaussianNoiseModel =
285
- std::dynamic_pointer_cast<noiseModel::Gaussian>(noiseModel);
286
- if (gaussianNoiseModel) {
287
- // If the noise model is Gaussian, retrieve the information matrix
288
- infoMat = gaussianNoiseModel->information ();
289
- } else {
290
- // If the factor is not a Gaussian factor, we'll linearize it to get
291
- // something with a normalized noise model
292
- // TODO(kevin): does this make sense to do? I think maybe not in
293
- // general? Should we just yell at the user?
294
- auto gaussianFactor = factor->linearize (values);
295
- infoMat = gaussianFactor->information ();
296
- }
297
- }
298
-
299
- // Compute the (negative) log of the normalizing constant
300
- return -(factor->dim () * log (2.0 * M_PI) / 2.0 ) -
301
- (log (infoMat.determinant ()) / 2.0 );
302
- }
303
256
};
304
257
305
258
} // namespace gtsam
0 commit comments