ECOS_csolve: Solve a conic optimization problem In ECOSolveR: Embedded Conic Solver in R

Description

The function ECOS_csolve is a wrapper around the ecos csolve C function. Conic constraints are specified using the G and h parameters and can be NULL and zero length vector respectively indicating an absence of conic constraints. Similarly, equality constraints are specified via A and b parameters with NULL and empty vector values representing a lack of such constraints. At most one of the pair (G , h) or (A, b) is allowed to be absent.

Usage

 1 2 3 ECOS_csolve(c = numeric(0), G = NULL, h = numeric(0), dims = list(l = integer(0), q = NULL, e = integer(0)), A = NULL, b = numeric(0), bool_vars = integer(0), int_vars = integer(0), control = ecos.control()) 

Arguments

 c the coefficients of the objective function; the length of this determines the number of variables n in the problem. G the inequality constraint sparse matrix in compressed column format, e.g. dgCMatrix-class. Can be NULL h the right hand size of the inequality constraint. Can be empty numeric vector. dims is a list of three named elements: dims['l'] an integer specifying the dimension of positive orthant cone, dims['q'] an integer vector specifying dimensions of second-order cones, dims['e'] an integer specifying the number of exponential cones A the optional equality constraint sparse matrix in compressed column format, e.g. dgCMatrix-class. Can be NULL b the right hand side of the equality constraint, must be specified if A is. Can be empty numeric vector. bool_vars the indices of the variables, 1 through n, that are boolean; that is, they are either present or absent in the solution int_vars the indices of the variables, 1 through n, that are integers control is a named list that controls various optimization parameters; see ecos.control.

Value

a list of 8 named items

x

primal variables

y

dual variables for equality constraints

s

slacks for Gx + s <= h, s \in K

z

dual variables for inequality constraints s \in K

infostring

gives information about the status of solution

retcodes

a named integer vector containing four elements

exitflag

0=OPTIMAL, 1=PRIMAL INFEASIBLE, 2=DUAL INFEASIBLE, -1=MAXIT REACHED

iter

the number of iteration used

mi_iter

the number of iterations for mixed integer problems

numerr

a non-zero number if a numeric error occurred

summary

a named numeric vector containing

pcost

value of primal objective

dcost

value of dual objective

pres

primal residual on inequalities and equalities

dres

dual residual

pinf

primal infeasibility measure

dinf

dual infeasibility measure

pinfres

primal infeasibility residual

dinfres

dual infeasibility residual

gap

duality gap

relgap

relative duality gap

r0

Unknown at the moment to this R package maintainer.

timing

a named numeric vector of timing information consisting of

runtime

the total runtime in ecos

tsetup

the time for setup of the problem

tsolve

the time to solve the problem

Details

A call to this function will solve the problem: minimize c^Tx, subject to Ax = b, and h - G*x \in K.

Variables can be constrained to be boolean (1 or 0) or integers. This is indicated by specifying parameters bool_vars and/or int_vars respectively. If so indicated, the solutions will be found using a branch and bound algorithm.

Examples

  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 ## githubIssue98 G <- local({ Gpr <- c(0.416757847405471, 2.136196095668454, 1.793435585194863, -1., 0.056266827226329, -1.640270808404989, 0.841747365656204, -1., 0.416757847405471, 2.136196095668454, 1.793435585194863, -1., 0.056266827226329, -1.640270808404989, 0.841747365656204, -1., -1.) Gjc <- as.integer(c(0, 4, 8, 12, 16, 17)) Gir <- as.integer(c(0, 1, 2, 7, 0, 1, 2, 8, 3, 4, 5, 9, 3, 4, 5, 10, 6)) Matrix::sparseMatrix(i = Gir, p = Gjc, x = Gpr, index1 = FALSE) }) print(G) 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 = G, h = h, dims = dims, A = NULL, b = numeric(0)) ## A larger problem using saved data for the large matrices MPC01 <- readRDS(system.file("misc", "MPC01.rds", package="ECOSolveR")) retval <- ECOS_csolve(c = MPC01$c, G = MPC01$G, h = MPC01$h, dims = MPC01$dims) retval$retcodes retval$infostring retval\$summary 

ECOSolveR documentation built on May 30, 2017, 5:12 a.m.