Search code examples
cnlopt

Fixed interval constraints in nlopt


I am trying to implement an optimiser for a set of black-box functions (neural networks) for which I do not have a derivative (that's probably not relevant for this question though). I want to use nlopt so I've been reading through the tutorial on their website, which implements a trivial objective function with Non linear constraints.

In their example, the constraint function is a set of continuously differentiable polynomials. The constraint arguably is the objective function in this example, which made the whole tutorial a bit confusing for a non-mathsy type such as myself. In my case I just want to impose fixed bounds on each dimension.

How do impose the fixed interval [a,b] on each dimension (and for an arbitrary number of dimensions) in nlopt?

I'm conscious of the fact that the constraint function in the tutorial also includes a derivative, and I'm not sure how or if I need to provide a derivative for my fixed interval constraint function.


Solution

  • I should have read the whole tutorial...

    nlopt provides the following functions specifically for the purpose of imposing fixed constraints:

    nlopt_set_lower_bounds nlopt_set_upper_bounds