fmincon: Minimize Nonlinear Constrained Multivariable Function.

View source: R/fmincon.R

fminconR Documentation

Minimize Nonlinear Constrained Multivariable Function.

Description

Find minimum of multivariable functions with nonlinear constraints.

Usage

  fmincon(x0, fn, gr = NULL, ..., method = "SQP",
          A = NULL, b = NULL, Aeq = NULL, beq = NULL,
          lb = NULL, ub = NULL, hin = NULL, heq = NULL,
          tol = 1e-06, maxfeval = 10000, maxiter = 5000)

Arguments

x0

starting point.

fn

objective function to be minimized.

gr

gradient function of the objective; not used for SQP method.

...

additional parameters to be passed to the function.

method

method options 'SQP', 'auglag'; only 'SQP is implemented.

A, b

linear ineqality constraints of the form A x <= b .

Aeq, beq

linear eqality constraints of the form Aeq x = beq .

lb, ub

bounds constraints of the form lb <= x <= ub .

hin

nonlinear inequality constraints of the form hin(x) <= 0 .

heq

nonlinear equality constraints of the form heq(x) = 0 .

tol

relative tolerance.

maxiter

maximum number of iterations.

maxfeval

maximum number of function evaluations.

Details

Wraps the function solnl in the 'NlcOptim' package. The underlying method is a Squential Quadratic Programming (SQP) approach.

Constraints can be defined in different ways, as linear constraints in matrix form, as nonlinear functions, or as bounds constraints.

Value

List with the following components:

par

the best minimum found.

value

function value at the minimum.

convergence

integer indicating the terminating situation.

info

parameter list describing the final situation.

Note

fmincon mimics the Matlab function of the same name.

Author(s)

Xianyan Chen for the package NlcOptim.

References

J. Nocedal and S. J. Wright (2006). Numerical Optimization. Second Edition, Springer Science+Business Media, New York.

See Also

fminsearch, fminunc,

Examples

# Classical Rosenbrock function
n <- 10; x0 <- rep(1/n, n)
fn <- function(x) {n <- length(x)
    x1 <- x[2:n]; x2 <- x[1:(n - 1)]
    sum(100 * (x1 - x2^2)^2 + (1 - x2)^2)
}
# Equality and inequality constraints
heq1 <- function(x) sum(x)-1.0
hin1 <- function(x) -1 * x
hin2 <- function(x) x - 0.5
ub <- rep(0.5, n)

# Apply constraint minimization
res <- fmincon(x0, fn, hin = hin1, heq = heq1)
res$par; res$value

pracma documentation built on Nov. 10, 2023, 1:14 a.m.