Local derivative-free optimization: nlpsolve

### 6.53.3 Local derivative-free optimization: nlpsolve

nlpsolve computes the optimum of a (not necessarily differentiable) nonlinear (multivariate) objective function, subject to a set of nonlinear equality and/or inequality constraints, using the COBYLA algorithm.

- nlpsolve takes the following arguments:
  - obj, an expression to optimize.
  - Optionally, constr, a list of equality and inequality constraints.
  - Optionally, bd, a sequence of variable boundaries x=a..b.
  - Optionally, opt, a sequence of options which may be one of:
    - maximize=bool, where bool can be true or false. Just maximize is equivalent to maximize=true. (By default, maximize=false.)
    - nlp_initialpoint=pt, where pt is a point given in the form [x=x0,y=y0,…]. pt does not have to be feasible, but it must not be zero. If none is given or the given point is not feasible, then a feasible starting guess is automatically generated. Note that choosing a good initial point is required for obtaining a correct solution in some cases.
    - nlp_iterationlimit=n for an integer n.
    - assume=nlp_nonnegative
    - nlp_precision=є for some є > 0.
- nlpsolve(obj ⟨constr,bd,opt⟩) returns a list [optobj,optdec], where optobj is the optimal value of obj and optobj is a list of of optimal values of the decision variables.

Examples.

- Input:
  nlpsolve(ln(1+x1^2)-x2,[(1+x1^2)^2+x2^2=4])
  Output:

  ⎡ ⎣ | −1.73205080757, | ⎡ ⎣ | x1=−4.77142305945×10−8,x2=1.73205080757 | ⎤ ⎦ | ⎤ ⎦

- Input:
  nlpsolve(-x1*x2*x3,[72-x1-2x2-2x3>=0],x1=0..20,x2=0..11,x3=0..42)
  Output:

  ⎡ ⎣ | −3300.0, | ⎡ ⎣ | x1=20.0,x2=11.0,x3=15.0 | ⎤ ⎦ | ⎤ ⎦

- Input:

  nlpsolve(x^3+2x*y-2y^2,x=-10..10,y=-10..10,
  nlp_initialpoint=[x=3,y=4],maximize)

  Output:

  ⎡ ⎣ | 1050.0, | ⎡ ⎣ | x=10.0,y=4.99999985519 | ⎤ ⎦ | ⎤ ⎦

- Input:
  nlpsolve(sin(x)/x,x=1..30)
  Output:

  ⎡ ⎣ | −0.217233628211, | ⎡ ⎣ | x=4.49340946198 | ⎤ ⎦ | ⎤ ⎦

- Input:

  nlpsolve(2-1/120*x1*x2*x3*x4*x5,
  [x1<=1,x2<=2,x3<=3,x4<=4,x5<=5],assume=nlp_nonnegative)

  Output:

  ⎡ ⎣ | 1.0, | ⎡ ⎣ | x1=1.0,x2=2.0,x3=3.0,x4=4.0,x5=5.0 | ⎤ ⎦ | ⎤ ⎦