1
# Interface to Constrained Optimization By Linear Approximation
3
from __future__ import nested_scopes
6
def fmin_cobyla(func, x0, cons, args=(), consargs=None, rhobeg=1.0, rhoend=1e-4,
7
iprint=1, maxfun=1000):
9
Minimize a function using the Contrained Optimization BY Linear Approximation
14
func -- function to minimize. Called as func(x, *args)
16
x0 -- initial guess to minimum
18
cons -- a list of functions that all must be >=0 (a single function
21
args -- extra arguments to pass to function
23
consargs -- extra arguments to pass to constraints (default of None means
24
use same extra arguments as those passed to func). Use () for no
27
rhobeg -- reasonable initial changes to the variables
29
rhoend -- final accuracy in the optimization (not precisely guaranteed)
31
iprint -- controls the frequency of output: 0 (no output),1,2,3
33
maxfun -- maximum number of function evaluations.
41
err = "cons must be a list of callable functions or a single"\
44
if isinstance(cons, list):
47
if not callable(thisfunc):
53
raise TypeError, "cons must be a list of callable functions or a single"\
62
for constraints in cons:
63
con[k] = constraints(x,*consargs)
67
xopt = _cobyla.minimize(calcfc, m=m, x=x0,rhobeg=rhobeg,rhoend=rhoend,iprint=iprint,