fmincon | R Documentation |
Find minimum of multivariable functions with nonlinear constraints.
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)
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. |
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.
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. |
fmincon
mimics the Matlab function of the same name.
Xianyan Chen for the package NlcOptim.
J. Nocedal and S. J. Wright (2006). Numerical Optimization. Second Edition, Springer Science+Business Media, New York.
fminsearch
, fminunc
,
# 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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.