[SciPy-user] minization of multivariable function
josef.pktd@gmai...
josef.pktd@gmai...
Sat Jan 24 14:06:57 CST 2009
On Sat, Jan 24, 2009 at 2:16 PM, Philippe TANN <philippetann@hotmail.com> wrote:
> Here is my program: I would like to estimate parameters by using the
> generalized method of moments. The parameters must be the values where the
> function is minimal.
> When I run my program, there is no syntax error but when I use the statement
> optiGMM(), the program is running indefinitely by showing several times the
> same message.:
> Optimization terminated successfully.
> Current function value: 0.000015
> Iterations: 32
> Function evaluations: 87
> Optimization terminated successfully.
> Current function value: 0.000014
> Iterations: 23
> Function evaluations: 72
> Optimization terminated successfully.
> Current function value: 0.000016
> Iterations: 34
> Function evaluations: 82
> Optimization terminated successfully.
> Current function value: 0.000012
> Iterations: 35
> Function evaluations: 91
> Optimization terminated successfully.
> Current function value: 0.000014
> Iterations: 34
> Function evaluations: 94
>
>
>
>
>> From: nwagner@iam.uni-stuttgart.de
>> To: scipy-user@scipy.org
>> Date: Sat, 24 Jan 2009 19:10:31 +0100
>> Subject: Re: [SciPy-user] minization of multivariable function
>>
>> On Sat, 24 Jan 2009 19:03:51 +0100
>> Philippe TANN <philippetann@hotmail.com> wrote:
>> >
>> > Hello,
>> >
>> > I have some problems when I want to minimize a
>> >multivariable function with module fmin. Indeed, when I
>> >enter my function to minimize, I have indefinitely this
>> >kind of messages many times without the values where my
>> >function is minimal:
>> >
>> > Optimization terminated successfully.
>> > Current function value: 0.000017
>> > Iterations: 30
>> > Function evaluations: 80
>> > May you help me to solve this problem?
>> > Thank you in advance,
>> > PhT
>> >
I just gave it a quick look. I finishes if I put maxiter in both of your fmin
You have a redundant nested fmin in matpoids,
matpoids is solving the same problem each time. The printout
"Optimization terminated successfully" comes from your fmin in
matpoids, not from your fmin in optiGMM
def g(xi):
xi0=[0.1, 0.5, 0.3]
W=matpoids(xi0) # here you call matpoids with
the same values each time
L=Heston(xi[0], xi[1], xi[2])
G=numpy.matrix(conditions(xi[0], xi[1], xi[2], L))
return abs(float(G*(W*(G.T))))
Your code has a lot of loops and looks not very "efficiently"
programmed, but I didn't try to read in detail. Make sure you don't
have redundant calculations inside your objective function for fmin,
otherwise you might have to wait for a long time for your results.
Move calculations outside and put required parameters in
args=() when calling fmin.
with maxiter = 3 in both fmin, the program ends after a few minutes if I do
xi0=[0.1, 0.5, 0.3]
print optiGMM(xi0)
Josef
More information about the SciPy-user
mailing list