Solve quadratically constrained optimization problem with CPLEX
Solve quadratically constrained optimization problem with CPLEX
Interface to CPLEX solvers for quadratically constrained linear, quadratic, and mixed-integer programs. The general statement of the problem is [REMOVE_ME]min21x′Qx+c′xmin0.5x′Qx+c′x[REMOVEME2]
If Q==NULL then the problem is linear, if any value of the vtype
argument is "B" or "I" then the problem is a mixed-integer program. The control argument is used to set CPLEX's many parameters. See details. The objsense determines if the problem is a maximization or minimization problem. The sense argument is used to set the constraint directions.
Description
Interface to CPLEX solvers for quadratically constrained linear, quadratic, and mixed-integer programs. The general statement of the problem is
If Q==NULL then the problem is linear, if any value of the vtype
argument is "B" or "I" then the problem is a mixed-integer program. The control argument is used to set CPLEX's many parameters. See details. The objsense determines if the problem is a maximization or minimization problem. The sense argument is used to set the constraint directions.
Rcplex_solve_QCP(cvec, Amat, bvec, Qmat =NULL, QC, lb =0, ub =Inf, sense ="L", objsense = c("min","max"), vtype
=NULL, n =1, control = list())
Arguments
cvec: The linear coefficient of the objective function
Amat: The constraint matrix (requires ncol(Amat)==length(cvec))
bvec: The constraints right-hand side (requires length(bvec)==nrow(Amat))
Qmat: The quadratic coefficient of the objective function. If NULL the problem is linear. If not NULL, it must be a symmetric positive semidefinite matrix of size length(cvec) by length(cvec). Default NULL
QC: a list with three elements: QC, dir, and b. The element QC is a list with the quadratic part Q, a matrix, and the linear part of the constraint L, a numeric (currently nonzero values are not supported). dir has the same meaning as argument sense and b as bvec.
lb: Lower bound on the problem variables. If length(lb)==1 then lb is the lower bound of all variables. Otherwise, length(lb)==length(cvec). Set lb=-Inf to have no lower bound. Default 0.
ub: Upper bound on the problem variables. See lb for further details. Default Inf.
control: A list of CPLEX parameters. See Details
objsense: Either "max" or "min", determines the optimization direction. Default "min"
sense: The direction of the inequality in each constraint. If length(sense)==1 then the same value is taken for each constraint. Can be one of "L" (less than or equal), "G" (reater than or equal) or "E" (equal). Requires length(sense)==length(bvec). Default "L".
vtype: Determines the type of each problem variable. Can be one of "C" (continuous), "I" (integer) or "B" (binary). If length(vtype)==1 the same value is taken for all variables. Otherwise, requires length(vtype)==length(ctype). Default "C".
n: Determines the maximal number of solutions the solver should return in case of an MIP with more than one solution at optimum. If CPLEX should search for "all" solutions then n has to be set to NA. In CPLEX this is also called populating the solution pool. The parameters solnpoolagap, solnpoolgap, and solnpoolintensity influence the search for multiple solutions (see also the control
argument below for details). Available from CPLEX 11.0 on. Rcplex()
raises a warning if an older version of CPLEX is used and n>1. Default 1.
Details
See function link[Rcplex]{Rcplex}() for more information about sparse matrix representation and control arguments.
Returns
Returns a list with the following components, or, if n > 1 a list of length equal to the number of optimal solutions containing the following components for each solution: - xopt: Values of problem variables at optimum.
obj: Value of objective function at optimum.
status: Solution status. See CPLEX documentation for meaning of status codes.
extra: List with extra information about solution with components
slack:: Values of slack variables for inequality constraints.
nodecnt:: (IF MIP PROBLEM) Number of nodes in the search tree evaluated
lambda:: (IF NOT MIP PROBLEM) Values of dual variables at optimum
References
IBM ILOG CPLEX Optimization Studio documentation
Author(s)
Hector Corrada Bravo and Stefan Theussl
See Also
Rcplex.close, optim
Examples
## objective functionc <- c(1,2,3)Q <- matrix(c(-33,6,0,6,-22,11.5,0,11.5,-11), nrow =3)## constraints## linear partA <- matrix(c(-1,1,1,-3,1,1), nrow =2)dir <- c("L","L")b <- c(20,30)## quadratic partQC <- list(QC = list(Q = list(diag(1, nrow =3)), L =NULL), dir ="L", b =1)## boundsub <- c(40,Inf,Inf)## solveres <- Rcplex_solve_QCP(c,A, b, Q, ub = ub, QC = QC, sense = dir, objsense ="max")print(res)## solve MIQCPres <- Rcplex_solve_QCP(c, A, b, Q, ub = ub, QC = QC, sense = dir, objsense ="max", vtype = c("C","I","C"))## quadratic and linear partQC <- list(QC = list(Q = list(diag(1, nrow =3)), L = list(c(3,4,-3))), dir ="L", b =1)## solveres <- Rcplex_solve_QCP(c,A, b, Q, ub = ub, QC = QC, sense = dir, objsense ="max")print(res)Rcplex.close()