Hi!
On Tue, 2011-01-04 at 20:22 +0100, Yury V. Zaytsev wrote:
> What would be the right way to omit certain bounds? Is using numpy.inf
> OK in such a case instead of +/-HUGE_VAL ? Alternatively, maybe it makes
> sense to add such a constant to the Python bindings...
I have found a way to convert the box constraints definitions used in
SciPy to the format that is expected by NLopt and it seems to work well
for me. I hope that the following snippet can also be added to the wiki
NLopt Python reference:
import numpy as np
param_bounds = ...
# Reformat boundary conditions in a way that they can be
# accepted by NLopt routines
#
lb = np.zeros( (len(param_bounds), ), dtype = np.float64)
ub = np.zeros( (len(param_bounds), ), dtype = np.float64)
for idx, (lbv, ubv) in enumerate(param_bounds):
if lbv is not None:
lb[idx] = lbv
else:
lb[idx] = -np.inf
if ubv is not None:
ub[idx] = ubv
else:
ub[idx] = np.inf
opt.set_lower_bounds(lb)
opt.set_upper_bounds(ub)
Thanks,
--
Sincerely yours,
Yury V. Zaytsev
_______________________________________________
NLopt-discuss mailing list
[email protected]
http://ab-initio.mit.edu/cgi-bin/mailman/listinfo/nlopt-discuss