Suppose we are given data x, y
data = (x, y)
Suppose the model to fit is y = x * m
, where we want to find m
.
Implement a weighted least squares solver
function solver(w, data)
# implement your weighted least squares optimizer
# w is a N-vector of weights
end
and a function to calculate the residuals
function residuals(c, data)
# implement a function that returns the residuals for each data point given the candidate solution m
# should return a N-vector of residuals
end
define maximum residual of inliers
c = 0.2
Solve using GNC
using GraduatedNonConvexity
m_gm = GNC_GM(N, data, solver, residuals, c) # or
m_tls = GNC_TLS(N, data, solver, residuals, c)
see examples/1d.jl
This package is a re-implementation of
H. Yang, P. Antonante, V. Tzoumas, and L. Carlone,“Graduated Non-Convexity for Robust Spatial Perception: From Non-Minimal Solvers to Global Outlier Rejection”,IEEE Robotics and Automation Letters (RA-L), 2020
The author's original implementatation is available at https://github.com/MIT-SPARK/GNC-and-ADAPT