forked from dirkschumacher/rcbc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
113 lines (80 loc) · 4.28 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "README-"
)
```
# CBC bindings for R
<!-- badges: start -->
[![Lifecycle: experimental](https://img.shields.io/badge/Lifecycle-experimental-orange.svg)](https://www.tidyverse.org/lifecycle/#experimental)
[![R-CMD-check-Ubuntu](https://img.shields.io/github/workflow/status/dirkschumacher/rcbc/Ubuntu/master.svg?label=Ubuntu)](https://github.com/dirkschumacher/rcbc/actions)
[![R-CMD-check-Windows](https://img.shields.io/github/workflow/status/dirkschumacher/rcbc/Windows/master.svg?label=Windows)](https://github.com/dirkschumacher/rcbc/actions)
[![R-CMD-check-Mac-OSX](https://img.shields.io/github/workflow/status/dirkschumacher/rcbc/Mac%20OSX/master.svg?label=Mac%20OSX)](https://github.com/dirkschumacher/rcbc/actions)
[![Documentation](https://img.shields.io/github/workflow/status/dirkschumacher/rcbc/Documentation/master.svg?label=Documentation)](https://github.com/dirkschumacher/rcbc/actions)
[![codecov](https://codecov.io/gh/dirkschumacher/rcbc/branch/master/graph/badge.svg)](https://codecov.io/gh/dirkschumacher/rcbc)
[![CRAN status](https://www.r-pkg.org/badges/version/rcbc)](https://CRAN.R-project.org/package=rcbc)
<!-- badges: end -->
The _rcbc_ package provides an interface to the [_CBC_ (COIN-OR branch and cut)](https://projects.coin-or.org/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](http://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://projects.coin-or.org/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://projects.coin-or.org/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 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](https://brew.sh/).
```
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](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://projects.coin-or.org/Cbc) in publications.
```{r, echo = FALSE, result = "asis", comment = ""}
citation("rcbc")
```