https://github.com/dirkschumacher/rcbc
COIN-OR branch and cut (CBC) bindings for R
https://github.com/dirkschumacher/rcbc
cbc coin integer-programming linear-programming r solver
Last synced: 5 months ago
JSON representation
COIN-OR branch and cut (CBC) bindings for R
- Host: GitHub
- URL: https://github.com/dirkschumacher/rcbc
- Owner: dirkschumacher
- License: other
- Created: 2016-11-13T16:10:42.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2024-11-12T22:39:19.000Z (11 months ago)
- Last Synced: 2024-11-12T23:27:48.928Z (11 months ago)
- Topics: cbc, coin, integer-programming, linear-programming, r, solver
- Language: R
- Homepage: https://dirkschumacher.github.io/rcbc/
- Size: 237 KB
- Stars: 20
- Watchers: 7
- Forks: 5
- Open Issues: 10
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE
Awesome Lists containing this project
README
---
output: github_document
---```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "README-"
)
```# CBC bindings for R
[](https://lifecycle.r-lib.org/articles/stages.html)
[](https://github.com/dirkschumacher/rcbc/actions)
[](https://github.com/dirkschumacher/rcbc/actions)
[](https://github.com/dirkschumacher/rcbc/actions)
[](https://github.com/dirkschumacher/rcbc/actions)
[](https://app.codecov.io/github/dirkschumacher/rcbc?branch=master)
[](https://CRAN.R-project.org/package=rcbc)The _rcbc_ package provides an interface to the [_CBC_ (COIN-OR branch and cut)](https://github.com/coin-or/Cbc) 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](https://www.coin-or.org/). 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](https://cran.r-project.org/). To install this package, please use the following _R_ code to install it from the [source code repository on GitHub](https://github.com/dirkschumacher/rcbc). Please note that [CBC solver](https://github.com/coin-or/Cbc) header and library files also need be installed prior to installing this _R_ package (see below for details).
```{r, eval = FALSE}
if (!require(remotes))
install.packages("remotes")
remotes::install_github("dirkschumacher/rcbc")
```### Windows
The package can be installed from source when the [Rtools](https://cran.r-project.org/bin/windows/Rtools/) software is installed. Specifically, the [CBC solver](https://github.com/coin-or/Cbc) header and library files are automatically downloaded from [RWinLib](https://github.com/rwinlib/cbc).
### Linux
#### Debian/Ubuntu
The following system command can be used to install dependences.
```
sudo apt-get install coinor-libcbc-dev coinor-libclp-dev
```#### Fedora
The following system command can be used to install dependencies.
```
sudo yum install coin-or-Cbc-devel coin-or-Clp-devel
```### macOS
The following system command can be used to install dependencies using [Homebrew package manager](https://brew.sh/). 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
```## Usage
Here we will provide a brief example showing how the package can be used to solve an optimization problem (see [package vignette](https://dirkschumacher.github.io/rcbc/articles/rcbc.html) for more details).
```{r}
# 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)
```## ROI plugin
There is now a work in progress [ROI plugin](https://github.com/dirkschumacher/ROI.plugin.cbc).
## Contribution
Feel free to open issues and send pull requests.
## Citation
Please cite the _rcbc_ R package and the [CBC solver](https://github.com/coin-or/Cbc) in publications.
```{r, echo = FALSE, result = "asis", comment = ""}
citation("rcbc")
```