CBC bindings for R
The rcbc package provides an interface to the CBC (COIN-OR branch and cut) solver. Specifically, CBC is an open-source mixed integer programming solver that is developed as part of the Computational Infrastructure for Operations Research (COIN-OR) project. By interfacing with the CBC solver, the rcbc package can be used to generate optimal solutions to optimization problems. Please note that this package is under active development and is still a work in progress.
Installation
The package is not yet available on The Comprehensive R Archive Network. To install this package, please use the following R code to install it from the source code repository on GitHub. Please note that CBC solver header and library files also need be installed prior to installing this R package (see below for details).
if (!require(remotes))
install.packages("remotes")
remotes::install_github("dirkschumacher/rcbc")
Windows
The package can be installed from source when the Rtools software is installed. Specifically, the CBC solver header and library files are automatically downloaded from RWinLib.
Linux
Debian/Ubuntu
The following system command can be used install dependences.
sudo apt-get install coinor-libcbc-dev coinor-libclp-dev
Fedora
The following system command can be used install dependences.
sudo yum install coin-or-Cbc-devel coin-or-Clp-devel
Mac OSX
The following system command can be used install dependences using Homebrew package manager.
brew install coin-or-tools/coinor/cbc
Usage
Here we will provide a brief example showing how the package can be used to solve an optimization problem (see package vignette for more details).
# load package
library(rcbc)
# define optimization problem and solve it
## max 1 * x + 2 * y
## s.t.
## x + y <= 1
## x, y binary
result <- cbc_solve(
obj = c(1, 2),
mat = matrix(c(1, 1), ncol = 2, nrow = 1),
is_integer = c(TRUE, TRUE),
row_lb = -Inf, row_ub = 1, max = TRUE,
col_lb = c(0, 0), col_ub = c(1, 1),
cbc_args = list("SEC" = "1"))
# extract solution status
solution_status(result)
#> [1] "optimal"
# extract solution values
column_solution(result)
#> [1] 0 1
# extract objective value for solution
objective_value(result)
#> [1] 2
ROI plugin
There is now a work in progress ROI plugin.
Contribution
Feel free to open issues and send pull requests.
Citation
Please cite the rcbc R package and the CBC solver in publications.
To cite the rcbc package in publications, use:
Schumacher D, Ooms J, Yapparov B, and Hanson JO (2022) rcbc: COIN CBC
MILP Solver Bindings. R package version 0.1.0.9001.
https://github.com/dirkschumacher/rcbc
Forrest J and Lougee-Heimer R (2005) CBC User Guide. In Emerging
theory, Methods, and Applications (pp. 257--277). INFORMS,
Catonsville, MD.
Please cite both COIN-OR CBC and this package.
To see these entries in BibTeX format, use 'print(<citation>,
bibtex=TRUE)', 'toBibtex(.)', or set
'options(citation.bibtex.max=999)'.