# Constrained Optimization library for equality and inequality constraints

Any recommendations for choice of a constrained optimization library suitable for my optimization function? I am minimizing a i) non-linear function with linear equality and inequality constraints, and ii) have available the gradient and the hessian of the function.

If it helps, the function I am minimizing is the Kullback-Liebler divergence.

constrOptim only deals with inequality constraints. Quadprog handles quadratics. Trust does not support constraints. So the KL divergence does not fit into these solutions.

There are quite a few solutions on the R Cran Task page for Optimization. Iam able to perform the optimization in MATLAB using the fmincon() function which seems to use an interior-point or a trust-region-reflective. Ideally there is a library that is well-suited to the problem defined.

• Are the constraints linear? Commented Dec 14, 2011 at 2:05
• @cardinal - yes - the constraints are linear Commented Dec 14, 2011 at 2:12
• So, if your equality constraints are $A x = b$, at least a work-around for constrOptim would be to include both $A x \leq b$ and $A x \geq b$. No? Commented Dec 14, 2011 at 2:14
• That is very clever. I will explore this and see how it performs. You should consider posting this as an answer. I'll keep the question open for a couple days to see what other tools are available Commented Dec 14, 2011 at 2:55
• @cardinal trick doesn't help for interior point method, like the one of constrOptim, since the method need a starting point into the interior of the feasible region -not on the border Commented Oct 2, 2014 at 8:08

Both packages, alabama and Rsolnp, contain "[i]mplementations of the augmented lagrange multiplier method for general nonlinear optimization" --- as the optimization task view says --- and are quite reliable and robust. The can handle equality and inequality constraints defined as (nonlinear) functions again.

I have worked with both packages. Sometimes, constraints are a bit easier to formulate with Rsolnp, whereas alabama appears to be a bit faster at times.

There is also the package Rdonlp2 that relies on an external and in the optimization community well-known software library. Unfortunately, its license status is a bit uncertain at the moment.

• Just want to add one property of Alabama inequality constraints which I found today. If your inequality constraints creates an infeasible region, then the code runs without any warning/error messages and takes the mean value of boundaries as fixed value of the parameter. For example if you have x > 6 and x <4, then the solution will provide a solution with x = 5 without any warning. Commented Apr 3, 2017 at 11:13
• It seems this answer is still visited and read. Therefore, I would like to add that there is a new package NlcOptim (since 2015). It solves optimization problems with nonlinear objective and constraint functions, where nonlinear equality and inequality constraints are allowed. I do use it regularly. Commented Jun 19, 2019 at 20:11