[Numpy-discussion] [ANN] NLopt, a nonlinear optimization library
Steven G. Johnson
stevenj at alum.mit.edu
Tue Jun 29 13:27:19 EDT 2010
Sebastian Haase wrote:
> this sounds like the library I was looking for.
> Would you mind reading my post
> [SciPy-User] Global Curve Fitting of 2 functions to 2 sets of data-curves
> http://mail.scipy.org/pipermail/scipy-user/2010-June/025674.html
> ?
> I got many interesting answers, where apparently the agreement was to
> "just write a proper error-function".
> Regarding constraints, the suggestion was to "manually" substitute my
> variables with combinations of exp()-expressions that would implicitly
> take care of the r_i>0 and 0<A_j<1 constraints.
> Question: Does NLopt allow to do those optimizations in a more direct,
> less "manual" and still easy-to-use way ?
Hi Sebastian,
Yes, NLopt allows you to directly enter nonlinear constraints and it
will take care of satisfying them (if possible). (How it solves the
constrained problem depends on what algorithm you select, but this is
taken care of internally.)
See the NLopt manual, which includes a nonlinearly constrained problem
in its tutorial, and describes which of its algorithms support nonlinear
constraints.
I would certainly recommend against just adding a fixed penalty
function: if you make the penalty too steep then you kill the
convergence rate of any algorithm, and if you make the penalty too
shallow then it may converge to an unfeasible point (a point violating
your constraints). (There are proper ways to implement penalty
functions, but it generally involves repeatedly reoptimizing while
gradually increasing the penalties until a feasible point is obtained.
e.g. this is done automatically for you by the "augmented Lagrangian"
algorithm included in NLopt. But penalties aren't the only way to
implement nonlinear constraints, and NLopt also has algorithms that
include constraints more directly.)
Regards,
Steven G. Johnson
PS. Regarding your post, I basically agree with your respondents that
you have to decide what error function you want to minimize. That is,
you presumably have some error measure for each fitted dataset -- how
you do you want to combine them? (If you don't combine them, you have a
"multi-objective" optimization problem, which in general has no
solution.) e.g. do you want to minimize the sum of the squared errors
over all datasets, or some weighted variant thereof, or...? Anyway, a
library like NLopt doesn't know anything about your problem except the
objective function (and possibly constraint functions) that you specify,
so those are up to you.
More information about the NumPy-Discussion
mailing list