## 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()
Run the code above in your browser using DataLab