Minimize a function using the Constrained Optimization BY Linear Approximation (COBYLA) method.
Parameters : | func : callable
x0 : ndarray
cons : sequence
args : tuple
consargs : tuple
rhobeg : :
rhoend : :
iprint : {0, 1, 2, 3}
disp : {0, 1, 2, 3}
maxfun : int
|
---|---|
Returns : | x : ndarray
|
Examples
Minimize the objective function f(x,y) = x*y subject to the constraints x**2 + y**2 < 1 and y > 0:
>>> def objective(x):
... return x[0]*x[1]
...
>>> def constr1(x):
... return 1 - (x[0]**2 + x[1]**2)
...
>>> def constr2(x):
... return x[1]
...
>>> fmin_cobyla(objective, [0.0, 0.1], [constr1, constr2], rhoend=1e-7)
Normal return from subroutine COBYLA
NFVALS = 64 F =-5.000000E-01 MAXCV = 1.998401E-14
X =-7.071069E-01 7.071067E-01
array([-0.70710685, 0.70710671])
The exact solution is (-sqrt(2)/2, sqrt(2)/2).