[SciPy-user] Questions about scipy.optimize.fmin_cobyla

fdu.xiaojf@gmai... fdu.xiaojf@gmai...
Mon Jul 16 08:25:42 CDT 2007


Hi dmitrey,

Thank you so much for your kindness!

dmitrey wrote:

 > so if you have only x >= 0 constraints, it's better to use tnc or
 > openopt lincher than fmin_cobyla

Unfortunately, the function I want to minimize still has equality
constraints. The reason why I chose cobyla is that cobyla can handle
inequality and equality constraints, and it doesn't require derivate
information.

 >
 > if you have to use cobyla anyway, try this:
 >
 >
 > a = []
 > for i in range(5):
 >     a.append(lambda x: x[i]**2)
 > x = [1,2,3,4,5]
 > for i in range(5):
 >     print a[i](x)
 >
 >  1
 > 4
 > 9
 > 16
 > 25

The constrain functions are called by fmin_cobyla, so I couldn't make
sure "for i ...." are  used when the constrain functions are called.

In your example, if I use "for j in range(5): print a[j](x)", it will
not work as expected.

 >
 > If you will replace xi by exp(xi), don't forget to replace lb[i]=0 by
 > lb[i]=1

I'm trying this.
 >
 > HTH, d


More information about the SciPy-user mailing list