I'm using the CERN ROOT Data Analysis Framework implementation of the GNU MultiRootFinder to solve for the unknowns, x
and y
, in the following system:
The system describes the solution to a localization problem. That is, given the locations [x_i, y_i]
of three parties, the speed of some signal, and the time at which each party "saw" the signal, I want to determine the coordinates, [x,y]
, of the source. We can assume the three parties and the source are coplanar, for simplicity.
My code is as follows. Note that this code is designed to run in Cling, where it is a perfectly valid program. void localize()
plays the role of int main()
here. Some changes would be needed to compile this in, say, gcc
.
#define x1 300000
#define y1 360000
#define x2 210000
#define y2 210000
#define x3 96000
#define y3 360000
#define c 29980000000
void localize(){
ROOT::RDataFrame frame("D","./path/to/data");
auto statn1 = frame.Take<double>("statn1");
auto statn2 = frame.Take<double>("statn2");
auto statn3 = frame.Take<double>("statn3");
TF2 *f1 = new TF2("f1","sqrt((x-[0])^2 + (y-[1])^2) + [2]*([3] - [4]) - sqrt((x-[5])^2 + (y-[6])^2)");
TF2 *f2 = new TF2("f2","sqrt((x-[0])^2 + (y-[1])^2) + [2]*([3] - [4]) - sqrt((x-[5])^2 + (y-[6])^2)");
ROOT::Math::MultiRootFinder rootFinder(0);
int i = 0;
f1->SetParameters(x1,y1,c, statn2->at(i), statn1->at(i), x2,y2);
f2->SetParameters(x2,y2,c, statn3->at(i), statn2->at(i), x3,y3);
ROOT::Math::WrappedMultiTF1 g1(*f1,2);
ROOT::Math::WrappedMultiTF1 g2(*f2,2);
rootFinder.AddFunction(g1);
rootFinder.AddFunction(g2);
rootFinder.SetPrintLevel(1);
double init[2] = {2000, 3200};
rootFinder.Solve(init);
}
When I run the code, I get the error
Error in <ROOT::Math::GSLMultiRootFinder::Solve>: The iteration is not making any progress
I've set the iterations to the maximum number possible, and I've chosen the starting point to be the center of the circle circumscribed by the three parties.
I fed the solver only the first two equations. Feeding it all three is, as I understand it, unneccessary, and produces an error as the solution to all three includes a third unknown, the time of emission.
What am I doing wrong here? Apologies if this is a basic question. This isn't something I'm very familiar with.
EDIT:
I'm wondering if this has anything to do with the fact that two equations will produce two solutions, in general. So, perhaps the root finder isn't converging on a single solution, causing the error? I can't find anything in the docs that suggests this, but I can't find anything that doesn't either.
If this is the case, I'm wondering, how could I introduce the third equation so as to disambaguate?
EDIT:
I've tried playing with the tolerances and # of iterations. If I start at 3 iterations, I get a new error:
ROOT::Math::GSLMultiRootFinder::Solve: exceeded max iterations, reached tolerance is not sufficient; absTol = 1e-06
Where the tolerance is set to the default value of 1E-06 (obviously). This continues up to 10 iterations, when I get the "not making progress" error.