[SciPy-User] fsolve with restriction on variable
Robert Kern
robert.kern at gmail.com
Mon Aug 3 14:44:56 EDT 2009
On Mon, Aug 3, 2009 at 13:42, Ashley DaSilva<awesomeashley527 at gmail.com> wrote:
> Sorry, I will send the traceback.
> I am using fmin_tnc, where I have: import fmin_tnc as fmin
>
> Traceback (most recent call last):
> File "hf_improved.py", line 190, in <module>
>
> solution=fmin(f2,x0,args=(eE,),bounds=[(0,1),(0,None),(0,None)],approx_grad=True)
> File "/usr/lib/python2.5/site-packages/scipy/optimize/tnc.py", line 246,
> in fmin_tnc
> fmin, ftol, xtol, pgtol, rescale)
> File "/usr/lib/python2.5/site-packages/scipy/optimize/tnc.py", line 200,
> in func_and_grad
> g = approx_fprime(x, func, epsilon, *args)
> File "/usr/lib/python2.5/site-packages/scipy/optimize/optimize.py", line
> 617, in approx_fprime
> grad[k] = (f(*((xk+ei,)+args)) - f0)/epsilon
> TypeError: unsupported operand type(s) for -: 'list' and 'list'
>
>
> Other information that might be useful:
> def f2(v,E):
> u=v[0]
> return [(E-P(v))**2, (E*u-Q(v))**2, (1-N(v))**2]
>
> where P, Q, N, are defined functions.
Oh, you mean for the function itself. Return an array, not a list.
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
-- Umberto Eco
More information about the SciPy-User
mailing list