![](https://secure.gravatar.com/avatar/612395b66b3e7959997007b342b3688a.jpg?s=120&d=mm&r=g)
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
![](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
![](https://secure.gravatar.com/avatar/66691af588236ceb792d3ae15e964492.jpg?s=120&d=mm&r=g)
Thanks Nils, yes, fmin_cobyla can handle the general constraints, however I also still don't know how to write the constraints: "a list of callable function" cons and there are no examples in this optimize module!, I also appreciate any helps from any of you. for fmin_l_bfgs_b, see examples in this module, I have run this module without difficulty including lower and upper boundary for each design variables to solve my problems. Xiaojian On 9/15/06, Nils Wagner <nwagner@iam.uni-stuttgart.de> wrote:
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
_______________________________________________ SciPy-user mailing list SciPy-user@scipy.org http://projects.scipy.org/mailman/listinfo/scipy-user
![](https://secure.gravatar.com/avatar/612395b66b3e7959997007b342b3688a.jpg?s=120&d=mm&r=g)
On Fri, 15 Sep 2006 08:59:09 -0700 "Xiaojian Wang" <wangxj.uc@gmail.com> wrote:
Thanks Nils,
yes, fmin_cobyla can handle the general constraints, however I also still don't know how to write the constraints: "a list of callable function" cons and there are no examples in this optimize module!, I also appreciate any helps from any of you.
for fmin_l_bfgs_b, see examples in this module, I have run this module without difficulty including lower and upper boundary for each design variables to solve my problems.
Xiaojian
On 9/15/06, Nils Wagner <nwagner@iam.uni-stuttgart.de> wrote:
Hi all,
I would like to solve a constrained optimization
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
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
Nils Wagner wrote: problem with scipy. parameter (\theta) but 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
_______________________________________________ SciPy-user mailing list SciPy-user@scipy.org http://projects.scipy.org/mailman/listinfo/scipy-user
You can use something like this def cons1(x): return x[-1]-theta_1 def cons2(x): return theta_2-x[-1] def cons3(x): return linalg.norm(x[:2*n])-r_1 def cons4(x): return r_2-linalg.norm(x[:2*n]) xopt = optimize.fmin_cobyla(F_p,x_0,cons=(cons1,cons2,cons3,cons4,),rhobeg=1.0,rhoend=1.e-7,maxfun=9000) Nils
participants (2)
-
Nils Wagner
-
Xiaojian Wang