Reputation: 7546
Is there a function in R that does optimization with quadratic constraints?
Reference: http://en.wikipedia.org/wiki/Quadratically_constrained_quadratic_program
Upvotes: 6
Views: 3856
Reputation: 1954
From the CRAN page for the optiSolve
package: https://cran.r-project.org/web/packages/optiSolve/optiSolve.pdf
The following steps are included in solving a constrained optimization problem (cop):
- Define the objective with one of the following functions:
linfun
defines a linear objective function,quadfun
defines a quadratic objective function,ratiofun
defines a rational objective function.- Define the constraints by using the following functions:
lincon
defines linear equality and inequality constraints,quadcon
defines quadratic constraints,ratiocon
defines rational constraints,lbcon
defines lower bounds for the variables,ubcon
defines upper bounds for the variables.- Put the objective function and the constraints together to define the optimization problem:
cop
defines a constrained optimization problem.- Solve the optimization problem:
solvecop
solves a constrained optimization problem.- Check if the solution fulfils all constraints:
validate
checks if the solution fulfils all constraints, and calculates the values of the constraints.
So a quadratically constrained quadratic objective requires you to use quadfun
with quadcon
.
You could also use slsqp
in the nloptr
package. This is one of the methods that optiSolve
can call. https://cran.r-project.org/web/packages/nloptr/nloptr.pdf
Upvotes: 0
Reputation: 16724
All these answer seem to forget one important thing: the solver to use depends heavily on whether the constraint is convex or not. If convex we can use readily available QCP / SOCP solvers (including Cplex and Gurobi). If not convex, we can try a general purpose NLP solver (such as IPOPT). Non-convex global solvers are another possibility, but most are not directly available under R.
Upvotes: 0
Reputation: 217
Yes, there are several software packages that can solve QCQPs.
CLSOCP solves SOCP problems. DWD also solves SOCP problems. Rcsdp solves SDP problems.
Keep in mind that
QCQPs are a subset of SOCPs, which in turn are a subset of SDPs.
There are references online illustrating how to formulate a QCQP as an SOCP or SDP
Upvotes: 3