Description Details Author(s) References Examples
A low level interface to COIN-OR Clp (COIN Linear Program code).
The package clpAPI
provides access to the callable library
of COIN-OR Clp from within R.
Gabriel Gelius-Dietrich <geliudie@uni-duesseldorf.de>
Maintainer: Mayo Roettger <mayo.roettger@hhu.de>
The COIN-OR Clp home page at https://projects.coin-or.org/Clp
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 | # load package
library(clpAPI)
# preparing the model
lp <- initProbCLP()
nrows <- 5
ncols <- 8
# objective function
obj <- c(1, 0, 0, 0, 2, 0, 0, -1)
# upper and lower bounds of the rows
rlower <- c(2.5, -1000, 4, 1.8, 3)
rupper <- c(1000, 2.1, 4, 5, 15)
# upper and lower bounds of the columns
clower <- c(2.5, 0, 0, 0, 0.5, 0, 0, 0)
cupper <- c(1000, 4.1, 1, 1, 4, 1000, 1000, 4.3)
# constraint matrix
ia <- c(0, 4, 0, 1, 1, 2, 0, 3, 0, 4, 2, 3, 0, 4)
ja <- c(0, 2, 4, 6, 8, 10, 11, 12, 14)
ar <- c(3.0, 5.6, 1.0, 2.0, 1.1, 1.0, -2.0, 2.8,
-1.0, 1.0, 1.0, -1.2, -1.0, 1.9)
# direction of optimization
setObjDirCLP(lp, 1)
# load problem data
loadProblemCLP(lp, ncols, nrows, ia, ja, ar,
clower, cupper, obj, rlower, rupper)
# solve lp problem
solveInitialCLP(lp)
# retrieve the results
getSolStatusCLP(lp)
getObjValCLP(lp)
getColPrimCLP(lp)
# remove problem object
delProbCLP(lp)
|
using COIN OR Clp version 1.15.5
Coin0506I Presolve 2 (-3) rows, 3 (-5) columns and 6 (-8) elements
Clp0006I 0 Obj 3.5 Dual inf 2.9473683 (1)
Clp0006I 1 Obj 3.2368421
Clp0000I Optimal - objective value 3.2368421
Coin0511I After Postsolve, objective 3.2368421, infeasibilities - dual 0 (0), primal 0 (0)
Clp0032I Optimal objective 3.236842105 - 1 iterations time 0.002, Presolve 0.00
[1] 0
[1] 0
[1] 3.236842
[1] 2.5000000 0.0000000 0.0000000 0.6428571 0.5000000 4.0000000 0.0000000
[8] 0.2631579
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.