# Change in Minuit2 behaviour from 6.20.00 onwards

**URL:** <https://root-forum.cern.ch/t/change-in-minuit2-behaviour-from-6-20-00-onwards/40362>\
**Category:** ROOT\
**Tags:** math\
**Created:** [July 10, 2020, 6:55pm UTC](https://root-forum.cern.ch/t/change-in-minuit2-behaviour-from-6-20-00-onwards/40362 "2020-07-10T18:55:03Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![jdalseno](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/j/9de0a6/32.png) [@jdalseno](https://root-forum.cern.ch/u/jdalseno)\
**Post date:** [July 10, 2020, 6:55pm UTC](https://root-forum.cern.ch/t/change-in-minuit2-behaviour-from-6-20-00-onwards/40362/1 "2020-07-10T18:55:04Z")

</div>

I’ve noticed recently that some of my fits are starting to crash with the following error,

…/root-6.22.00/math/minuit2/src/VariableMetricBuilder.cxx:272: ROOT::Minuit2::FunctionMinimum ROOT::Minuit2::VariableMetricBuilder::Minimum(const ROOT::Minuit2::MnFcn&, const ROOT::Minuit2::GradientCalculator&, const ROOT::Minuit2::MinimumSeed&, std::vectorROOT::Minuit2::MinimumState&, unsigned int, double) const: Assertion `s0.IsValid()’ failed.  
Aborted (core dumped)

which doesn’t happen with 6.18.04 and earlier on the same code. Here’s a minimal example reproducing the problem that will finish with 6.18.04 but crash with 6.20.00 onwards,

```auto
#include "Minuit2/FCNBase.h"
#include "Minuit2/FunctionMinimum.h"
#include "Minuit2/MnMigrad.h"
#include "Minuit2/MnPrint.h"
#include "Minuit2/MnUserParameters.h"

class Fcn : public ROOT::Minuit2::FCNBase
{
  virtual double operator()( const std::vector<double>& par ) const
  { return 1.0; }

  virtual double Up() const
  { return 1.0; }
};

int main()
{
  ROOT::Minuit2::MnUserParameters mn_param;
  mn_param.Add("par1", 0.0, 0.001);

  Fcn fcn;
  ROOT::Minuit2::MnMigrad migrad(fcn, mn_param, 2);
  ROOT::Minuit2::FunctionMinimum min = migrad();
  std::cout << min << std::endl;

  return 0;
}

```

I wasn’t able to find any information in recent release notes concerning changes to Minuit2 so I was wondering if anyone knew what happened and if this new behaviour should be expected from now on?

\_ROOT Version: 6.20.00 and above  
_Platform:_ Linux  
_Compiler:_ gcc9

* * *

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [July 10, 2020, 7:09pm UTC](https://root-forum.cern.ch/t/change-in-minuit2-behaviour-from-6-20-00-onwards/40362/2 "2020-07-10T19:09:23Z")

</div>

Thanks for reporting the issue. @moneta will most probably take a look

---

<div class="post-metadata">

**Author:** ![moneta](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/moneta/32/19423_2.png) [@moneta](https://root-forum.cern.ch/u/moneta)\
**Post date:** [July 13, 2020, 5:33pm UTC](https://root-forum.cern.ch/t/change-in-minuit2-behaviour-from-6-20-00-onwards/40362/3 "2020-07-13T17:33:00Z")

</div>

Hi,  
There has been no change, you are probably using a debug build (containing assert) and a non debug build. In the first case , an assert is triggered since the initial state is invalid due to an invalid initial Hessian matrix. In that case happens because your function has zero second derivative.

Probably this assert can be removed and let anyway Minuit2 failing

Lorenzo

---

<div class="post-metadata">

**Author:** ![jdalseno](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/j/9de0a6/32.png) [@jdalseno](https://root-forum.cern.ch/u/jdalseno)\
**Post date:** [July 13, 2020, 6:20pm UTC](https://root-forum.cern.ch/t/change-in-minuit2-behaviour-from-6-20-00-onwards/40362/4 "2020-07-13T18:20:58Z")

</div>

Hi Lorenzo, thanks very much for your reply.

I’m building both versions of root from source with the same cmake command,

cmake …/root-6.xx.yy/ -DCMAKE\_INSTALL\_PREFIX=/opt/root -DCMAKE\_BUILD\_TYPE=Optimized -DCMAKE\_CXX\_STANDARD=17 -Dgminimal=ON -Dminuit2=ON -Dmathmore=ON

Is there an additional flag that should be set in order not to build a debug version?

---

<div class="post-metadata">

**Author:** ![eguiraud](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/eguiraud/32/32217_2.png) [@eguiraud](https://root-forum.cern.ch/u/eguiraud)\
**Post date:** [July 14, 2020, 7:05am UTC](https://root-forum.cern.ch/t/change-in-minuit2-behaviour-from-6-20-00-onwards/40362/5 "2020-07-14T07:05:44Z")

</div>

Hi,  
`-DCMAKE_BUILD_TYPE=Optimized` should be `-DCMAKE_BUILD_TYPE=Release` (which is also the default). I am not sure whether using “Optimized” happens to add debug symbols.

Cheers,  
Enrico

---

<div class="post-metadata">

**Author:** ![jdalseno](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/j/9de0a6/32.png) [@jdalseno](https://root-forum.cern.ch/u/jdalseno)\
**Post date:** [July 14, 2020, 8:38am UTC](https://root-forum.cern.ch/t/change-in-minuit2-behaviour-from-6-20-00-onwards/40362/6 "2020-07-14T08:38:52Z")

</div>

Hi Enrico, that was it, thanks. I recompiled ROOT by removing that flag and now everything has returned to normal. Should something be done about the Optimized flag adding debug symbols, or was this flag intended more for developers rather than being for general use? I should probably report this downstream to Fedora as well as their rpm builds also suffer the crash.

---

<div class="post-metadata">

**Author:** ![eguiraud](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/eguiraud/32/32217_2.png) [@eguiraud](https://root-forum.cern.ch/u/eguiraud)\
**Post date:** [July 14, 2020, 9:38am UTC](https://root-forum.cern.ch/t/change-in-minuit2-behaviour-from-6-20-00-onwards/40362/7 "2020-07-14T09:38:21Z")

</div>

Where did you find that `Optimized` build mode?

> I should probably report this downstream to Fedora as well as their rpm builds also suffer the crash.

It’s totally ok for builds to have debug symbols, in general.

@moneta, how should the script be changed so that it does not trigger the assert?

---

<div class="post-metadata">

**Author:** ![moneta](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/moneta/32/19423_2.png) [@moneta](https://root-forum.cern.ch/u/moneta)\
**Post date:** [July 14, 2020, 9:51am UTC](https://root-forum.cern.ch/t/change-in-minuit2-behaviour-from-6-20-00-onwards/40362/8 "2020-07-14T09:51:11Z")

</div>

I will anyway remove this assert() to avoid such problems in the future

---

<div class="post-metadata">

**Author:** ![jdalseno](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/j/9de0a6/32.png) [@jdalseno](https://root-forum.cern.ch/u/jdalseno)\
**Post date:** [July 14, 2020, 9:58am UTC](https://root-forum.cern.ch/t/change-in-minuit2-behaviour-from-6-20-00-onwards/40362/9 "2020-07-14T09:58:15Z")

</div>

The way I came to include the `Optimized` build mode was from the `INSTALL` file bundled with ROOT in the README directory. Section 6 pointed me to this webpage,

> **[Building ROOT from source](https://root.cern/install/build_from_source/#options)**
>
> Data Analysis Framework

where I found `CMAKE_BUILD_TYPE` under the “Relevant CMake variables” heading. I guess my thinking was that `Optimized` should be the best option for fastest performance.

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [July 28, 2020, 10:00am UTC](https://root-forum.cern.ch/t/change-in-minuit2-behaviour-from-6-20-00-onwards/40362/10 "2020-07-28T10:00:40Z")

</div>

Closed on July 28, 2020, 10:00am UTC

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
