Skip to content
Snippets Groups Projects
Commit 32911000 authored by Claus Jonathan Fritzemeier's avatar Claus Jonathan Fritzemeier
Browse files

initial commit of version 1.2.6

parent 9cb9926f
No related branches found
No related tags found
No related merge requests found
# ignore pdf files
*.pdf
# ignore build r package:
sybil_*.tar.gz
Package: clpAPI
Type: Package
Title: R Interface to C API of COIN-OR Clp
Version: 1.2.6
Date: 2013-10-26
Authors@R: c(person("Gabriel", "Gelius-Dietrich", role = c("aut", "cre"), email = "geliudie@uni-duesseldorf.de"))
Depends: R (>= 2.6.0)
Imports: methods
Description: R Interface to C API of COIN-OR Clp, depends on COIN-OR Clp Version >= 1.12.0
SystemRequirements: COIN-OR Clp (>= 1.12.0)
License: GPL-3
LazyLoad: yes
Collate: generics.R clp_ptrClass.R clp.R clpAPI.R zzz.R
Packaged: 2013-10-26 16:15:58 UTC; gabriel
Author: Gabriel Gelius-Dietrich [aut, cre]
Maintainer: Gabriel Gelius-Dietrich <geliudie@uni-duesseldorf.de>
NeedsCompilation: yes
Repository: CRAN
Date/Publication: 2013-10-26 19:08:53
MD5 0 → 100644
aed7f2b6574917b3d0ca688429b99065 *DESCRIPTION
5daa14e3ff7a2270d741a3e781a8f987 *NAMESPACE
00cd81844a47cfe6b42a5b2139d64c78 *R/clp.R
3ce8923439c8c1b6b9d5a5b73eedc8c1 *R/clpAPI.R
9732448f604c10e494f1786df44f0a62 *R/clp_ptrClass.R
c28b18176d42d49363a806c626389214 *R/generics.R
b92329cf50a482f5a473bcce316e5669 *R/zzz.R
f7372a571a1b0690bfaf3bdb7b88c829 *build/vignette.rds
661848692617a4273bc42814dec96764 *cleanup
011ce44bdb6c566923d3f8473620a42a *configure
c2209e4bff9ea976398c3587f4e13c38 *configure.ac
d41d8cd98f00b204e9800998ecf8427e *configure.win
ee6ae0f4273773b869f135cdc41a6ef1 *inst/INSTALL
eb15b4cad6eef59a4ae92d53a44c24d0 *inst/NEWS.Rd
e236783da143c26d795f14dd8021f981 *inst/README
3952b2754f409d0fe85d390817441d03 *inst/c2r.map
1e514bbcc73c999233af23fb78ae0f9a *inst/doc/clpAPI.R
f932b68cee56631e482786a0e888fe45 *inst/doc/clpAPI.Rnw
e9350415f9796cedd430ddbae49d06e8 *inst/doc/clpAPI.pdf
6bb5e918e9243fc4d2404ae81576bf20 *man/addColsCLP.Rd
3d7fc83d95f88caacb91ba6a894db11a *man/addRowsCLP.Rd
ae29b572c5b913e0cee58e41f9c1a77b *man/chgColLowerCLP.Rd
87cc07301c3cad4431b6a7a916787f93 *man/chgColUpperCLP.Rd
3998d99207a7c1260723825664df6133 *man/chgObjCoefsCLP.Rd
6bfa51e7bb325ac428f9270a028c8f7a *man/chgRowLowerCLP.Rd
633054b25943786817eebc3642183c1c *man/chgRowUpperCLP.Rd
84c9bba40b1ddfe90954903ce1fd3f6d *man/clpAPI-package.Rd
49d588eb46fcebee1712674bb4f7d3aa *man/clpPtr-class.Rd
fcf3a7ff8b53a3ec50c958c3d2166ca3 *man/copyNamesCLP.Rd
659504f9c06c120f6c55517d63bf4994 *man/delColsCLP.Rd
045ae82acdc295785959fd1e8db6cf5a *man/delProbCLP.Rd
9c1d261b4d7a3e3b4375fe8e75cedf39 *man/delRowsCLP.Rd
9cabdc8298f7370c21e15b513a0c7ca1 *man/dropNamesCLP.Rd
012d88d845f835bfe2cfea4ba08a6e3d *man/dualCLP.Rd
278341a1d5c00b1dbc8d7701ae0b8d86 *man/getColDualCLP.Rd
a6d90e81c179278dbf6086646af4a366 *man/getColLowerCLP.Rd
36a0fd7a47f52c73d59e82fd5857110d *man/getColPrimCLP.Rd
80d47275b11ba6c766b7b164e411d0fc *man/getColUpperCLP.Rd
f2f2fcd4e3c90634ab136b4627ae4b08 *man/getIndCLP.Rd
68a872b9c42e981c3317f8f965af541f *man/getLogLevelCLP.Rd
9162f07ae7aea48973cd93e1ee018d3e *man/getNnzCLP.Rd
81f39e9aa5747819fd1f87f8a1c36d21 *man/getNumColsCLP.Rd
fe178eb36ee4084fa25e21e56b04be92 *man/getNumNnzCLP.Rd
e43df9658e7fbe8c631349bdc06c73ea *man/getNumRowsCLP.Rd
7c577badd12b83de9afff5287619018b *man/getObjCoefsCLP.Rd
faa9ce206e630ab2d33cfa7b3d3d9117 *man/getObjDirCLP.Rd
4d8cc7aa9d96418f85633255fcf2867f *man/getObjValCLP.Rd
869b586c8026d2ec8e703ea761d6630e *man/getRowDualCLP.Rd
8212e338fbed580675f023fc6c477d3c *man/getRowLowerCLP.Rd
c943286578d76fbf3761b0a30c7fecd4 *man/getRowPrimCLP.Rd
57c2faa7f4443187dab2649912ed7688 *man/getRowUpperCLP.Rd
72df7fd600abfc56ce19a11f84842402 *man/getScaleFlagCLP.Rd
7b57d27e7160f754119e62a428ba27f3 *man/getSolStatusCLP.Rd
fd66b1d0be60b2c2855c93bfebd584ff *man/getVecLenCLP.Rd
4ae77953b088288d8b5c9c88e0e83446 *man/getVecStartCLP.Rd
8f8ecad322db363f477c83c35fc09603 *man/idiotCLP.Rd
6551a8a960f4462b59c34cdce1103161 *man/initProbCLP.Rd
f38b36396c9aaf39189b160c40167b65 *man/lengthNamesCLP.Rd
21aaec1dccf7fadd698c3da90bfd8d35 *man/loadMatrixCLP.Rd
70b15fb57229f15409b540663e81c4fc *man/loadProblemCLP.Rd
b52e0947a60ff6f1839a37d224a7a3df *man/primalCLP.Rd
a01c1ad1bfac218ad53b3c3abf90a2e2 *man/printModelCLP.Rd
a418a1cbfec3f1bdd4acf49f32f7b2e2 *man/probNameCLP.Rd
13cbb298a95e03c13e895dcd72c7147b *man/readMPSCLP.Rd
9870599290752fe1f5fbb51515c88151 *man/resizeCLP.Rd
dc8d186dbdf094fb26aef82502d4871b *man/restoreModelCLP.Rd
8f39cfcdbc1a927b83a8f1897865ed78 *man/return_codeCLP.Rd
ebdf498e2559a65c19729a1a21c9e72b *man/saveModelCLP.Rd
ff95f14cb153143c4addab443ab162c0 *man/scaleModelCLP.Rd
e04ef106322792a2c83721d6cf20e0dd *man/setLogLevelCLP.Rd
7411687c9940b4d378325078af8355c3 *man/setObjDirCLP.Rd
cd6ee2d6da156be2d3b7938d1d787a87 *man/solveInitialBarrierCLP.Rd
40bce1c1ba932f49b7b77b16b7210cb7 *man/solveInitialBarrierNoCrossCLP.Rd
c49b476f94cfbfbeb8a93a8bc7083d0f *man/solveInitialCLP.Rd
46cd2ee701fcdac1c2473b1072336e2d *man/solveInitialDualCLP.Rd
f89b721b6ec8b260fe3cdb7024932030 *man/solveInitialPrimalCLP.Rd
5724c8b0b98b6cf1bcc15bad70f87f5a *man/status_codeCLP.Rd
fa89b81b2935b875d4230c3e2c1c2e25 *man/versionCLP.Rd
e4cff70c399a10f65c797ddb9bfc2f65 *src/Makevars.in
5e18cdf60e85c6ed074a9125868cef8d *src/Makevars.win
80e01a59b216fbb14dd6b3b7aaa0f506 *src/clpAPI.c
ebf775ae8f5797658db56f2e81349c14 *src/clpAPI.h
f1ee63eab916e1506cb4af5fbcdddd5e *src/clpR.h
2f0955cfb67608368cf62466a9d2226f *src/init.c
f932b68cee56631e482786a0e888fe45 *vignettes/clpAPI.Rnw
useDynLib(clpAPI)
import(methods)
exportClass("clpPtr")
export(
# methods
"clpPointer",
"clpPtrType",
"clpPtrType<-",
"isNULLpointerCLP",
"isCLPpointer",
# function names
addColsCLP,
addRowsCLP,
chgColLowerCLP,
chgColUpperCLP,
chgObjCoefsCLP,
chgRowLowerCLP,
chgRowUpperCLP,
#colNameCLP,
copyNamesCLP,
delColsCLP,
delProbCLP,
delRowsCLP,
dualCLP,
dropNamesCLP,
getColDualCLP,
getColLowerCLP,
getColPrimCLP,
getColUpperCLP,
getIndCLP,
getLogLevelCLP,
getNnzCLP,
getNumColsCLP,
getNumNnzCLP,
getNumRowsCLP,
getObjCoefsCLP,
getObjDirCLP,
getObjValCLP,
getRowDualCLP,
getRowLowerCLP,
getRowPrimCLP,
getRowUpperCLP,
getScaleFlagCLP,
getSolStatusCLP,
getVecLenCLP,
getVecStartCLP,
idiotCLP,
initProbCLP,
loadMatrixCLP,
loadProblemCLP,
lengthNamesCLP,
primalCLP,
printModelCLP,
probNameCLP,
readMPSCLP,
resizeCLP,
restoreModelCLP,
return_codeCLP,
#rowNameCLP,
saveModelCLP,
scaleModelCLP,
setLogLevelCLP,
setObjDirCLP,
solveInitialBarrierCLP,
solveInitialBarrierNoCrossCLP,
solveInitialCLP,
solveInitialDualCLP,
solveInitialPrimalCLP,
status_codeCLP,
versionCLP
)
R/clp.R 0 → 100644
#------------------------------------------------------------------------------#
# R interface to COIN-OR Clp #
#------------------------------------------------------------------------------#
# clp.R
# R interface to COIN-OR Clp.
#
# Copyright (C) 2011-2013 Gabriel Gelius-Dietrich, Dpt. for Bioinformatics,
# Institute for Informatics, Heinrich-Heine-University, Duesseldorf, Germany.
# All right reserved.
# Email: geliudie@uni-duesseldorf.de
#
# This file is part of clpAPI.
#
# ClpAPI is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# ClpAPI is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with clpAPI If not, see <http://www.gnu.org/licenses/>.
#------------------------------------------------------------------------------#
# return codes of clp optimizations
return_codeCLP <- function(code) {
if (code == 0) { return( "solution process was successful" ) }
else { return(paste("Failed to obtain solution, unknown error code:", code)) }
}
# solution status codes of clp optimizations
status_codeCLP <- function(code) {
if (code == 0) { return( "solution is optimal" ) }
else if (code == 1) { return( "solution is primal infeasible" ) }
else if (code == 2) { return( "solution is dual infeasible" ) }
else if (code == 3) { return( "stopped on iterations etc" ) }
else if (code == 4) { return( "stopped due to errors" ) }
else { return(paste("unknown status code:", code)) }
}
#------------------------------------------------------------------------------#
# R interface to COIN-OR Clp #
#------------------------------------------------------------------------------#
# clpAPI.R
# R interface to COIN-OR Clp.
#
# Copyright (C) 2011-2013 Gabriel Gelius-Dietrich, Dpt. for Bioinformatics,
# Institute for Informatics, Heinrich-Heine-University, Duesseldorf, Germany.
# All right reserved.
# Email: geliudie@uni-duesseldorf.de
#
# This file is part of clpAPI.
#
# ClpAPI is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# ClpAPI is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with clpAPI If not, see <http://www.gnu.org/licenses/>.
#------------------------------------------------------------------------------#
# the interface #
#------------------------------------------------------------------------------#
#------------------------------------------------------------------------------#
delProbCLP <- function(lp) {
invisible(.Call("delProb", clpPointer(lp), PACKAGE = "clpAPI"))
}
#------------------------------------------------------------------------------#
initProbCLP <- function(ptrtype = "clp_prob") {
lp <- .Call("initProb", PACKAGE = "clpAPI",
as.character(ptrtype)
)
lpP <- clp_Pointer(lp)
return(lpP)
}
#------------------------------------------------------------------------------#
setObjDirCLP <- function(lp, lpdir) {
invisible(
.Call("setObjDir", PACKAGE = "clpAPI",
clpPointer(lp),
as.numeric(lpdir)
)
)
}
#------------------------------------------------------------------------------#
getObjDirCLP <- function(lp) {
lpdir <- .Call("getObjDir", PACKAGE = "clpAPI",
clpPointer(lp)
)
return(lpdir)
}
#------------------------------------------------------------------------------#
resizeCLP <- function(lp, nrows, ncols) {
invisible(
.Call("resize", PACKAGE = "clpAPI",
clpPointer(lp),
as.integer(nrows),
as.integer(ncols)
)
)
}
#------------------------------------------------------------------------------#
addRowsCLP <- function(lp, nrows, lb, ub, rowst, cols, val) {
invisible(
.Call("addRows", PACKAGE = "clpAPI",
clpPointer(lp),
as.integer(nrows),
as.numeric(lb),
as.numeric(ub),
as.integer(rowst),
as.integer(cols),
as.numeric(val)
)
)
}
#------------------------------------------------------------------------------#
addColsCLP <- function(lp, ncols, lb, ub, obj, colst, rows, val) {
invisible(
.Call("addCols", PACKAGE = "clpAPI",
clpPointer(lp),
as.integer(ncols),
as.numeric(lb),
as.numeric(ub),
as.numeric(obj),
as.integer(colst),
as.integer(rows),
as.numeric(val)
)
)
}
#------------------------------------------------------------------------------#
getNumRowsCLP <- function(lp) {
nrows <- .Call("getNumRows", PACKAGE = "clpAPI",
clpPointer(lp)
)
return(nrows)
}
#------------------------------------------------------------------------------#
getNumColsCLP <- function(lp) {
ncols <- .Call("getNumCols", PACKAGE = "clpAPI",
clpPointer(lp)
)
return(ncols)
}
#------------------------------------------------------------------------------#
chgObjCoefsCLP <- function(lp, objCoef) {
invisible(
.Call("chgObjCoefs", PACKAGE = "clpAPI",
clpPointer(lp),
as.numeric(objCoef)
)
)
}
#------------------------------------------------------------------------------#
getObjCoefsCLP <- function(lp) {
objCoefs <- .Call("getObjCoefs", PACKAGE = "clpAPI",
clpPointer(lp)
)
return(objCoefs)
}
#------------------------------------------------------------------------------#
chgRowLowerCLP <- function(lp, rlb) {
invisible(
.Call("chgRowLower", PACKAGE = "clpAPI",
clpPointer(lp),
as.numeric(rlb)
)
)
}
#------------------------------------------------------------------------------#
getRowLowerCLP <- function(lp) {
rlb <- .Call("getRowLower", PACKAGE = "clpAPI",
clpPointer(lp)
)
return(rlb)
}
#------------------------------------------------------------------------------#
chgRowUpperCLP <- function(lp, rub) {
invisible(
.Call("chgRowUpper", PACKAGE = "clpAPI",
clpPointer(lp),
as.numeric(rub)
)
)
}
#------------------------------------------------------------------------------#
getRowUpperCLP <- function(lp) {
rub <- .Call("getRowUpper", PACKAGE = "clpAPI",
clpPointer(lp)
)
return(rub)
}
#------------------------------------------------------------------------------#
chgColLowerCLP <- function(lp, lb) {
invisible(
.Call("chgColLower", PACKAGE = "clpAPI",
clpPointer(lp),
as.numeric(lb)
)
)
}
#------------------------------------------------------------------------------#
getColLowerCLP <- function(lp) {
lb <- .Call("getColLower", PACKAGE = "clpAPI",
clpPointer(lp)
)
return(lb)
}
#------------------------------------------------------------------------------#
chgColUpperCLP <- function(lp, ub) {
invisible(
.Call("chgColUpper", PACKAGE = "clpAPI",
clpPointer(lp),
as.numeric(ub)
)
)
}
#------------------------------------------------------------------------------#
getColUpperCLP <- function(lp) {
ub <- .Call("getColUpper", PACKAGE = "clpAPI",
clpPointer(lp)
)
return(ub)
}
#------------------------------------------------------------------------------#
loadProblemCLP <- function(lp, ncols, nrows, ia, ja, ra,
lb = NULL, ub = NULL,
obj_coef = NULL, rlb = NULL, rub = NULL) {
if (is.null(lb)) {
Clb <- as.null(lb)
}
else {
Clb <- as.numeric(lb)
}
if (is.null(ub)) {
Cub <- as.null(ub)
}
else {
Cub <- as.numeric(ub)
}
if (is.null(obj_coef)) {
Cobj_coef <- as.null(obj_coef)
}
else {
Cobj_coef <- as.numeric(obj_coef)
}
if (is.null(rlb)) {
Crlb <- as.null(rlb)
}
else {
Crlb <- as.numeric(rlb)
}
if (is.null(rub)) {
Crub <- as.null(rub)
}
else {
Crub <- as.numeric(rub)
}
invisible(
.Call("loadProblem", PACKAGE = "clpAPI",
clpPointer(lp),
as.integer(ncols),
as.integer(nrows),
as.integer(ia),
as.integer(ja),
as.numeric(ra),
Clb,
Cub,
Cobj_coef,
Crlb,
Crub
# as.numeric(lb),
# as.numeric(ub),
# as.numeric(obj_coef),
# as.numeric(rlb),
# as.numeric(rub)
)
)
}
#------------------------------------------------------------------------------#
loadMatrixCLP <- function(lp, ncols, nrows, ia, ja, ra) {
invisible(
.Call("loadMatrix", PACKAGE = "clpAPI",
clpPointer(lp),
as.integer(ncols),
as.integer(nrows),
as.integer(ia),
as.integer(ja),
as.numeric(ra)
)
)
}
#------------------------------------------------------------------------------#
getNumNnzCLP <- function(lp) {
nnz <- .Call("getNumNnz", PACKAGE = "clpAPI",
clpPointer(lp)
)
return(nnz)
}
#------------------------------------------------------------------------------#
getVecStartCLP <- function(lp) {
vec_start <- .Call("getVecStart", PACKAGE = "clpAPI",
clpPointer(lp)
)
return(vec_start)
}
#------------------------------------------------------------------------------#
getIndCLP <- function(lp) {
index <- .Call("getInd", PACKAGE = "clpAPI",
clpPointer(lp)
)
return(index)
}
#------------------------------------------------------------------------------#
getVecLenCLP <- function(lp) {
vec_len <- .Call("getVecLen", PACKAGE = "clpAPI",
lp
)
return(vec_len)
}
#------------------------------------------------------------------------------#
getNnzCLP <- function(lp) {
n_elem <- .Call("getNnz", PACKAGE = "clpAPI",
clpPointer(lp)
)
return(n_elem)
}
#------------------------------------------------------------------------------#
printModelCLP <- function(lp, prefix = "CLPmodel") {
invisible(
.Call("printModel", PACKAGE = "clpAPI",
clpPointer(lp),
as.character(prefix)
)
)
}
#------------------------------------------------------------------------------#
setLogLevelCLP <- function(lp, amount) {
invisible(
.Call("setLogLevel", PACKAGE = "clpAPI",
clpPointer(lp),
as.integer(amount)
)
)
}
#------------------------------------------------------------------------------#
getLogLevelCLP <- function(lp) {
amount <- .Call("getLogLevel", PACKAGE = "clpAPI",
clpPointer(lp)
)
return(amount)
}
#------------------------------------------------------------------------------#
scaleModelCLP <- function(lp, mode) {
invisible(
.Call("scaleModel", PACKAGE = "clpAPI",
clpPointer(lp),
as.integer(mode)
)
)
}
#------------------------------------------------------------------------------#
getScaleFlagCLP <- function(lp) {
flag <- .Call("getScaleFlag", PACKAGE = "clpAPI",
clpPointer(lp)
)
return(flag)
}
#------------------------------------------------------------------------------#
solveInitialCLP <- function(lp) {
ret <- .Call("solveInitial", PACKAGE = "clpAPI",
clpPointer(lp)
)
return(ret)
}
#------------------------------------------------------------------------------#
solveInitialDualCLP <- function(lp) {
ret <- .Call("solveInitialDual", PACKAGE = "clpAPI",
clpPointer(lp)
)
return(ret)
}
#------------------------------------------------------------------------------#
solveInitialPrimalCLP <- function(lp) {
ret <- .Call("solveInitialPrimal", PACKAGE = "clpAPI",
clpPointer(lp)
)
return(ret)
}
#------------------------------------------------------------------------------#
solveInitialBarrierCLP <- function(lp) {
ret <- .Call("solveInitialBarrier", PACKAGE = "clpAPI",
clpPointer(lp)
)
return(ret)
}
#------------------------------------------------------------------------------#
solveInitialBarrierNoCrossCLP <- function(lp) {
ret <- .Call("solveInitialBarrierNoCross", PACKAGE = "clpAPI",
clpPointer(lp)
)
return(ret)
}
#------------------------------------------------------------------------------#
dualCLP <- function(lp, ifValP = 0) {
ret <- .Call("dual", PACKAGE = "clpAPI",
clpPointer(lp),
as.integer(ifValP)
)
return(ret)
}
#------------------------------------------------------------------------------#
primalCLP <- function(lp, ifValP = 0) {
ret <- .Call("primal", PACKAGE = "clpAPI",
clpPointer(lp),
as.integer(ifValP)
)
return(ret)
}
#------------------------------------------------------------------------------#
idiotCLP <- function(lp, thd = 0) {
invisible(
.Call("idiot", PACKAGE = "clpAPI",
clpPointer(lp),
as.integer(thd)
)
)
}
#------------------------------------------------------------------------------#
getSolStatusCLP <- function(lp) {
stat <- .Call("getSolStatus", PACKAGE = "clpAPI",
clpPointer(lp)
)
return(stat)
}
#------------------------------------------------------------------------------#
getObjValCLP <- function(lp) {
obj <- .Call("getObjVal", PACKAGE = "clpAPI",
clpPointer(lp)
)
return(obj)
}
#------------------------------------------------------------------------------#
getColPrimCLP <- function(lp) {
col_prim <- .Call("getColPrim", clpPointer(lp), PACKAGE = "clpAPI")
return(col_prim)
}
#------------------------------------------------------------------------------#
getColDualCLP <- function(lp) {
col_dual <- .Call("getColDual", clpPointer(lp), PACKAGE = "clpAPI")
return(col_dual)
}
#------------------------------------------------------------------------------#
getRowPrimCLP <- function(lp) {
row_prim <- .Call("getRowPrim", clpPointer(lp), PACKAGE = "clpAPI")
return(row_prim)
}
#------------------------------------------------------------------------------#
getRowDualCLP <- function(lp) {
row_dual <- .Call("getRowDual", clpPointer(lp), PACKAGE = "clpAPI")
return(row_dual)
}
#------------------------------------------------------------------------------#
delRowsCLP <- function(lp, num, i) {
invisible(
.Call("delRows", PACKAGE = "clpAPI",
clpPointer(lp),
as.integer(num),
as.integer(i)
)
)
}
#------------------------------------------------------------------------------#
delColsCLP <- function(lp, num, j) {
invisible(
.Call("delCols", PACKAGE = "clpAPI",
clpPointer(lp),
as.integer(num),
as.integer(j)
)
)
}
#------------------------------------------------------------------------------#
readMPSCLP <- function(lp, fname, keepNames = TRUE, ignoreErrors = FALSE) {
check <- .Call("readMPS", PACKAGE = "clpAPI",
clpPointer(lp),
as.character(fname),
as.integer(keepNames),
as.integer(ignoreErrors)
)
return(check)
}
#------------------------------------------------------------------------------#
saveModelCLP <- function(lp, fname) {
check <- .Call("saveModel", PACKAGE = "clpAPI",
clpPointer(lp),
as.character(fname)
)
return(check)
}
#------------------------------------------------------------------------------#
restoreModelCLP <- function(lp, fname) {
check <- .Call("restoreModel", PACKAGE = "clpAPI",
clpPointer(lp),
as.character(fname)
)
return(check)
}
#------------------------------------------------------------------------------#
versionCLP <- function() {
version <- .Call("version", PACKAGE = "clpAPI")
return(version)
}
#------------------------------------------------------------------------------#
dropNamesCLP <- function(lp) {
invisible(
.Call("dropNames", PACKAGE = "clpAPI",
clpPointer(lp)
)
)
}
#------------------------------------------------------------------------------#
copyNamesCLP <- function(lp, cnames, rnames) {
invisible(
.Call("copyNames", PACKAGE = "clpAPI",
clpPointer(lp),
as.character(cnames),
as.character(rnames)
)
)
}
#------------------------------------------------------------------------------#
lengthNamesCLP <- function(lp) {
nnames <- .Call("lengthNames", PACKAGE = "clpAPI",
clpPointer(lp)
)
return(nnames)
}
#------------------------------------------------------------------------------#
rowNameCLP <- function(lp, i, rname) {
invisible(
.Call("rowName", PACKAGE = "clpAPI",
clpPointer(lp),
as.integer(i),
as.character(rname)
)
)
}
#------------------------------------------------------------------------------#
colNameCLP <- function(lp, j, cname) {
invisible(
.Call("colName", PACKAGE = "clpAPI",
clpPointer(lp),
as.integer(j),
as.character(cname)
)
)
}
#------------------------------------------------------------------------------#
probNameCLP <- function(lp, pname) {
invisible(
.Call("probName", PACKAGE = "clpAPI",
clpPointer(lp),
as.integer(nchar(pname)),
as.character(pname)
)
)
}
#------------------------------------------------------------------------------#
# R interface to COIN-OR Clp #
#------------------------------------------------------------------------------#
# clp_ptrClass.R
# R interface to COIN-OR Clp.
#
# Copyright (C) 2011-2013 Gabriel Gelius-Dietrich, Dpt. for Bioinformatics,
# Institute for Informatics, Heinrich-Heine-University, Duesseldorf, Germany.
# All right reserved.
# Email: geliudie@uni-duesseldorf.de
#
# This file is part of clpAPI.
#
# ClpAPI is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# ClpAPI is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with clpAPI If not, see <http://www.gnu.org/licenses/>.
#------------------------------------------------------------------------------#
# definition of class clpPtr #
#------------------------------------------------------------------------------#
# representation of class clpPtr
setClass(Class = "clpPtr",
representation(
clpPtrType = "character",
clpPointer = "externalptr"
)
#, contains = "externalptr"
)
#------------------------------------------------------------------------------#
# contructor for class clpPtr
setMethod(f = "initialize",
signature = "clpPtr",
definition = function(.Object, p, w) {
.Object@clpPointer <- attr(p, which = w, exact = TRUE)
.Object@clpPtrType <- as.character(p)
return(.Object)
}
)
# contructor for pointers to clp problem structures
clp_Pointer <- function(pointer) {
if (is(pointer, "clp_ptr")) {
pObj <- new("clpPtr",
p = pointer,
w = as.character("clp_ptr"))
}
else {
pObj <- pointer
}
return(pObj)
}
#------------------------------------------------------------------------------#
# clpPtrType
setMethod("clpPtrType", signature(object = "clpPtr"),
function(object) {
return(object@clpPtrType)
}
)
setReplaceMethod("clpPtrType", signature = (object = "clpPtr"),
function(object, value) {
object@clpPtrType <- value
return(object)
}
)
# clpPointer
setMethod("clpPointer", signature(object = "clpPtr"),
function(object) {
return(object@clpPointer)
}
)
#------------------------------------------------------------------------------#
setMethod("isNULLpointerCLP", signature(object = "clpPtr"),
function(object) {
return(.Call("isNULLptr", PACKAGE = "clpAPI", clpPointer(object)))
}
)
setMethod("isCLPpointer", signature(object = "clpPtr"),
function(object) {
return(.Call("isCLPptr", PACKAGE = "clpAPI", clpPointer(object)))
}
)
#------------------------------------------------------------------------------#
setMethod("show", signature(object = "clpPtr"),
function(object) {
nc <- NA
if (isNULLpointerCLP(object)) {
ptrtype <- "NULL"
}
else {
if (isCLPpointer(object)) {
ptrtype <- "COIN-OR Clp problem object"
nc <- getNumColsCLP(object)
}
else {
ptrtype <- "unknown"
}
}
cat("object of class ", dQuote("clpPtr"),
": pointer to ", ptrtype, ".\n", sep = "")
if (!is.na(nc)) {
if ( (nc < 1) || (nc > 10) ) {
cat(paste("Number of variables: ",
getNumColsCLP(object), "\n"))
cat(paste("Number of constraints:",
getNumRowsCLP(object), "\n"))
}
else {
# make a more illustrative method here
cat(paste("Number of variables: ",
getNumColsCLP(object), "\n"))
cat(paste("Number of constraints:",
getNumRowsCLP(object), "\n"))
}
}
cat(paste("Slot ",
dQuote("clpPtrType"), ": ",
clpPtrType(object), "\n", sep = ""))
cat(paste("Slot ", dQuote("clpPointer"), ": ", sep = ""))
print(slot(object, "clpPointer"), sep = "")
}
)
#------------------------------------------------------------------------------#
# R interface to COIN-OR Clp #
#------------------------------------------------------------------------------#
# generics.R
# R interface to COIN-OR Clp.
#
# Copyright (C) 2011-2013 Gabriel Gelius-Dietrich, Dpt. for Bioinformatics,
# Institute for Informatics, Heinrich-Heine-University, Duesseldorf, Germany.
# All right reserved.
# Email: geliudie@uni-duesseldorf.de
#
# This file is part of clpAPI.
#
# ClpAPI is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# ClpAPI is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with clpAPI If not, see <http://www.gnu.org/licenses/>.
#------------------------------------------------------------------------------#
# generics #
#------------------------------------------------------------------------------#
setGeneric(name = "clpPointer",
def = function(object) { standardGeneric("clpPointer") }
)
setGeneric(name = "clpPtrType",
def = function(object) { standardGeneric("clpPtrType") }
)
setGeneric(name = "clpPtrType<-",
def = function(object, value) { standardGeneric("clpPtrType<-") }
)
setGeneric(name = "isNULLpointerCLP",
def = function(object) { standardGeneric("isNULLpointerCLP") }
)
setGeneric(name = "isCLPpointer",
def = function(object) { standardGeneric("isCLPpointer") }
)
R/zzz.R 0 → 100644
#------------------------------------------------------------------------------#
# R interface to COIN-OR Clp #
#------------------------------------------------------------------------------#
# zzz.R
# R interface to COIN-OR Clp.
#
# Copyright (C) 2011-2013 Gabriel Gelius-Dietrich, Dpt. for Bioinformatics,
# Institute for Informatics, Heinrich-Heine-University, Duesseldorf, Germany.
# All right reserved.
# Email: geliudie@uni-duesseldorf.de
#
# This file is part of clpAPI.
#
# ClpAPI is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# ClpAPI is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with clpAPI If not, see <http://www.gnu.org/licenses/>.
.packageName <- "clpAPI"
.onLoad <- function(libname, pkgname) {
.Call("initCLP", PACKAGE = "clpAPI")
}
.onAttach <- function(libname, pkgname) {
packageStartupMessage("using COIN OR Clp version ", versionCLP())
}
File added
#! /bin/sh
rm -rf autom4te.cache src/Makevars src/*.o
exit 0
configure 0 → 100755
This diff is collapsed.
AC_INIT([clpAPI], [1.2.6], [geliudie@uni-duesseldorf.de])
dnl # --------------------------------------------------------------------
dnl # global (environment) variables
dnl # --------------------------------------------------------------------
dnl
dnl # PKG_CPPFLAGS C preprocessor flags -I...
dnl # PKG_CFLAGS C compiler flags
dnl # PKG_LIBS libraries -l...
dnl # --------------------------------------------------------------------
dnl # R compiler and flags
dnl # --------------------------------------------------------------------
: ${R_HOME=`R RHOME`}
if test -z "${R_HOME}"; then
echo "could not determine R_HOME"
exit 1
fi
dnl # GNU R default settings
CC=`"${R_HOME}/bin/R" CMD config CC`
CPP=`"${R_HOME}/bin/R" CMD config CPP`
CFLAGS=`"${R_HOME}/bin/R" CMD config CFLAGS`
CPPFLAGS=`"${R_HOME}/bin/R" CMD config CPPFLAGS`
AC_PROG_CC
AC_PROG_CPP
dnl # --------------------------------------------------------------------
dnl # test for global variables
dnl # --------------------------------------------------------------------
ARGS_OK="FALSE"
if test [ -n "$PKG_CPPFLAGS" -a -n "$PKG_LIBS" ] ; then
ARGS_OK="TRUE"
else
if test [ -n "$PKG_CPPFLAGS" -o -n "$PKG_LIBS" ] ; then
AC_MSG_ERROR([Please set both variables: PKG_CPPFLAGS AND PKG_LIBS])
fi
fi
dnl # --------------------------------------------------------------------
dnl # get arguments
dnl # --------------------------------------------------------------------
AC_ARG_WITH(clp-include,
AC_HELP_STRING([--with-clp-include=PATH],
[location of COIN-OR Clp include directory [[/usr/local/include]]]
),
[CLP_INCLUDE=$withval],
[CLP_INCLUDE=""])
AC_ARG_WITH(clp-lib,
AC_HELP_STRING([--with-clp-lib=PATH],
[location of COIN-OR Clp callable library [[usr/local/lib]]]
),
[CLP_LIB=$withval],
[CLP_LIB=""])
dnl # --------------------------------------------------------------------
dnl # pkg-config
dnl # --------------------------------------------------------------------
dnl # include and library directories
if test [ "$ARGS_OK" = "FALSE" ] ; then
AC_PATH_PROG([PKG_CONFIG], [pkg-config], [], [$PATH:/usr/local/bin])
if test [ "${PKG_CONFIG}" != "" ] ; then
if "${PKG_CONFIG}" --exists clp; then
CLP_LIBS=`${PKG_CONFIG} --libs clp`
CLP_CFLAGS=`${PKG_CONFIG} --cflags clp`
if test [ -z "$CLP_LIBS" -a -z "$CLP_CFLAGS" ] ; then
AC_MSG_NOTICE([can not get information about clp from pkg-config])
else
AC_MSG_NOTICE([set compile and link flags according to pkg-config])
AC_MSG_NOTICE([compile flags are $CLP_CFLAGS])
AC_MSG_NOTICE([link flags are $CLP_LIBS])
PKG_LIBS="${CLP_LIBS}"
PKG_CPPFLAGS="${CLP_CFLAGS}"
ARGS_OK="TRUE"
fi
else
AC_MSG_NOTICE([pkg-config file for clp is not available])
fi
fi
fi
dnl # --------------------------------------------------------------------
dnl # test arguments
dnl # --------------------------------------------------------------------
dnl # include and library directories
dnl # include and library directories
if test [ "$ARGS_OK" = "FALSE" ] ; then
if test [ -n "$CLP_INCLUDE" -a -n "$CLP_LIB" ] ; then
if test [ -d "$CLP_INCLUDE" ] ; then
if test [ -d "$CLP_INCLUDE/coin" ] ; then
PKG_CPPFLAGS="-I${CLP_INCLUDE} -I${CLP_INCLUDE}/coin"
else
PKG_CPPFLAGS="-I${CLP_INCLUDE}"
fi
else
AC_MSG_ERROR([directory $CLP_INCLUDE does not exist])
fi
if test [ -d "$CLP_LIB" ] ; then
if test [ -d "$CLP_LIB/coin" ] ; then
PKG_LIBS="-L${CLP_LIB} -L${CLP_LIB}/coin"
else
PKG_LIBS="-L${CLP_LIB}"
fi
else
AC_MSG_ERROR([directory $CLP_LIB does not exist])
fi
else
dnl # if no arguments are given, try to find the clp executable. If is not
dnl # found, use /usr/local
AC_PREFIX_PROGRAM(clp)
if test [ "$prefix" = "NONE" ] ; then
AC_MSG_NOTICE([No prefix given, trying /usr and /usr/local])
if test [ -d "/usr/include" -o -d "/usr/local/include" ] ; then
PKG_CPPFLAGS="-I/usr/include -I/usr/local/include -I/usr/include/coin -I/usr/local/include/coin"
else
AC_MSG_ERROR([directories /usr/include and /usr/local/include do not exist])
fi
if test [ -d "/usr/local/lib" -o -d "/usr/local/lib64" -o -d "/usr/lib" -o -d "/usr/lib64"] ; then
PKG_LIBS=""
if test [ -d "/usr/local/lib" ] ; then
PKG_LIBS="$PKG_LIBS -L/usr/local/lib"
if test [ -d "/usr/local/lib/coin" ] ; then
PKG_LIBS="$PKG_LIBS -L/usr/local/lib/coin"
fi
fi
if test [ -d "/usr/local/lib64" ] ; then
PKG_LIBS="$PKG_LIBS -L/usr/local/lib64"
if test [ -d "/usr/local/lib64/coin" ] ; then
PKG_LIBS="$PKG_LIBS -L/usr/local/lib64/coin"
fi
fi
if test [ -d "/usr/lib" ] ; then
PKG_LIBS="$PKG_LIBS -L/usr/lib"
if test [ -d "/usr/lib/coin" ] ; then
PKG_LIBS="$PKG_LIBS -L/usr/lib/coin"
fi
fi
if test [ -d "/usr/lib64" ] ; then
PKG_LIBS="$PKG_LIBS -L/usr/lib64"
if test [ -d "/usr/lib64/coin" ] ; then
PKG_LIBS="$PKG_LIBS -L/usr/lib64/coin"
fi
fi
# PKG_LIBS="-L/usr/local/lib -Wl,-rpath /usr/local/lib"
else
AC_MSG_ERROR([none of the directories /usr/local/lib, /usr/local/lib64, /usr/lib of /usr/lib64 exists])
fi
else
AC_MSG_NOTICE([found executable clp in $prefix])
if test [ -d "$prefix/include" ] ; then
PKG_CPPFLAGS="-I$prefix/include"
if test [ -d "$prefix/include/coin" ] ; then
PKG_CPPFLAGS="$PKG_CPPFLAGS -I$prefix/include/coin"
fi
else
AC_MSG_ERROR([directory $prefix/include does not exist])
fi
if test [ -d "$prefix/lib" -o -d "$prefix/lib64" ] ; then
PKG_LIBS=""
if test [ -d "$prefix/lib" ] ; then
PKG_LIBS="$PKG_LIBS -L$prefix/lib"
if test [ -d "$prefix/lib/coin" ] ; then
PKG_LIBS="$PKG_LIBS -L$prefix/lib/coin"
fi
fi
if test [ -d "$prefix/lib64" ] ; then
PKG_LIBS="$PKG_LIBS -L$prefix/lib64"
if test [ -d "$prefix/lib64/coin" ] ; then
PKG_LIBS="$PKG_LIBS -L$prefix/lib64/coin"
fi
fi
else
AC_MSG_ERROR([neither $prefix/lib nor $prefix/lib64 exist])
fi
fi
fi
PKG_LIBS="${PKG_LIBS} -lClp -lCoinUtils -lm"
ARGS_OK="TRUE"
fi
dnl # --------------------------------------------------------------------
dnl # CFLAGS
dnl # --------------------------------------------------------------------
if test [ -z "$PKG_CFLAGS" ] ; then
if test [ "${R_ARCH}" = "/x86_64" ] ; then
PKG_CFLAGS="-m64"
elif test [ "${R_ARCH}" = "/i386" ] ; then
PKG_CFLAGS="-m32"
else
PKG_CFLAGS=""
fi
fi
dnl # --------------------------------------------------------------------
dnl # check header and library
dnl # --------------------------------------------------------------------
LIBS="${PKG_LIBS}"
CFLAGS="${CFLAGS} ${PKG_CFLAGS}"
CPPFLAGS="${CPPFLAGS} ${PKG_CPPFLAGS}"
AC_CHECK_HEADER([Clp_C_Interface.h],,
AC_MSG_ERROR([Could not find Clp_C_Interface.h:
clpAPI requires clp from http://www.coin-or.org/projects/Clp.xml
use --with-clp-include or CLP_INCLUDE to specify the include path.]))
AC_SEARCH_LIBS([Clp_newModel], [Clp], ,
AC_MSG_ERROR([Could not link to clp:
use --with-clp-lib or CLP_LIB to specify the lib path.]))
dnl # --------------------------------------------------------------------
dnl # substitute src/Makevars
dnl # --------------------------------------------------------------------
AC_SUBST(PKG_CFLAGS)
AC_SUBST(PKG_LIBS)
AC_SUBST(PKG_CPPFLAGS)
AC_OUTPUT(src/Makevars)
exit 0
GNU R package clpAPI: R Interface to C API of COIN-OR Clp
The installation procedure for the clpAPI package needs to know where to
find the COIN-OR Clp include directory and where to find the callable library.
# ---------------------------------------------------------------------------- #
# Linux and MacOS X installation
# ---------------------------------------------------------------------------- #
There are basically four different ways of installing the clpAPI package:
1) Use --with-clp-<ARG>
--with-clp-include=PATH with PATH being the include directory of
COIN-OR Clp
--with-clp-lib=PATH with PATH being the directory containing the
callable library.
R CMD INSTALL --configure-args=" \
--with-clp-include=/path/to/include/dir \
--with-clp-lib=/path/to/lib/dir" clpAPI_X.X.X.tar.gz
When using --with-clp-<ARG>, both arguments must be given.
2) Use of environment variables
PKG_CPPFLAGS giving the PATH to the include directory of
COIN-OR Clp
PKG_LIBS giving the PATH to the directory containing the
callable library.
3) Use --prefix
--prefix=PATH with path being the installation directory of
COIN-OR Clp. The include directory is assumed to
be PATH/include and the callable library should
be in PATH/lib.
If either --with-clp-<ARG> nor --prefix is given, it is checked wether
clp is in the PATH. If yes, PATH is used as prefix. If not,
/usr/local/include and /usr/local/lib are tested.
3) Use pkg-config
If pkg-config is available on your system, the pkg-config information
of COIN-OR Clp will be used.
# ---------------------------------------------------------------------------- #
# Windows installation
# ---------------------------------------------------------------------------- #
For the installation on Windows systems the file Makewars.win in src/ is
required. The file looks like this:
PKG_CPPFLAGS=-g -D_R_=1 -DUSE_R=1 -I${CLP_PATH}/include/coin
PKG_LIBS=-L${CLP_PATH}/lib/coin -lClp -lCoinUtils -lstdc++
with the environment variable CLP_PATH being the installation directory
of COIN-OR Clp. This procedure was tested successfully on 32-bit Windows XP.
%% clpAPI Version History
\name{NEWS}
\title{clpAPI News}
\encoding{UTF-8}
% ---------------------------------------------------------------------------- %
\section{Changes in version 1.2.6 2013-10-26}{
\itemize{
\item a minor bugfix in file \file{configure.ac}
}
}
% ---------------------------------------------------------------------------- %
\section{Changes in version 1.2.5 2013-09-08}{
\itemize{
\item removed argument \code{--enable-lapack} from file \file{configure.ac}
}
}
% ---------------------------------------------------------------------------- %
\section{Changes in version 1.2.4 2013-07-17}{
\itemize{
\item added function \code{probNameCLP()}
}
}
% ---------------------------------------------------------------------------- %
\section{Changes in version 1.2.3 2013-05-23}{
\itemize{
\item prints the version number of COIN-OR Clp on startup
\item added functions \code{dropNamesCLP()}, \code{copyNamesCLP()} and
\code{lengthNamesCLP()}
}
}
% ---------------------------------------------------------------------------- %
\section{Changes in version 1.2.2 2013-01-16}{
\itemize{
\item removed old file \file{NEWS.Rd} from top level directory
}
}
% ---------------------------------------------------------------------------- %
\section{Changes in version 1.2.1 2012-04-21}{
\itemize{
\item bugfix in file \file{configure.ac} when using pkg-config
}
}
% ---------------------------------------------------------------------------- %
\section{Changes in version 1.2.0 2012-04-20}{
\itemize{
\item updated \file{configure.ac} script
\item file \file{NEWS} is now in \file{inst/NEWS.Rd}
\item added finalizer for COIN-OR Clp problem objects
\item Function \code{initProbCLP()} returns an instances of class
\code{clpPtr}. This class has two data slots:
\tabular{ll}{
clpPtrType \tab a character string giving the pointer type and \cr
clpPointer \tab a pointer to a C structure \cr
}
\item file \file{c2r.map} in \file{inst/}: mapping of filenames between
C API and \pkg{clpAPI}, run
\preformatted{
c2r <- system.file(package = "clpAPI", "c2r.map")
source(c2r)
}
in order to use original function names of the COIN-OR Clp C API.
}
}
% ---------------------------------------------------------------------------- %
\section{Changes in version 1.1.7 2011-08-22}{
\itemize{
\item minor update in \file{configure.ac}
}
}
% ---------------------------------------------------------------------------- %
\section{Changes in version 1.1.6 2011-07-29}{
\itemize{
\item \file{configure.ac} script and \file{Makevars.win} are now compatible
to COIN-OR Clp version 1.14.0
}
}
% ---------------------------------------------------------------------------- %
\section{Changes in version 1.1.5 2011-07-28}{
\itemize{
\item added \file{NAMESPACE}
}
}
% ---------------------------------------------------------------------------- %
\section{Changes in version 1.1.4 2011-07-27}{
\itemize{
\item removed file \file{COPYING}
}
}
% ---------------------------------------------------------------------------- %
\section{Changes in version 1.1.3 2011-07-27}{
\itemize{
\item changes in \file{configure.ac}
\item updated package vignette
\item added files \file{INSTALL} and \file{README}
}
}
% ---------------------------------------------------------------------------- %
\section{Changes in version 1.1.2 2011-07-14}{
\itemize{
\item minor changes in \file{configure.ac}
}
}
% ---------------------------------------------------------------------------- %
\section{Changes in version 1.1.1 2011-07-12}{
\itemize{
\item renamed to \pkg{clpAPI}
}
}
% ---------------------------------------------------------------------------- %
\section{Changes in version 1.0.3 2011-05-12}{
\itemize{
\item added functions \code{getColDualCLP()}, \code{getRowPrimCLP()} and
\code{getRowDualCLP()}
}
}
% ---------------------------------------------------------------------------- %
\section{Changes in version 1.0.2 2010-12-15}{
\itemize{
\item fixed a bug in \file{configure.ac}
}
}
% ---------------------------------------------------------------------------- %
\section{Changes in version 1.0.1 2010-11-05}{
\itemize{
\item added functions \code{addRowsCLP()}, \code{addColsCLP()},
\code{deleteRowsCLP()} and \code{deleteColsCLP()}
}
}
% ---------------------------------------------------------------------------- %
\section{Changes in version 1.0.0 2010-08-19}{
\itemize{
\item initial public release
}
}
GNU R package clpAPI: R Interface to C API of COIN-OR Clp
The package clpAPI requires a working installation of COIN-OR Clp (including
libraries and header files).
#------------------------------------------------------------------------------#
# map COIN-OR Clp function names to clpAPI function names #
#------------------------------------------------------------------------------#
# COIN-OR Clp # clpAPI
Clp_addColumns <- clpAPI::addColsCLP
Clp_addRows <- clpAPI::addRowsCLP
Clp_chgColumnLower <- clpAPI::chgColLowerCLP
Clp_chgColumnUpper <- clpAPI::chgColUpperCLP
Clp_chgObjCoefficients <- clpAPI::chgObjCoefsCLP
Clp_chgRowLower <- clpAPI::chgRowLowerCLP
Clp_chgRowUpper <- clpAPI::chgRowUpperCLP
#Clp_columnName <- clpAPI::colNameCLP
Clp_copyNames <- clpAPI::copyNamesCLP
Clp_deleteColumns <- clpAPI::delColsCLP
Clp_deleteModel <- clpAPI::delProbCLP
Clp_deleteRows <- clpAPI::delRowsCLP
Clp_dropNames <- clpAPI::dropNamesCLP
Clp_dual <- clpAPI::dualCLP
Clp_dualColumnSolution <- clpAPI::getColDualCLP
Clp_columnLower <- clpAPI::getColLowerCLP
Clp_primalColumnSolution <- clpAPI::getColPrimCLP
Clp_columnUpper <- clpAPI::getColUpperCLP
Clp_getIndices <- clpAPI::getIndCLP
Clp_logLevel <- clpAPI::getLogLevelCLP
Clp_getElements <- clpAPI::getNnzCLP
Clp_numberColumns <- clpAPI::getNumColsCLP
Clp_getNumElements <- clpAPI::getNumNnzCLP
Clp_numberRows <- clpAPI::getNumRowsCLP
Clp_objective <- clpAPI::getObjCoefsCLP
Clp_optimizationDirection <- clpAPI::getObjDirCLP
Clp_objectiveValue <- clpAPI::getObjValCLP
Clp_dualRowSolution <- clpAPI::getRowDualCLP
Clp_rowLower <- clpAPI::getRowLowerCLP
Clp_primalRowSolution <- clpAPI::getRowPrimCLP
Clp_problemName <- clpAPI::probNameCLP
Clp_rowUpper <- clpAPI::getRowUpperCLP
Clp_scalingFlag <- clpAPI::getScaleFlagCLP
Clp_status <- clpAPI::getSolStatusCLP
Clp_getVectorLengths <- clpAPI::getVecLenCLP
Clp_getVectorStarts <- clpAPI::getVecStartCLP
Clp_idiot <- clpAPI::idiotCLP
Clp_newModel <- clpAPI::initProbCLP
Clp_lengthNames <- clpAPI::lengthNamesCLP
Clp_loadProblem <- clpAPI::loadProblemCLP
Clp_primal <- clpAPI::primalCLP
Clp_printModel <- clpAPI::printModelCLP
Clp_readMps <- clpAPI::readMPSCLP
Clp_resize <- clpAPI::resizeCLP
Clp_restoreModel <- clpAPI::restoreModelCLP
#Clp_rowName <- clpAPI::rowNameCLP
Clp_saveModel <- clpAPI::saveModelCLP
Clp_scaling <- clpAPI::scaleModelCLP
Clp_setLogLevel <- clpAPI::setLogLevelCLP
Clp_setOptimizationDirection <- clpAPI::setObjDirCLP
Clp_initialBarrierSolve <- clpAPI::solveInitialBarrierCLP
Clp_initialBarrierNoCrossSolve <- clpAPI::solveInitialBarrierNoCrossCLP
Clp_initialSolve <- clpAPI::solveInitialCLP
Clp_initialDualSolve <- clpAPI::solveInitialDualCLP
Clp_initialPrimalSolve <- clpAPI::solveInitialPrimalCLP
### R code from vignette source 'clpAPI.Rnw'
### Encoding: UTF-8
###################################################
### code chunk number 1: clpAPI.Rnw:74-75
###################################################
library(clpAPI)
###################################################
### code chunk number 2: clpAPI.Rnw:78-79
###################################################
prob <- initProbCLP()
###################################################
### code chunk number 3: clpAPI.Rnw:82-83
###################################################
setObjDirCLP(prob, -1)
###################################################
### code chunk number 4: clpAPI.Rnw:86-88
###################################################
nc <- 3
nr <- 3
###################################################
### code chunk number 5: clpAPI.Rnw:92-93
###################################################
ia <- c(0, 1, 2, 0, 1, 2, 0, 1, 2)
###################################################
### code chunk number 6: clpAPI.Rnw:96-97
###################################################
ja <- c(0, 3, 6, 9)
###################################################
### code chunk number 7: clpAPI.Rnw:100-101
###################################################
ar <- c(2, 4, 3, 3, 1, 4, 1, 2, 2)
###################################################
### code chunk number 8: clpAPI.Rnw:104-105
###################################################
clb <- rep(0, 3)
###################################################
### code chunk number 9: clpAPI.Rnw:108-109
###################################################
rub <- c(5, 11, 8)
###################################################
### code chunk number 10: clpAPI.Rnw:112-113
###################################################
obj <- c(5, 4, 3)
###################################################
### code chunk number 11: clpAPI.Rnw:116-117
###################################################
loadProblemCLP(prob, nc, nr, ia, ja, ar, clb, NULL, obj, NULL, rub)
###################################################
### code chunk number 12: clpAPI.Rnw:120-121
###################################################
solveInitialCLP(prob)
###################################################
### code chunk number 13: clpAPI.Rnw:124-125
###################################################
getObjValCLP(prob)
###################################################
### code chunk number 14: clpAPI.Rnw:129-130
###################################################
getColPrimCLP(prob)
###################################################
### code chunk number 15: clpAPI.Rnw:134-135
###################################################
getColDualCLP(prob)
###################################################
### code chunk number 16: clpAPI.Rnw:138-139
###################################################
delProbCLP(prob)
###################################################
### code chunk number 17: clpAPI.Rnw:154-155
###################################################
help("Clp_addColumns")
###################################################
### code chunk number 18: clpAPI.Rnw:165-167
###################################################
c2r <- system.file(package = "clpAPI", "c2r.map")
source(c2r)
###################################################
### code chunk number 19: clpAPI.Rnw:170-172
###################################################
pr1 <- initProbCLP()
delProbCLP(pr1)
###################################################
### code chunk number 20: clpAPI.Rnw:175-177
###################################################
pr2 <- Clp_newModel()
Clp_deleteModel(pr2)
\documentclass[a4paper,headings=small]{scrartcl}
\usepackage[english]{babel}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage{textcomp,lmodern}
\typearea[current]{last}
\usepackage{fixltx2e,mparhack,mathdots}
\usepackage{natbib}
\usepackage{hyperref}
\bibliographystyle{abbrvnat}
\usepackage{microtype}
\newcommand{\Comp}[1]{\texttt{#1}}
\addtolength{\skip\footins}{0.5\baselineskip}
\usepackage{fnpos}
\hypersetup{
pdftitle = {clpAPI -- Quick Start},
pdfauthor = {Gabriel Gelius-Dietrich},
pdfsubject = {R Interface to C API of COIN-OR Clp},
pdfkeywords = {Optimization, COIN-OR Clp},
pdfborder = {0 0 0},
pdfhighlight = {/N}
}
\newcommand{\pkg}[1]{\emph{#1}}
\newcommand{\pkgname}{\pkg{clpAPI}}
\newcommand{\prgname}[1]{\textsc{#1}}
\begin{document}
\title{clpAPI -- Quick Start}
%\VignetteIndexEntry{Package clpAPI -- Quick Start}
\author{Gabriel Gelius-Dietrich}
\maketitle
\section{Introduction}
The package \pkgname{} provides a low level interface to the C~API of
COIN-OR Clp\footnote{COIN-OR linear programming version 1.12.0 or higher
\url{https://projects.coin-or.org/Clp}} (COIN-OR linear programming).
The package \pkgname{} relies on a separate installation of COIN-OR Clp.
\section{Installation}
See \Comp{INSTALL} for installation instructions and platform specific details.
\section{Usage}
In the following, an example lp-problem will be created and solved:
\noindent
\hspace{.5in} maximize
$$z = 5 x_1 + 4 x_2 + 3 x_3$$
\hspace{.5in} subject to
$$
\begin{array}{r@{\:}c@{\:}r@{\:}c@{\:}r@{\:}c@{\:}r}
2 x_1 &+& 3 x_2 &+& x_3 & \leq 5 \\
4 x_1 &+& x_2 &+& 2 x_3 & \leq 11 \\
3 x_1 &+& 4 x_2 &+& 2 x_3 & \leq 8 \\
\end{array}
$$
\hspace{.5in} where all variables are non-negative
$$x_1 \geq 0, \ x_2 \geq 0, \ x_3 \geq 0$$
\noindent
Load the library.
<<>>=
library(clpAPI)
@
Create a problem object.
<<>>=
prob <- initProbCLP()
@
Set the direction of optimization ($-1$: maximize, $1$: minimize).
<<>>=
setObjDirCLP(prob, -1)
@
Prepare data structures for the problem object. Number of columns and rows:
<<>>=
nc <- 3
nr <- 3
@
The constraint matrix is passed in column major order format. \textbf{Be
careful here:} all indices start with 0! Row indices.
<<>>=
ia <- c(0, 1, 2, 0, 1, 2, 0, 1, 2)
@
Column indices.
<<>>=
ja <- c(0, 3, 6, 9)
@
Non-zero elements.
<<>>=
ar <- c(2, 4, 3, 3, 1, 4, 1, 2, 2)
@
Lower bounds for the variables (columns).
<<>>=
clb <- rep(0, 3)
@
Right hand side (row upper bounds for the rows).
<<>>=
rub <- c(5, 11, 8)
@
Objective coefficients.
<<>>=
obj <- c(5, 4, 3)
@
Load problem data into the problem object.
<<>>=
loadProblemCLP(prob, nc, nr, ia, ja, ar, clb, NULL, obj, NULL, rub)
@
Solve the problem using the simplex algorithm.
<<>>=
solveInitialCLP(prob)
@
Retrieve the value of the objective function after optimization.
<<>>=
getObjValCLP(prob)
@
Retrieve the primal values of the structural variables (columns) after
optimization.
<<>>=
getColPrimCLP(prob)
@
Retrieve the dual values of the structural variables (columns) after
optimization (reduced costs).
<<>>=
getColDualCLP(prob)
@
Free memory, allacated to the problem object.
<<>>=
delProbCLP(prob)
@
\section{Function names}
\subsection{Searching}
The function names in \pkgname{} are different from the names in
\prgname{COIN-OR Clp},
e.\,g. the function \texttt{addColsCLP} in \pkgname{} is called
\texttt{Clp\_addColumns} in \prgname{COIN-OR Clp}. The directory \texttt{inst/}
containes a file \texttt{c2r.map} which maps a \prgname{COIN-OR Clp} function
name to the corresponding \pkgname{} function name. Additionally, all man-pages
contain an alias to the \prgname{COIN-OR Clp} function name. The call
<<>>=
help("Clp_addColumns")
@
will bring up the man-page of \texttt{addColsCLP}.
\subsection{Mapping}
The file \texttt{c2r.map} in \texttt{inst/} maps the \pkgname{} function names
to the orininal \prgname{COIN-OR Clp} function names of its C-API.
To use the latter, run
<<>>=
c2r <- system.file(package = "clpAPI", "c2r.map")
source(c2r)
@
now either
<<>>=
pr1 <- initProbCLP()
delProbCLP(pr1)
@
or the original functions
<<>>=
pr2 <- Clp_newModel()
Clp_deleteModel(pr2)
@
work both. Keep in mind that the mapping only affects the function names not the
arguments of a function.
\end{document}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment