[SciPy-user] minpack.error / fsolve problem

Webb Sprague webb.sprague@gmail....
Fri Feb 29 18:30:34 CST 2008

I am having a problem with convergence (I think) for an optimization.

Every so often I do a non-linear fit of a parameter using fsolve (as
input a constant vector of base death rates, a constant vector
multiplier of those, and a variable scalar multiplier -- the last is
what I am trying to fit) and I get a "minpack.error" with the message
that "Error occured while calling the Python function named f"  with
no other information. The information normally returned from fsolve
(ier, message,  infodict) are all set to none.

I am kind of at a loss for how to proceed, at least without taking a
class on optimization algorithms.  How do I get more information from
fsolve?  Is there a better optimization function to use?
optimize.golden()?  Or ... ?

See attached for how I set up the optimizer, and here is the back
trace from the web application using this code:


Traceback (most recent call last):

  File "/usr/lib64/python2.5/site-packages/mod_python/importer.py",
line 1537, in HandlerDispatch
    default=default_handler, arg=req, silent=hlist.silent)

  File "/usr/lib64/python2.5/site-packages/mod_python/importer.py",
line 1229, in _process_target
    result = _execute_target(config, req, object, arg)

  File "/usr/lib64/python2.5/site-packages/mod_python/importer.py",
line 1128, in _execute_target
    result = object(arg)

  File "/usr/lib64/python2.5/site-packages/mod_python/publisher.py",
line 213, in handler
    published = publish_object(req, object)

  File "/usr/lib64/python2.5/site-packages/mod_python/publisher.py",
line 425, in publish_object
    return publish_object(req,util.apply_fs_data(object, req.form, req=req))

  File "/usr/lib64/python2.5/site-packages/mod_python/util.py", line
554, in apply_fs_data
    return object(**args)

  File "/var/www/localhost/htdocs/lcfit/lc.py", line 221, in
    return ProcessRatesCoherent_(req)

  File "/home/webbs/larry/INTERNET_APPLICATION/LcPageObjects.py", line
425, in __call__
    obj = self.targetClass(**formData)

  File "/home/webbs/larry/INTERNET_APPLICATION/LcSinglePopObject.py",
line 530, in __init__

  File "/home/webbs/larry/INTERNET_APPLICATION/LcCoherentPopObject.py",
line 205, in _do_lc
    flattenBx=self.flattenBx, doTS=True))

  File "/home/webbs/larry/INTERNET_APPLICATION/LcSinglePopObject.py",
line 338, in lcInfer
    kt = fitMultiKt(ax, bx, copy.copy(kt_unfit), nmx[goodRowsNum,:],

  File "/home/webbs/larry/INTERNET_APPLICATION/LcSinglePopObject.py",
line 103, in fitMultiKt
    fittedKt[i] = fitSingleKt(ax, bx, kt[i], nmx[i,:],
lifeTableParams) # ages go across

  File "/home/webbs/larry/INTERNET_APPLICATION/LcSinglePopObject.py",
line 88, in fitSingleKt
    fittedKt = LcUtil.fitX(func=LcUtil.kt2e0, target=target_e0, ax=ax,
bx=bx, lifeTableParams=lifeTableParams)

  File "/home/webbs/larry/INTERNET_APPLICATION/LcUtil.py", line 460, in fitX
    "funcKwargs: %s\n" % pprint.pformat(funcKwargs))

Exception: Caught exception and weird failure in fitting kt to empirical e_0.
e: "Error occured while calling the Python function named f".  error
__doc__:  "None". type: "<class 'minpack.error'>".  out: "None".
infodict: "None".  ier: "None".  mesg:  "None".
funcArgs: ()
funcKwargs: {'ax': array([-4.231837, -6.92667 , -7.537601, -7.668495,
-6.554903, -5.971107, -5.759917, -5.514402, -5.230182, -4.900118,
-4.559831, -4.244538, -3.937256, -3.602081, -3.269744, -2.901267,
-2.51867 , -2.118842, -1.746651, -1.402097, -1.085182, -0.795903,
-0.534262, -0.300259]),
 'bx': array([ 0.135533,  0.126908,  0.117685,  0.095685,  0.029012,
0.019818,  0.025011,  0.003613, -0.00145 , -0.03515 , -0.0542  ,
-0.062684, -0.051495, -0.039603, -0.029531, -0.011641, -0.002807,
-0.018365, -0.028617, -0.033565, -0.033207, -0.027544, -0.016576,
 'lifeTableParams': {'ageCutoff': 80,
                     'beginFuncParam': 0.0,
                     'endFuncParam': 0.0,
                     'extensionMethod': 'mxExtend_Boe',
                     'gender': 'combined',
                     'ltFuncType': 'ex'}}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fsolve-error.py
Type: text/x-python
Size: 2447 bytes
Desc: not available
Url : http://projects.scipy.org/pipermail/scipy-user/attachments/20080229/aef263f6/attachment.py 

More information about the SciPy-user mailing list