## githubIssue98
cat("Basic matrix interface\n")
Gmat <- matrix(c(0.416757847405471, 2.13619609566845, 1.79343558519486, 0, 0,
0, 0, -1, 0, 0, 0, 0.056266827226329, -1.64027080840499, 0.841747365656204,
0, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0.416757847405471, 2.13619609566845,
1.79343558519486, 0, 0, 0, -1, 0, 0, 0, 0, 0.056266827226329, -1.64027080840499,
0.841747365656204, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, -1, 0, 0, 0, 0), ncol = 5L)
c <- as.numeric(c(0, 0, 0, 0, 1))
h <- as.numeric(c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))
dims <- list(l = 6L, q = 5L, e = 0L)
ECOS_csolve(c = c, G = Gmat, h = h,
dims = dims,
A = NULL, b = numeric(0))
cat("Simple Triplet Matrix interface, if you have package slam\n")
if (requireNamespace("slam")) {
ECOS_csolve(c = c, G = slam::as.simple_triplet_matrix(Gmat), h = h,
dims = dims,
A = NULL, b = numeric(0))
}
if (requireNamespace("Matrix")) {
ECOS_csolve(c = c, G = Matrix::Matrix(Gmat), h = h,
dims = dims,
A = NULL, b = numeric(0))
}
## Larger problems using saved data can be found in the test suite.
## Here is one
if (requireNamespace("Matrix")) {
MPC01 <- readRDS(system.file("testdata", "MPC01_1.RDS", package = "ECOSolveR"))
G <- Matrix::sparseMatrix(x = MPC01$Gpr, i = MPC01$Gir, p = MPC01$Gjc,
dims = c(MPC01$m, MPC01$n), index1 = FALSE)
h <- MPC01$h
dims <- lapply(list(l = MPC01$l, q=MPC01$q, e=MPC01$e), as.integer)
retval <- ECOS_csolve(c = MPC01$c, G=G, h = h, dims = dims, A = NULL, b = NULL,
control = ecos.control(verbose=1L))
retval$retcodes
retval$infostring
retval$summary
}
Run the code above in your browser using DataLab