[SciPy-User] how to use properly the function fmin () to scipy.optimize

javi fralosal at ei.upv.es
Tue Mar 13 09:02:11 EDT 2012


Hello, I have been trying to find the right way to use the function fmin () to
use downhill simplex.

Mainly I have a problem with that is that the algorithm converges to good
effect, ie as a solution with a value next to zero.

To test the performance of the algorithm I used the following example:

def minimize (x):

         min = x [0] + x [1] + x [2] + x [3]
         return min

In which given a vector x would want to obtain the values ​​of its elements that
when added give the minimum possible value.

To do this use the following function call:

solution = fmin (minimize, x0 = array ([1, 2, 3, 4]), args = "1", xtol = 0.21, =
0.21 ftol, full_output = 1)

print "value parameters", solution [0], "\ n"

and I get the following results:

       Optimization terminated successfully.
                Current function value: 10.000000
                Iterations: 1
                Function evaluations: 5
      
       value of the parameters: [1. 2. 3. 4.]

As you can see the solution is VERY BAD, and I understand that due to large
values ​​of ftol and xtol that I gave it converges very quickly and gives a
small value.

Now, for that is a better result, ie, better than the 10 found understand that I
must decrease and ftol xtol values​​, but in doing so I get:


"Warning: Maximum number of function evaluations exceeded Has Been."

Where I understand the algorithm before converging has made excessive calls to
the function "minimize".

Could you tell me what the correct use of the parameters ftol and  xtol to find
a good minimum next to 0?. Sshould generally be used in subsequent cases of ftol
and xtol values​​?, They differ?.

A greeting and thank you very much.




More information about the SciPy-User mailing list