solnp | R Documentation |
Nonlinear optimization using augmented Lagrange method (original version)
solnp(
pars,
fun,
eqfun = NULL,
eqB = NULL,
ineqfun = NULL,
ineqLB = NULL,
ineqUB = NULL,
LB = NULL,
UB = NULL,
control = list(),
...
)
pars |
an numeric vector of decision variables (length n). |
fun |
the objective function (must return a scalar). |
eqfun |
an optional function for calculating equality constraints. |
eqB |
a vector of the equality bounds (if eq_fn provided). |
ineqfun |
an optional function for calculating inequality constraints. |
ineqLB |
the lower bounds for the inequality (must be finite) |
ineqUB |
the upper bounds for the inequalitiy (must be finite) |
LB |
lower bounds on decision variables |
UB |
upper bounds on decision variables |
control |
a list of solver control parameters (see details). |
... |
additional arguments passed to the supplied functions (common to all functions supplied). |
The optimization problem solved by csolnp
is formulated as:
\begin{aligned}
\min_{x \in \mathbb{R}^n} \quad & f(x) \\
\text{s.t.} \quad & g(x) = b \\
& h_l \le h(x) \le h_u\\
& x_l \le x \le x_u\\
\end{aligned}
where f(x)
is the objective function, g(x)
is the vector of equality constraints
with target value b
, h(x)
is the vector of inequality constraints bounded
by h_l
and h_u
, with parameter bounds x_l
and x_u
. Internally,
inequality constraints are converted into equality constraints using slack variables
and solved using an augmented Lagrangian approach.
The control is a list with the following options:
This is used as a penalty weighting scaler for infeasibility in the augmented objective function. The higher its value the more the weighting to bring the solution into the feasible region (default 1). However, very high values might lead to numerical ill conditioning or significantly slow down convergence.
Maximum number of major (outer) iterations (default 400).
Maximum number of minor (inner) iterations (default 800).
Relative step size in forward difference evaluation (default 1.0e-7).
Relative tolerance on feasibility and optimality (default 1e-8).
The value of the objective function and the parameters is printed at every major iteration (default 1).
An list with the following slot:
Optimal Parameters.
Indicates whether the solver has converged (0) or not (1 or 2).
Vector of function values during optimization with last one the value at the optimal.
The vector of Lagrange multipliers.
The Hessian of the augmented problem at the optimal solution.
The estimated optimal inequality vector of slack variables used for transforming the inequality into an equality constraint.
The number of function evaluations.
Time taken to compute solution.
Alexios Galanos
{
# From the original paper by Y.Ye
# see the unit tests for more....
# POWELL Problem
fn1 = function(x)
{
exp(x[1] * x[2] * x[3] * x[4] * x[5])
}
eqn1 = function(x){
z1 = x[1] * x[1] + x[2] * x[2] + x[3] * x[3] + x[4] * x[4] + x[5] * x[5]
z2 = x[2] * x[3] - 5 * x[4] * x[5]
z3 = x[1] * x[1] * x[1] + x[2] * x[2] * x[2]
return(c(z1, z2, z3))
}
x0 = c(-2, 2, 2, -1, -1)
}
powell = solnp(x0, fun = fn1, eqfun = eqn1, eqB = c(10, 0, -1))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.