min = h.fit_praxis(n, "funname", x._ref_x[0])
min = h.fit_praxis(n, "funname", Vector)
min = h.fit_praxis(..., ..., ..., "after quad statement")
min = h.fit_praxis(efun_as_python_callable, neuron_vector)
This is the principal axis method for minimizing a function. See praxis.c in the scopmath library.
funname may be either an interpreted HOC function or a compiled NMODL function. This form of calling cannot optimize Python functions directly.
If the variable stoprun is set to 1 during a call to fit_praxis, it will return immediately (when the current call to funname returns) with a return value and varx values set to the best minimum found so far. Use stop_praxis() to stop after finishing the current principal axis calculation.
The fourth argument, if present, specifies a statement to be executed at the end of each principal axis evaluation.
If the third argument is a Vector, then that style is used to specify the initial starting point and return the final value. However the function is still called with second arg as a pointer into a double array.
The Python callable form uses a Python Callable as the function to minimize and it must take a single NEURON Vector argument specifying the values of the parameters for use in evaluation the function. On entry to fit_praxis the Vector specifies the number of parameters and the parameter starting values. On return the vector contains the values of parameters which generated the least minimum found so far.
Example: minimize \((x+y - 5)^2 + 5*((x-y) - 15)^2\)
from neuron import h
v = h.Vector(2)
def efun(v):
return (v.x[0]+v.x[1] - 5)**2 + 5*(v.x[0]-v.x[1] - 15)**2
h.attr_praxis(1e-5, .5, 0)
e = h.fit_praxis(efun, v)
print "e=%g x=%g y=%g\n"%(e, v.x[0], v.x[1])
Warning
Up to version 4.0.1, the arguments to funname were an explicit list of n arguments. ie numarg()==n.
See also
h.attr_praxis(tolerance, maxstepsize, printmode)
previous_index = attr_praxis(mcell_ran4_index)
Set the attributes of the praxis method. This must be called before the first call to fit_praxis().
The single argument form causes praxis to pick its random numbers from the the mcellran4 generator beginning at the specified index. This allows reproducible fitting. The return value is the previously picked index. (see mcell_ran4())
pval = h.pval_praxis(i)
pval = h.pval_praxis(i, paxis._ref_x[0])
pval = h.pval_praxis(i, Vector)
h.stop_praxis()
h.stop_praxis(i)