![](https://secure.gravatar.com/avatar/612395b66b3e7959997007b342b3688a.jpg?s=120&d=mm&r=g)
Nils Wagner wrote:
Hi all,
I would like to solve a constrained optimization problem with scipy. As far as I understand it there exists two possible functions for my problem in scipy - fmin_tnc and fmin_l_bfgs_b.
The problem is given by
min f(x)
subjected to
\theta_1 \le theta \le theta_2
and
r_1 \le r \le r_2
where x is a vector \in \mathds{R}^{2n+1}.
theta is the last entry in x.
r = \| x[:2*n] \| = linalg.norm(x[:2*n])
How do I specify the bounds for my problem ? I mean it's easy to define the bounds for the l a s t parameter (\theta) but I am at a loss how to formulate the bounds for x[0],...,x[2n-1] s e p a r a t e l y.
bounds -- a list of (min, max) pairs for each element in x, defining the bounds on that parameter. Use None for one of min or max when there is no bound in that direction
Any hint would be appreciated.
Nils
_______________________________________________ SciPy-user mailing list SciPy-user@scipy.org http://projects.scipy.org/mailman/listinfo/scipy-user
Sorry for replying to myself. I guess I can use fmin_cobyla with the following constraints cons1= x[-1]-\theta_1 cons2=\theta_2-x[-1] cons3=linalg.norm(x[:2*n])-r_1 cons4=r_2-linalg.norm(x[:2*n]) Is that correct ? Is there a better way to implement the problem ? Nils