knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "README-" )
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.
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")
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.
The following system command can be used to install dependences.
sudo apt-get install coinor-libcbc-dev coinor-libclp-dev
The following system command can be used to install dependencies.
sudo yum install coin-or-Cbc-devel coin-or-Clp-devel
The following system command can be used to install dependencies using Homebrew package manager. After installing CBC and its dependencies, they need to linked in order to install the rcbc package. Please note that if you have previously installed these software, then they will be overwritten with the newer versions.
brew tap coin-or-tools/coinor brew install coin-or-tools/coinor/cbc brew link cbc --force brew link coinutils --force brew link osi --force brew link clp --force brew link cgl --force
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) # extract solution values column_solution(result) # extract objective value for solution objective_value(result)
There is now a work in progress ROI plugin.
Feel free to open issues and send pull requests.
Please cite the rcbc R package and the CBC solver in publications.
citation("rcbc")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.