| Type: | Package |
| Title: | 'COIN-OR' 'Clp' Plugin for the 'R' Optimization Infrastructure |
| Version: | 0.1.0 |
| Description: | Registers the 'COIN-OR' 'Clp' linear programming solver, through the 'coinclp' package, with the 'R' Optimization Infrastructure ('ROI'). Linear programs with continuous variables are then solved by ROI_solve(op, solver = "coinclp"), keeping sparse constraint matrices sparse all the way to the solver, and returning dual values, reduced costs and row activities alongside the primal solution. |
| License: | EPL |
| URL: | https://github.com/SamLovick/ROI.plugin.coinclp |
| BugReports: | https://github.com/SamLovick/ROI.plugin.coinclp/issues |
| Encoding: | UTF-8 |
| Depends: | R (≥ 4.0) |
| Imports: | coinclp (≥ 0.1.0), methods, ROI (≥ 1.0-0), slam, stats |
| Suggests: | Matrix, ROI.plugin.highs |
| NeedsCompilation: | no |
| Config/roxygen2/version: | 8.1.0 |
| Packaged: | 2026-09-15 15:10:23 UTC; samlo |
| Author: | Sam Lovick [aut, cre] |
| Maintainer: | Sam Lovick <sam@lovickconsulting.com> |
| Repository: | CRAN |
| Date/Publication: | 2026-09-28 08:10:13 UTC |
Solve linear programs in ROI with COIN-OR Clp
Description
Registers the COIN-OR Clp solver, through the coinclp package, with
the R Optimization Infrastructure. Loading this package is all the setup
there is: linear programs can then be solved with
ROI_solve(op, solver = "coinclp"), and "coinclp" joins the
solvers ROI_solve() picks from automatically.
Details
The plugin accepts a linear objective, linear constraints, continuous
variables and variable bounds, minimising or maximising. Constraints
given as a simple_triplet_matrix, which is how ROI stores
them, are passed to Clp in sparse form without being densified.
Solver controls
Pass these to ROI_solve as named arguments or in
control:
log_levelHow much Clp prints, 0 (silent, the default) to 4. Also accepted as
amountorverbosity_level, the names the earlier ROI.plugin.clp used.max_iterationsIteration limit; also
iterations.max_secondsTime limit in seconds; also
seconds.algorithmOne of
"auto"(the default),"primal","dual","barrier"or"barrier_nocross".presolveRun Clp's presolve,
TRUEby default.primal_tolerance,dual_toleranceSimplex tolerances.
scalingScaling mode: 0 off, 1 equilibrium, 2 geometric, 3 auto, 4 dynamic.
Solution
Besides the primal solution and the objective value,
solution(x, "dual") gives the dual value of each constraint and
solution(x, "aux") the row activities and reduced costs.
solution(x, "msg") returns the whole coinclp result,
including the iteration count.
Relation to ROI.plugin.clp
This package replaces ROI.plugin.clp, which was archived from CRAN in
January 2022 because the clpAPI package it depended on had been
archived. The code here is independent of that plugin; the control names
amount, verbosity_level, iterations and
seconds are kept so that scripts written for it still work, but
the solver is now named "coinclp" rather than "clp".
Author(s)
Maintainer: Sam Lovick sam@lovickconsulting.com
Authors:
Sam Lovick sam@lovickconsulting.com
See Also
Useful links:
Report bugs at https://github.com/SamLovick/ROI.plugin.coinclp/issues
Examples
library(ROI)
op <- OP(objective = c(143, 60),
constraints = L_constraint(rbind(c(120, 210), c(110, 30), c(1, 1)),
rep("<=", 3), c(15000, 4000, 75)),
maximum = TRUE)
result <- ROI_solve(op, solver = "coinclp", log_level = 0)
solution(result)
solution(result, "objval")
Dual values and auxiliary quantities
Description
solution(x, "dual") returns the dual value of each constraint, the
shadow price of its right hand side. solution(x, "aux") returns a
list with the row activities as primal and the reduced costs of the
variables as dual.
Usage
## S3 method for class 'coinclp_solution'
ROI_plugin_solution_dual(x)
## S3 method for class 'coinclp_solution'
ROI_plugin_solution_aux(x)
Arguments
x |
A solution returned by |
Details
Signs follow Clp's own convention for the direction that was solved, so a maximisation and the equivalent minimisation of the negated objective report duals of opposite sign.
Value
A numeric vector of dual values, or a list of auxiliary vectors.
Examples
library(ROI)
op <- OP(objective = c(143, 60),
constraints = L_constraint(rbind(c(120, 210), c(110, 30), c(1, 1)),
rep("<=", 3), c(15000, 4000, 75)),
maximum = TRUE)
result <- ROI_solve(op, solver = "coinclp")
solution(result, "dual")
solution(result, "aux")
Solve a linear program with Clp
Description
The method ROI dispatches to when a linear program is solved with
solver = "coinclp". It is not called directly; use
ROI_solve.
Usage
solve_OP(x, control = list())
Arguments
x |
An object of class |
control |
A named list of solver controls, see
|
Value
An object of class "coinclp_solution", which
solution unpacks.
Examples
library(ROI)
op <- OP(objective = c(143, 60),
constraints = L_constraint(rbind(c(120, 210), c(110, 30), c(1, 1)),
rep("<=", 3), c(15000, 4000, 75)),
maximum = TRUE)
result <- ROI_solve(op, solver = "coinclp")
solution(result)
solution(result, "dual")