Rcplex_solve_QCP | R Documentation |
Interface to CPLEX solvers for quadratically constrained linear, quadratic, and mixed-integer programs. The general statement of the problem is
\min \frac{1}{2}x'Qx + c'x
\mathrm{s.t} Ax \leq b
\mathrm{and} a_i'x + x'Q_ix \leq r_i for i=1,\ldots,q
lb \leq x \leq ub
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())
cvec |
The linear coefficient of the objective function |
Amat |
The constraint matrix (requires |
bvec |
The constraints right-hand side (requires |
Qmat |
The quadratic coefficient of the objective function. If
|
QC |
a list with three elements: |
lb |
Lower bound on the problem variables. If
|
ub |
Upper bound on the problem variables. See |
control |
A list of CPLEX parameters. See *Details* |
objsense |
Either |
sense |
The direction of the inequality in each
constraint. If |
vtype |
Determines the type of each problem variable. Can be one
of |
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
|
See function link[Rcplex]{Rcplex}()
for more information about
sparse matrix representation and control arguments.
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
|
Hector Corrada Bravo and Stefan Theussl
IBM ILOG CPLEX Optimization Studio documentation
Rcplex.close
, optim
## objective function
c <- c(1, 2, 3)
Q <- matrix(c(-33, 6, 0, 6, -22, 11.5, 0, 11.5, -11), nrow = 3)
## constraints
## linear part
A <- matrix(c(-1, 1, 1, -3, 1, 1), nrow = 2)
dir <- c("L", "L")
b <- c(20, 30)
## quadratic part
QC <- list(QC = list(Q = list(diag(1, nrow = 3)), L = NULL), dir = "L", b = 1)
## bounds
ub <- c(40, Inf, Inf)
## solve
res <- Rcplex_solve_QCP(c,A, b, Q, ub = ub, QC = QC, sense = dir, objsense = "max")
print(res)
## solve MIQCP
res <- Rcplex_solve_QCP(c, A, b, Q, ub = ub, QC = QC,
sense = dir, objsense = "max", vtype = c("C", "I", "C"))
## quadratic and linear part
QC <- list(QC = list(Q = list(diag(1, nrow = 3)), L = list(c(3,4,-3))), dir = "L", b = 1)
## solve
res <- Rcplex_solve_QCP(c,A, b, Q, ub = ub, QC = QC, sense = dir, objsense = "max")
print(res)
Rcplex.close()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.