Problem with NLP in OpenOpt
![](https://secure.gravatar.com/avatar/bc0dfc3af0f1bbdcf04aeb032d22bb9b.jpg?s=120&d=mm&r=g)
Hi, I am using NLP of OpenOpt to solve a NonLinear programming problem. I am using scipy_cobyla solver. The initial point that I have provided is feasible, but I am getting a message: ------------------------------------------message--------------------------------------------------------- starting solver scipy_cobyla (license: BSD ) with problem unnamed solver scipy_cobyla has finished solving the problem unnamed istop: -100 Solver: Time Elapsed = 0.75 CPU Time Elapsed = 0.750110139697 NO FEASIBLE SOLUTION is obtained (max residual = 1.29567664921e-005) ----------------------------------------------------------------------------------------------------------------- All other solvers cannot take h constraint and some others require extra additions. Following is my code: --------------------------------------------------code------------------------------------------------- from scikits.openopt import NLP f = lambda x: 1*x[0] + 7*x[5] + 3*x[10] + 8*x[15] x0 = [1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1] p=NLP(f,x0,maxIter=1e7,maxFunEvals=1e7) h1 = lambda x: x[0]**2 + x[1]**2 + x[2]**2 + x[3]**2 -1 h2 = lambda x: x[0]*x[4]+x[1]*x[5]+x[2]*x[6]+x[3]*x[7] h3 = lambda x: x[0]*x[8]+x[1]*x[9]+x[2]*x[10]+x[3]*x[11] h4 = lambda x: x[0]*x[12]+x[1]*x[13]+x[2]*x[14]+x[3]*x[15] h5 = lambda x: x[4]**2+x[5]**2+x[6]**2+x[7]**2-1 h6 = lambda x: x[4]*x[8]+x[5]*x[9]+x[6]*x[10]+x[7]*x[11] h7 = lambda x: x[4]*x[12]+x[5]*x[13]+x[6]*x[14]+x[7]*x[15] h8 = lambda x: x[8]**2+x[9]**2+x[10]**2+x[11]**2-1 h9 = lambda x: x[8]*x[12]+x[9]*x[13]+x[10]*x[14]+x[11]*x[15] h10 = lambda x: x[12]**2+x[13]**2+x[14]**2+x[15]**2-1 p.h=[h1,h2,h3,h4,h5,h6,h7,h8,h9,h10] r=p.solve('scipy_cobyla') ----------------------------------------------------------------------------------------------------------- The initial value x0 satisfies the constraints hi's but i am still getting that there is no feasible solution. Can anyone help me with this? Thank you
![](https://secure.gravatar.com/avatar/376d02997baf28c5cb67536223e5ae7d.jpg?s=120&d=mm&r=g)
hi, scipy_cobyla yields solution r.ff = -19, r.xf= array([ -1.00000000e+00, -9.80461510e-08, 1.35489449e-05, 5.37394643e-06, 9.80515487e-08, -1.00000000e+00, 4.43639580e-07, -2.00656699e-07, -5.92177803e-07, -2.01266552e-07, -1.00000000e+00, 1.02019241e-07, -1.81972968e-07, 2.91935590e-07, -1.02019165e-07, -1.00000000e+00]) and max constraint = 1.29567664921e-05, that exceeds default p.contol=1e-6 ALGENCAN yields r.ff=-19.0000051782, r.xf = array([ -1.00000000e+00, 3.77969060e-08, 2.50917684e-08, 3.90370801e-08, -3.78516336e-08, -1.00000020e+00, -1.99934148e-08, 3.28135157e-09, -2.50878312e-08, 1.99952165e-08, -9.99999998e-01, 2.31707460e-08, -3.90372694e-08, -3.28049018e-09, -2.27805959e-08, -1.00000048e+00]) and max constraint 9.53914e-07 that is less than default 1e-6 and hence is feasible, no error message (btw time elapsed is 30% less than cobyla). You could just set p.contol=1e-4 and scipy_cobyla will solve your problem well. Regards, D. Dark Wind wrote:
Hi,
I am using NLP of OpenOpt to solve a NonLinear programming problem. I am using scipy_cobyla solver. The initial point that I have provided is feasible, but I am getting a message: ------------------------------------------message--------------------------------------------------------- starting solver scipy_cobyla (license: BSD ) with problem unnamed solver scipy_cobyla has finished solving the problem unnamed istop: -100 Solver: Time Elapsed = 0.75 CPU Time Elapsed = 0.750110139697 NO FEASIBLE SOLUTION is obtained (max residual = 1.29567664921e-005) -----------------------------------------------------------------------------------------------------------------
All other solvers cannot take h constraint and some others require extra additions.
Following is my code: --------------------------------------------------code------------------------------------------------- from scikits.openopt import NLP
f = lambda x: 1*x[0] + 7*x[5] + 3*x[10] + 8*x[15] x0 = [1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]
p=NLP(f,x0,maxIter=1e7,maxFunEvals=1e7)
h1 = lambda x: x[0]**2 + x[1]**2 + x[2]**2 + x[3]**2 -1 h2 = lambda x: x[0]*x[4]+x[1]*x[5]+x[2]*x[6]+x[3]*x[7] h3 = lambda x: x[0]*x[8]+x[1]*x[9]+x[2]*x[10]+x[3]*x[11] h4 = lambda x: x[0]*x[12]+x[1]*x[13]+x[2]*x[14]+x[3]*x[15] h5 = lambda x: x[4]**2+x[5]**2+x[6]**2+x[7]**2-1 h6 = lambda x: x[4]*x[8]+x[5]*x[9]+x[6]*x[10]+x[7]*x[11] h7 = lambda x: x[4]*x[12]+x[5]*x[13]+x[6]*x[14]+x[7]*x[15] h8 = lambda x: x[8]**2+x[9]**2+x[10]**2+x[11]**2-1 h9 = lambda x: x[8]*x[12]+x[9]*x[13]+x[10]*x[14]+x[11]*x[15] h10 = lambda x: x[12]**2+x[13]**2+x[14]**2+x[15]**2-1
p.h=[h1,h2,h3,h4,h5,h6,h7,h8,h9,h10]
r=p.solve('scipy_cobyla') -----------------------------------------------------------------------------------------------------------
The initial value x0 satisfies the constraints hi's but i am still getting that there is no feasible solution.
Can anyone help me with this?
Thank you _______________________________________________ SciPy-user mailing list SciPy-user@scipy.org http://projects.scipy.org/mailman/listinfo/scipy-user
![](https://secure.gravatar.com/avatar/0e24afb59bd1fdf40fb5beed78e71484.jpg?s=120&d=mm&r=g)
On 11/15/07, Dark Wind <darkwind.87@gmail.com> wrote:
The initial value x0 satisfies the constraints hi's but i am still getting that there is no feasible solution.
Can anyone help me with this?
Cobyla is an infeasible method, meaning that in order to identifiy a solution to your problem, it will venture outside of the feasible set. In your example, it wasn't able to reach a feasible solution within the given limits (max number of iterations, tolerances, ...) It is not because their is a feasible point that the code will be able to find a solution; in this case, it got stuck before reaching the feasible set again. You can either re-solve your problem with looser tolerances, which is not very satisfactory, you can re-solve from a different starting point (which doesn't have to be feasible), or you can try another solver (as Dmitrey showed in his response). Dominique
![](https://secure.gravatar.com/avatar/bc0dfc3af0f1bbdcf04aeb032d22bb9b.jpg?s=120&d=mm&r=g)
Thank a lot. Scipy_Cobyla worked, but I am not getting how exactly to install ALGENCAN on windows? Do I need cygwin to install it on windows? thanks On Nov 15, 2007 8:54 AM, Dominique Orban <dominique.orban@gmail.com> wrote:
On 11/15/07, Dark Wind <darkwind.87@gmail.com> wrote:
The initial value x0 satisfies the constraints hi's but i am still getting that there is no feasible solution.
Can anyone help me with this?
Cobyla is an infeasible method, meaning that in order to identifiy a solution to your problem, it will venture outside of the feasible set. In your example, it wasn't able to reach a feasible solution within the given limits (max number of iterations, tolerances, ...) It is not because their is a feasible point that the code will be able to find a solution; in this case, it got stuck before reaching the feasible set again.
You can either re-solve your problem with looser tolerances, which is not very satisfactory, you can re-solve from a different starting point (which doesn't have to be feasible), or you can try another solver (as Dmitrey showed in his response).
Dominique
_______________________________________________ SciPy-user mailing list SciPy-user@scipy.org http://projects.scipy.org/mailman/listinfo/scipy-user
participants (3)
-
Dark Wind
-
dmitrey
-
Dominique Orban