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

dmitrey openopt@ukr....
Mon Jul 16 07:52:14 CDT 2007


fdu.xiaojf@gmail.com wrote:
> There are two problems:
>
> 1) In the constrain functions, I expected the value of i to be bounded
> to the specific constrain function, but it doesn't work as I expected.
>
> Here is a demonstration:
> In [14]: a = []
>
> In [15]: for i in range(4):
>      b = lambda : i**2
>      a.append(b)
>     ....:
>     ....:
>
> In [18]: for f in a:
>      print f()
>     ....:
>     ....:
> 9
> 9
> 9
> 9
>
> What I want is that every function in list a should print different
> values. The value of a[0](), a[1](), a[2](), a[3]() should be 0, 1, 4,
> 9.
>
> How to achieve this?
>   
if your b[i] are funcs from x, you should use b = lambda x: x **2 (for 
example)
however, NLP solvers can't handle these constraints as lb-ub bounds 
(fixed float numbers are required), you should describe them as 
non-linear constraints
c[i](x)<=0
HTH, D.


More information about the SciPy-user mailing list