Alexander Riess
2011-01-05 14:44:42 UTC
Hi,
i tried to solve a (simple) test-problem
min ( -1.0*x ) on [-1.0,1.0]
using LD_SLSQP on WinXP 64bit with Python 2.6.5 and the latest Nlopt package.
I used the following python input:
# === INPUT === START ===
# -*- coding: latin-1 -*-
import nlopt
from numpy import *
# Global iteration index
I = 0
# min -1.0*x on [-1,1] (Solution: xopt = 1 | fopt = -1.0 )
def f( x, grad ):
global I
I += 1
out = -1.0 * x[0]
grad[0] = -1.0
print str(I).ljust(15),str(x[0]).ljust(15),str(out).ljust(15),str(grad
[0]).ljust(15)
return out
opt = nlopt.opt(nlopt.LD_SLSQP, 1)
opt.set_lower_bounds( [-1.0 ] )
opt.set_upper_bounds( [ 1.0 ] )
opt.set_min_objective(f)
opt.set_xtol_rel(1e-6)
x0 = array([0.0])
print "Algorithm ", opt.get_algorithm_name(), "steps:\n"
print str("Iteration").ljust(15),str("x").ljust(15),str("f(x)").ljust(15),str
("f'(x)").ljust(15)
xOpt = opt.optimize(x0)
print "\nxopt = ", xOpt[0]
print "fopt = ", opt.last_optimum_value()
# === INPUT === END ===
This script results in
# === OUTPUT === START ===
Algorithm Sequential Quadratic Programming (SQP) (local, derivative) steps:
Iteration x f(x) f'(x)
1 0.0 -0 -1.0
2 1.0 -1.0 -1.0
Traceback (most recent call last):
File "minExample.py", line 26, in <module>
xOpt = opt.optimize(x0)
File "C:\Python265\lib\site-packages\nlopt.py", line 231, in optimize
def optimize(*args): return _nlopt.opt_optimize(*args)
RoundoffLimited: NLopt roundoff-limited
# === OUTPUT === END ===
What is the meaning of error-message "NLopt roundoff-limited"?
Why does it occur although x=1.0 is the final solution.
If i use, for example, algorithm LD_MMA with same input, everything works fine:
Algorithm Method of Moving Asymptotes (MMA) (local, derivative) steps:
Iteration x f(x) f'(x)
1 0.0 -0 -1.0
2 0.38196601125 -0.38196601125 -1.0
3 1.0 -1.0 -1.0
4 1.0 -1.0 -1.0
xopt = 1.0
fopt = -1.0
Yours sincerely
Alexander Riess
i tried to solve a (simple) test-problem
min ( -1.0*x ) on [-1.0,1.0]
using LD_SLSQP on WinXP 64bit with Python 2.6.5 and the latest Nlopt package.
I used the following python input:
# === INPUT === START ===
# -*- coding: latin-1 -*-
import nlopt
from numpy import *
# Global iteration index
I = 0
# min -1.0*x on [-1,1] (Solution: xopt = 1 | fopt = -1.0 )
def f( x, grad ):
global I
I += 1
out = -1.0 * x[0]
grad[0] = -1.0
print str(I).ljust(15),str(x[0]).ljust(15),str(out).ljust(15),str(grad
[0]).ljust(15)
return out
opt = nlopt.opt(nlopt.LD_SLSQP, 1)
opt.set_lower_bounds( [-1.0 ] )
opt.set_upper_bounds( [ 1.0 ] )
opt.set_min_objective(f)
opt.set_xtol_rel(1e-6)
x0 = array([0.0])
print "Algorithm ", opt.get_algorithm_name(), "steps:\n"
print str("Iteration").ljust(15),str("x").ljust(15),str("f(x)").ljust(15),str
("f'(x)").ljust(15)
xOpt = opt.optimize(x0)
print "\nxopt = ", xOpt[0]
print "fopt = ", opt.last_optimum_value()
# === INPUT === END ===
This script results in
# === OUTPUT === START ===
Algorithm Sequential Quadratic Programming (SQP) (local, derivative) steps:
Iteration x f(x) f'(x)
1 0.0 -0 -1.0
2 1.0 -1.0 -1.0
Traceback (most recent call last):
File "minExample.py", line 26, in <module>
xOpt = opt.optimize(x0)
File "C:\Python265\lib\site-packages\nlopt.py", line 231, in optimize
def optimize(*args): return _nlopt.opt_optimize(*args)
RoundoffLimited: NLopt roundoff-limited
# === OUTPUT === END ===
What is the meaning of error-message "NLopt roundoff-limited"?
Why does it occur although x=1.0 is the final solution.
If i use, for example, algorithm LD_MMA with same input, everything works fine:
Algorithm Method of Moving Asymptotes (MMA) (local, derivative) steps:
Iteration x f(x) f'(x)
1 0.0 -0 -1.0
2 0.38196601125 -0.38196601125 -1.0
3 1.0 -1.0 -1.0
4 1.0 -1.0 -1.0
xopt = 1.0
fopt = -1.0
Yours sincerely
Alexander Riess