[SciPy-dev] Multiple constraints in fmin_cobyla

Robert Kern rkern at ucsd.edu
Tue Nov 8 09:10:31 CST 2005

Nils Wagner wrote:
> Robert Kern wrote:
>>Nils Wagner wrote:
>>>Hi all,
>>>How can I apply multiple constraints (e.g. all design variables x \in
>>>\mathds{R}^n should be positive) in fmin_cobyla ?
>>>x_opt=optimize.fmin_cobyla(func, x, cons, args=(), consargs=(),maxfun=1200)
>>>def cons(x):
>>>   ?????
>>The documentation is pretty clear:
>>   cons     -- a list of functions that all must be >=0 (a single function
>>               if only 1 constraint)
> I am aware of the help function :-) 
> Anyway, how do I define a l i s t of functions ?

It's a regular Python list which contains functions. I can't make it any
clearer than that. This is pretty fundamental stuff.

def cons0(x):
  return x[0]

def cons1(x):
  return x[1]

x_opt = optimize.fmin_cobyla(func, x, [cons0, cons1])

Robert Kern
rkern at ucsd.edu

"In the fields of hell where the grass grows high
 Are the graves of dreams allowed to die."
  -- Richard Harter

More information about the Scipy-dev mailing list