[Minuit2] Add interface to pass initial values/cov matrix
This Pull request:
Modifies Minuit2 interface to pass initial error/covariance matrix or second derivatives (G2) vector.
Changes or fixes:
This PR exploits existing code in MnSeedGenerator and introduces some improvements, namely:
- Check whether provided matrix has positive diagonal (G2 must be positive) and larger than working precision
Eps; if it is not the case, numerical computation is carried out. - Disable
NegativeG2LineSearchwhenever point 1 is satisfied.
Furthermore, this PR provides an interface to pass the error/covariance matrix or second derivatives (G2) vector via ROOT::Math::Minimizer. The user can provide either the error/covariance matrix in compressed format (column-major upper triangular part), OR the g2 vector, see the code snippet below. The matrix or second derivatives must take into account only variable parameters, implying that all fixed parameters must be declared before providing initial values.
ROOT::Math::Minimizer* minimum = ROOT::Math::Factory::CreateMinimizer(minName, algoName);
minimum->SetVariable(0,"x",0.,0.);
minimum->SetVariable(1,"y",0.,0.);
int nrow = 2;
std::vector<double> cov(nrow*(nrow+1)/2);
std::vector<double> g2(nrow);
for(int i = 0; i < nrow; i++) {
g2[i] = 0.1*(i+1);
for(int j = i;j< nrow;j++)
cov[i * nrow - (i - 1) * i / 2 + j - i] = (i==j) ? 0.1*(i+1) : 0.;
}
minimum->SetCovariance(cov,nrow);
// OR
//minimum->SetG2(g2,nrow);
Checklist:
- [x] tested changes locally
- [x] updated the docs (if necessary)
Hi @mdessole, thanks a lot for the PR! There are merge conflicts though. Could you please rebase on master? Thanks!
Test Results
17 files 17 suites 3d 13h 7m 15s ⏱️ 2 700 tests 2 699 ✅ 1 💤 0 ❌ 43 571 runs 43 571 ✅ 0 💤 0 ❌
Results for commit 1a1bc1f2.
:recycle: This comment has been updated with latest results.
It's not great that we have to consider all these redundant overloads. I would suggest getting rid of them first, to keep the interface clean and consistent:
- https://github.com/root-project/root/pull/16443
What do you think, @lmoneta?
Rebased to re-run on mac15.
Are we missing something to go ahead with this PR?
Hi @guitargeek, @lmoneta! The PR is ready for review, could you please have a look?