TMinuit python fit function call failed(C++ exception of type runtime_error)

Hello all, while i was translating a C++ /ROOT script in PyRoot using TMinuit i got this error:
mini.mnexcm(“MIGRAD”, arglist, 2, ierflg)
Exception: void TMinuit::mnexcm(const char* comand, double* plist, int llist, int& ierflg) =>
TMinuit python fit function call failed (C++ exception of type runtime_error)
I have no idea what the problem may be. Is there anyone that can help me? I can give you more information about the program if you ask me something specific.
Thank you in advance!


In your call

mini.mnexcm(“MIGRAD”, arglist, 2, ierflg)

what are the types of arglist and ierflg ?

ierflg = ctypes.c_int()
arglist = np.empty(10)

and this:

#Minimization step

arglist[0] = 2000  # max number of calls to fcn

arglist[1] = 1e-20 # tolerance

That looks good, seems that the problem is somewhere else in the program.

Are you defining some fit function in Python and then passing it as an argument somewhere in your Python script?

i’ve written some theoretical functions and then from external files i’m inserting a data file and a file with parameters. Then i define fcn function and when i try to call minuit an error occurs. Should the arguments in the theoretical function be equal in number with the arguments in fcn? i have a function(p1,p2,p3,p4,v) with 4parameters and one variable should the fcn func have 5arguments ? in c++ i have fcn(npar, gin, f, par, iflag) . Does it have to be the same? i’m a little bit lost with the minuit. Thanx in advance!


I think at this point it would be useful if you could share some simple reproducer? To know exactly what code you are running and how you are defining the function that causes the error. (6.0 KB)

I am attaching a script with the first lines of code…it continues with plots etc. and with some lines where i insert my experimental and parameter files. My problem is that my function is user defined. I am not using lsq or binnedlikelihood or something familiar and also i want to insert the initial values of parameters from an external point not as simple arguments when calling minuit.
Thank you


That script contains paths to your local file system, could you try to come up with a standalone reproducer that I can run? Perhaps something that just creates TMinuit, does the SetFCN and then runs mnexcm would be enough to trigger the problem?

parameters.txt (642 Bytes)
data.txt (3.8 KB)

I thought it’s more simple to send the 2 files for the parameters (as the name) and the data.
Thank you very much

What do I need to provide to:
Enter low limit LL:
Enter upper limit LU:
Enter the pre-conditioning:

I’m so sorry i forgot to mention this. LL=20, LU=220, preconditioning=1

There seems to be a problem in this line of fcn:

d = TL_exp[i]-TL_theo(T[i], par)

I get IndexError: invalid index to scalar variable.

I’d check that expression (and see if you are trying to index a scalar variable)

sorry again but i still have the same problem…can you guide me to find which variable is having the problem?
thanx in advance


The problem is in this function that is called from fcn:

def TL_theo(t, *par):
    return TL_theo(t[0], par)

t is a scalar and is indexed (t[0]).

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