Previous Up Next

5.45.3  Nonlinear 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. The command takes the following arguments:

nlpsolve returns a list containing the optimal value of the objective and a vector of optimal values of the decision variables.

The objective is minimized by default, unless maximize or maximize=true is specified as an option.

Initial point, if given, does not need to be feasible. Note, however, that the initial value of a variable must not be zero. If the initial point is not given or isn’t feasible, a feasible starting guess is automatically generated. Note that choosing a good initial point is needed for obtaining a correct solution in some cases.

Input syntax for nlpsolve resembles that of Maple’s NLPSolve (entering the objective as a function (univariate case) is not supported, however).

Examples

Input :

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

Output :

[-1.73205080757,[x1=-4.77142305945e-08,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.49340942383]]

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]]

Previous Up Next