solving issue with robust model
parent
001a55ad3a
commit
73600c8faa
|
|
@ -337,14 +337,24 @@ double ShonanAveraging<d>::cost(const Values &values) const {
|
||||||
// Get kappa from noise model
|
// Get kappa from noise model
|
||||||
template <typename T>
|
template <typename T>
|
||||||
static double Kappa(const BinaryMeasurement<T> &measurement) {
|
static double Kappa(const BinaryMeasurement<T> &measurement) {
|
||||||
const auto &isotropic = boost::dynamic_pointer_cast<noiseModel::Isotropic>(
|
const auto &isotropic = boost::dynamic_pointer_cast<noiseModel::Isotropic>(
|
||||||
measurement.noiseModel());
|
measurement.noiseModel());
|
||||||
if (!isotropic) {
|
double sigma;
|
||||||
throw std::invalid_argument(
|
if (isotropic) {
|
||||||
"Shonan averaging noise models must be isotropic.");
|
sigma = isotropic->sigma();
|
||||||
}
|
} else{
|
||||||
const double sigma = isotropic->sigma();
|
const auto &robust = boost::dynamic_pointer_cast<noiseModel::Robust>(
|
||||||
return 1.0 / (sigma * sigma);
|
measurement.noiseModel());
|
||||||
|
if (robust) {
|
||||||
|
std::cout << "Verification of optimality does not work with robust cost function" << std::endl;
|
||||||
|
sigma = 1; // setting arbitrary value
|
||||||
|
}else{
|
||||||
|
throw std::invalid_argument(
|
||||||
|
"Shonan averaging noise models must be isotropic (but robust losses are allowed).");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 1.0 / (sigma * sigma);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
|
|
|
||||||
|
|
@ -338,7 +338,7 @@ TEST(ShonanAveraging2, noisyToyGraphWithHuber) {
|
||||||
graph.print();
|
graph.print();
|
||||||
EXPECT_LONGS_EQUAL(6, graph.size());
|
EXPECT_LONGS_EQUAL(6, graph.size());
|
||||||
auto initial = shonan.initializeRandomly(kRandomNumberGenerator);
|
auto initial = shonan.initializeRandomly(kRandomNumberGenerator);
|
||||||
auto result = shonan.run(initial, 2);
|
auto result = shonan.run(initial, 2, 3);
|
||||||
EXPECT_DOUBLES_EQUAL(0.0008211, shonan.cost(result.first), 1e-6);
|
EXPECT_DOUBLES_EQUAL(0.0008211, shonan.cost(result.first), 1e-6);
|
||||||
EXPECT_DOUBLES_EQUAL(0, result.second, 1e-10); // certificate!
|
EXPECT_DOUBLES_EQUAL(0, result.second, 1e-10); // certificate!
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue