-
Notifications
You must be signed in to change notification settings - Fork 767
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make mEstimator variable names consistent with math #188
Changes from all commits
23f5c8c
102123c
a5ff750
6e46b72
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -101,6 +101,82 @@ TEST( NonlinearFactor, NonlinearFactor ) | |
DOUBLES_EQUAL(expected,actual,0.00000001); | ||
} | ||
|
||
/* ************************************************************************* */ | ||
TEST(NonlinearFactor, Weight) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @dellaert I added a unit test for the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @yetongumich and @ProfFan There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see no problem, @yetongumich what do you think? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. LGTM |
||
// create a values structure for the non linear factor graph | ||
Values values; | ||
|
||
// Instantiate a concrete class version of a NoiseModelFactor | ||
PriorFactor<Point2> factor1(X(1), Point2(0, 0)); | ||
values.insert(X(1), Point2(0.1, 0.1)); | ||
|
||
CHECK(assert_equal(1.0, factor1.weight(values))); | ||
|
||
// Factor with noise model | ||
auto noise = noiseModel::Isotropic::Sigma(2, 0.2); | ||
PriorFactor<Point2> factor2(X(2), Point2(1, 1), noise); | ||
values.insert(X(2), Point2(1.1, 1.1)); | ||
|
||
CHECK(assert_equal(1.0, factor2.weight(values))); | ||
|
||
Point2 estimate(3, 3), prior(1, 1); | ||
double distance = (estimate - prior).norm(); | ||
|
||
auto gaussian = noiseModel::Isotropic::Sigma(2, 0.2); | ||
|
||
PriorFactor<Point2> factor; | ||
|
||
// vector to store all the robust models in so we can test iteratively. | ||
vector<noiseModel::Robust::shared_ptr> robust_models; | ||
|
||
// Fair noise model | ||
auto fair = noiseModel::Robust::Create( | ||
noiseModel::mEstimator::Fair::Create(1.3998), gaussian); | ||
robust_models.push_back(fair); | ||
|
||
// Huber noise model | ||
auto huber = noiseModel::Robust::Create( | ||
noiseModel::mEstimator::Huber::Create(1.345), gaussian); | ||
robust_models.push_back(huber); | ||
|
||
// Cauchy noise model | ||
auto cauchy = noiseModel::Robust::Create( | ||
noiseModel::mEstimator::Cauchy::Create(0.1), gaussian); | ||
robust_models.push_back(cauchy); | ||
|
||
// Tukey noise model | ||
auto tukey = noiseModel::Robust::Create( | ||
noiseModel::mEstimator::Tukey::Create(4.6851), gaussian); | ||
robust_models.push_back(tukey); | ||
|
||
// Welsch noise model | ||
auto welsch = noiseModel::Robust::Create( | ||
noiseModel::mEstimator::Welsch::Create(2.9846), gaussian); | ||
robust_models.push_back(welsch); | ||
|
||
// Geman-McClure noise model | ||
auto gm = noiseModel::Robust::Create( | ||
noiseModel::mEstimator::GemanMcClure::Create(1.0), gaussian); | ||
robust_models.push_back(gm); | ||
|
||
// DCS noise model | ||
auto dcs = noiseModel::Robust::Create( | ||
noiseModel::mEstimator::DCS::Create(1.0), gaussian); | ||
robust_models.push_back(dcs); | ||
|
||
// L2WithDeadZone noise model | ||
auto l2 = noiseModel::Robust::Create( | ||
noiseModel::mEstimator::L2WithDeadZone::Create(1.0), gaussian); | ||
robust_models.push_back(l2); | ||
|
||
for(auto&& model: robust_models) { | ||
factor = PriorFactor<Point2>(X(3), prior, model); | ||
values.clear(); | ||
values.insert(X(3), estimate); | ||
CHECK(assert_equal(model->robust()->weight(distance), factor.weight(values))); | ||
} | ||
} | ||
|
||
/* ************************************************************************* */ | ||
TEST( NonlinearFactor, linearize_f1 ) | ||
{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might cause regressions. 🙁
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, this is very significant, and seems fishy. Too bad this stuff did not get resolved when it was fresh in our minds, but now we have to re-argue this, and why it was not in @yetongumich PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. I believe the
0.5
should NOT be present, since if thenoiseModel_
is not robust, the weight function should simply be 1 (which in NoiseModel.h it is). If the noise model is robust, then it should just return the weight value for that particular M-estimator given the residuals.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interestingly, there isn't any test for this 😢
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interestingly, there isn't any reasonable usages for this function either...
Also, I think the 0.5 factor should not be there. @dellaert
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only usage of this function is in
gtsam_unstable/partition
, so I suggest this function to be moved to unstable as a standalone function there.Plus, this change is correct.