Title: | R Interface to the CSDP Semidefinite Programming Library |
---|---|
Description: | R interface to the CSDP semidefinite programming library. Installs version 6.1.1 of CSDP from the COIN-OR website if required. An existing installation of CSDP may be used by passing the proper configure arguments to the installation command. See the INSTALL file for further details. |
Authors: | Hector Corrada Bravo [aut, cre], Brian Borchers [aut], Don van den Bergh [ctb] |
Maintainer: | Hector Corrada Bravo <[email protected]> |
License: | CPL-1.0 |
Version: | 0.1.57.1 |
Built: | 2024-11-07 02:40:01 UTC |
Source: | https://github.com/hcorrada/rcsdp |
Interface to CSDP semidefinite programming library. The general statement of the primal problem is
with
where
means X is positive
semidefinite,
and all
are symmetric matrices of the same
size and
is a
vector of length
.
The dual of the problem is
where
Matrices and
are assumed to be block diagonal
structured, and must be specified that way (see Details).
csdp(C, A, b, K,control=csdp.control())
csdp(C, A, b, K,control=csdp.control())
C |
A list defining the block diagonal cost matrix |
A |
A list of length |
b |
A numeric vector of length |
K |
Describes the domain of each block of the sdp problem. It is a list with the following elements:
|
control |
Control parameters passed to csdp. See CSDP documentation. |
All problem matrices are assumed to be of block diagonal structure, and must be specified as follows:
If there are nblocks
blocks specified by K
, then
the matrix must be a list with nblocks
components.
If K$type == "s"
then the j
th element of the list must define a symmetric
matrix of size K$size
. It can be an object of class
"matrix"
, "simple_triplet_sym_matrix"
, or a valid
class from the class hierarchy in the "Matrix"
package.
If K$type == "l"
then the j
th element of the list
must be a numeric vector of length K$size
.
This function checks that the blocks in arguments C
and A
agree with
the sizes given in argument K
. It also checks that the
lengths of arguments b
and A
are equal. It does not check for symmetry in the problem data.
csdp_minimal
is a minimal wrapper to the C code underlying csdp
. It assumes that the arguments
sum.block.sizes
, nconstraints
, nblocks
, block.types
, and block.sizes
are provided as if they were created by Rcsdp:::prob.info
and that the arguments C
, A
, and
b
are provided as if they were created by Rcsdp:::prepare.data
. This function may be useful when
calling the csdp functionality iteratively and most of the optimization details stays the same. For example, when the
control file created by Rcsdp:::write.control.file
stays the same across iterations, but it would be recreated
on each iteration by csdp
.
X |
Optimal primal solution |
Z |
Optimal dual solution |
y |
Optimal dual solution |
pobj |
Optimal primal objective value |
dobj |
Optimal dual objective value |
status |
Status of returned solution.
|
Hector Corrada Bravo. CSDP written by Brian Borchers.
Borchers, B.:
CSDP, A C Library for Semidefinite Programming Optimization Methods and Software 11(1):613-623, 1999
http://euler.nmt.edu/~brian/csdppaper.pdf
Lu, F., Lin, Y., and Wahba, G.:
Robust Manifold Unfolding with Kernel Regularization TR
1108, October, 2005.
http://www.stat.wisc.edu/~wahba/ftp1/tr1108rr.pdf
C <- list(matrix(c(2,1, 1,2),2,2,byrow=TRUE), matrix(c(3,0,1, 0,2,0, 1,0,3),3,3,byrow=TRUE), c(0,0)) A <- list(list(matrix(c(3,1, 1,3),2,2,byrow=TRUE), matrix(0,3,3), c(1,0)), list(matrix(0,2,2), matrix(c(3,0,1, 0,4,0, 1,0,5),3,3,byrow=TRUE), c(0,1))) b <- c(1,2) K <- list(type=c("s","s","l"),size=c(2,3,2)) csdp(C,A,b,K) # Manifold Unrolling broken stick example # using simple triplet symmetric matrices X <- matrix(c(-1,-1, 0,0, 1,-1),nc=2,byrow=TRUE); d <- as.vector(dist(X)^2); d <- d[-2] C <- list(.simple_triplet_diag_sym_matrix(1,3)) A <- list(list(simple_triplet_sym_matrix(i=c(1,2,2),j=c(1,1,2),v=c(1,-1,1),n=3)), list(simple_triplet_sym_matrix(i=c(2,3,3),j=c(2,2,3),v=c(1,-1,1),n=3)), list(matrix(1,3,3))) K <- list(type="s",size=3) csdp(C,A,c(d,0),K)
C <- list(matrix(c(2,1, 1,2),2,2,byrow=TRUE), matrix(c(3,0,1, 0,2,0, 1,0,3),3,3,byrow=TRUE), c(0,0)) A <- list(list(matrix(c(3,1, 1,3),2,2,byrow=TRUE), matrix(0,3,3), c(1,0)), list(matrix(0,2,2), matrix(c(3,0,1, 0,4,0, 1,0,5),3,3,byrow=TRUE), c(0,1))) b <- c(1,2) K <- list(type=c("s","s","l"),size=c(2,3,2)) csdp(C,A,b,K) # Manifold Unrolling broken stick example # using simple triplet symmetric matrices X <- matrix(c(-1,-1, 0,0, 1,-1),nc=2,byrow=TRUE); d <- as.vector(dist(X)^2); d <- d[-2] C <- list(.simple_triplet_diag_sym_matrix(1,3)) A <- list(list(simple_triplet_sym_matrix(i=c(1,2,2),j=c(1,1,2),v=c(1,-1,1),n=3)), list(simple_triplet_sym_matrix(i=c(2,3,3),j=c(2,2,3),v=c(1,-1,1),n=3)), list(matrix(1,3,3))) K <- list(type="s",size=3) csdp(C,A,c(d,0),K)
Support for sparse matrices in package Rcsdp
. The class
simple_triplet_sym_matrix
is defined to provide support
for symmetric sparse matrices. It's definition is copied from the package relations
by Kurt
Hornik. Coercion functions from objects of class matrix
and
classes in the Matrix
hierarchy are provided.
simple_triplet_sym_matrix(i,j,v,n=max(c(i,j)),check.ind=FALSE) ## S3 method for class 'matrix' as.simple_triplet_sym_matrix(x,check.sym=FALSE) ## S3 method for class 'simple_triplet_sym_matrix' as.matrix(x,...) ## S3 method for class 'simple_triplet_sym_matrix' as.vector(x,...) .simple_triplet_zero_sym_matrix(n,mode="double") .simple_triplet_diag_sym_matrix(x,n) .simple_triplet_random_sym_matrix(n,occ=.1,nnz=occ*n*(n+1)/2,rfun=rnorm,seed=NULL,...)
simple_triplet_sym_matrix(i,j,v,n=max(c(i,j)),check.ind=FALSE) ## S3 method for class 'matrix' as.simple_triplet_sym_matrix(x,check.sym=FALSE) ## S3 method for class 'simple_triplet_sym_matrix' as.matrix(x,...) ## S3 method for class 'simple_triplet_sym_matrix' as.vector(x,...) .simple_triplet_zero_sym_matrix(n,mode="double") .simple_triplet_diag_sym_matrix(x,n) .simple_triplet_random_sym_matrix(n,occ=.1,nnz=occ*n*(n+1)/2,rfun=rnorm,seed=NULL,...)
i |
Row indices of non-zero entries. |
j |
Column indices of non-zero entries. |
v |
Non-zero entries. |
n |
Size of matrix. |
check.ind |
Checks that arguments |
check.sym |
Checks if matrix object is symmetric. Default |
x |
Object of class |
mode |
Type of zero matrix to create. Default |
occ |
Ratio of occupancy of random sparse matrix. Default |
nnz |
Number of non-zero entries in random sparse matrix. Default corresponds to |
rfun |
Function to generate random entries in sparse matrix. Default |
seed |
Random number generator seed. Set by function |
... |
Arguments passed on to casting functions. |
TO DO
TO DO
Hector Corrada Bravo
TO DO
# TO DO
# TO DO
Utility function to pass control parameters to csdp solver.
csdp.control(axtol = 1e-08, atytol = 1e-08, objtol = 1e-08, pinftol = 1e+08, dinftol = 1e+08, maxiter = 100, minstepfrac = 0.9, maxstepfrac = 0.97, minstepp = 1e-08, minstepd = 1e-08, usexzgap = 1, tweakgap = 0, affine = 0, printlevel = 1, perturbobj = 1, fastmode = 0)
csdp.control(axtol = 1e-08, atytol = 1e-08, objtol = 1e-08, pinftol = 1e+08, dinftol = 1e+08, maxiter = 100, minstepfrac = 0.9, maxstepfrac = 0.97, minstepp = 1e-08, minstepd = 1e-08, usexzgap = 1, tweakgap = 0, affine = 0, printlevel = 1, perturbobj = 1, fastmode = 0)
axtol |
Tolerance for primal feasibility. |
atytol |
Tolerance for dual feasibility. |
objtol |
Tolerance for relative duality gap. |
pinftol |
Tolerance for primal infeasibility. |
dinftol |
Tolerance for dual infeasibility. |
maxiter |
Maximum number of iterations used. |
minstepfrac |
Minimum distance to edge of feasibility region for step. |
maxstepfrac |
Maximum distance to edge of feasibility region for step. |
minstepp |
Failure is declared if primal line search step size is shorter than this parameter. |
minstepd |
Failure is declared if dual line search step size is shorter that this parameter. |
usexzgap |
If 0, then use objective function duality gap. |
tweakgap |
If 1 (and |
affine |
If 1, only use affine primal-dual steps and do not use barrier function. |
printlevel |
If 0, no printing, 1 normal printing, higher values result in more debug printing. |
perturbobj |
Amount of objective permutation used. |
fastmode |
If 1, csdp will be faster but also less accurate. |
Parameters are fully described in CSDP user guide. https://projects.coin-or.org/Csdp/
A list with values for all parameters. Any parameters not passed to function are set to default.
Hector Corrada Bravo, CSDP by Brian Borchers
https://projects.coin-or.org/Csdp/
params <- csdp.control(axtol=1e-6)
params <- csdp.control(axtol=1e-6)
Functions to read and write semidefinite program data and solutions in SDPA format.
readsdpa(file="",verbose=FALSE) writesdpa(C,A,b,K,file="") readsdpa.sol(K,C,m,file="") writesdpa.sol(X,Z,y,K,file="")
readsdpa(file="",verbose=FALSE) writesdpa(C,A,b,K,file="") readsdpa.sol(K,C,m,file="") writesdpa.sol(X,Z,y,K,file="")
file |
The name of the file to read from or write to. |
C |
Block structured cost matrix |
A |
List of block structured constraint matrices |
b |
RHS vector |
K |
Cone specification, as used in |
X |
Block structured primal optimal solution matrix |
Z |
Block structured dual optimal solution matrix |
y |
Dual optimal solution vector |
verbose |
Printout information as problem is read. Passed to CSDP's readsdpa function. Default |
m |
Number of constraints in problem. |
Block structured matrices must be specified as described in
csdp
.
Files read must be in SDPA format (see
http://euler.nmt.edu/~brian/sdplib/FORMAT).
However, these functions don't support comments or grouping characters
(e.g. braces, parentheses) in the block sizes specification.
Function readsdpa
returns a list with elements C,A,b,K
.
Function readsdpa.sol
returns a list with elements
X,Z,y
.
All returned matrices are lists of objects of class simple_triplet_sym_matrix
.
Hector Corrada Bravo
http://euler.nmt.edu/~brian/sdplib/FORMAT
# TO DO
# TO DO