| Title: | Interface to the SCIP Optimization Suite |
| Version: | 1.10.0-2 |
| Description: | Provides an R interface to SCIP (Solving Constraint Integer Programs), a framework for mixed-integer programming (MIP), mixed-integer nonlinear programming (MINLP), and constraint integer programming (2025, <doi:10.48550/arXiv.2511.18580>). Supports linear, quadratic, SOS, indicator, and knapsack constraints with continuous, binary, and integer variables. Includes a one-shot solver interface and a model-building API for incremental problem construction. |
| License: | Apache License (≥ 2) |
| URL: | https://github.com/bnaras/scip, https://scipopt.org/ |
| BugReports: | https://github.com/bnaras/scip/issues |
| Depends: | R (≥ 4.0) |
| Imports: | methods, Matrix |
| Suggests: | tinytest, slam, knitr, rmarkdown |
| VignetteBuilder: | knitr |
| SystemRequirements: | CMake (>= 3.11), GNU make, C++17 |
| Encoding: | UTF-8 |
| RoxygenNote: | 7.3.3 |
| NeedsCompilation: | yes |
| Packaged: | 2026-03-31 01:10:17 UTC; naras |
| Author: | Balasubramanian Narasimhan
|
| Maintainer: | Balasubramanian Narasimhan <naras@stanford.edu> |
| Repository: | CRAN |
| Date/Publication: | 2026-04-03 09:00:02 UTC |
scip: R Interface to the SCIP Optimization Suite
Description
Provides an R interface to SCIP (Solving Constraint Integer Programs), a framework for mixed-integer programming (MIP), mixed-integer nonlinear programming (MINLP), and constraint integer programming. Supports linear, quadratic, SOS, indicator, and knapsack constraints with continuous, binary, and integer variables. Includes a one-shot solver interface and a model-building API for incremental problem construction.
Author(s)
Maintainer: Balasubramanian Narasimhan naras@stanford.edu (ORCID)
Other contributors:
SCIP Optimization Suite Authors (SCIP, SoPlex, PaPILO libraries) [copyright holder]
See Also
Useful links:
Report bugs at https://github.com/bnaras/scip/issues
Convert a matrix to CSC (Compressed Sparse Column) format
Description
Convert a matrix to CSC (Compressed Sparse Column) format
Usage
make_csc_matrix(x)
Arguments
x |
A matrix, dgCMatrix, or simple_triplet_matrix |
Value
A list with components i (row indices, 0-based),
p (column pointers, 0-based), x (values),
nrow, ncol
Print method for scip_control objects
Description
Print method for scip_control objects
Usage
## S3 method for class 'scip_control'
print(x, ...)
Arguments
x |
A |
... |
Ignored. |
Value
Invisible x.
Add an indicator constraint to a SCIP model
Description
If binvar = 1 then sum(coefs * x[vars]) <= rhs.
Usage
scip_add_indicator_cons(model, binvar, vars, coefs, rhs, name = NULL)
Arguments
model |
A SCIP model. |
binvar |
Integer; 1-based index of the binary indicator variable. |
vars |
Integer vector; 1-based variable indices. |
coefs |
Numeric vector; coefficients. |
rhs |
Numeric; right-hand side. |
name |
Character; constraint name. |
Value
Integer; 1-based constraint index.
Add a linear constraint to a SCIP model
Description
Adds lhs <= sum(coefs * x[vars]) <= rhs.
Usage
scip_add_linear_cons(model, vars, coefs, lhs = -Inf, rhs = Inf, name = NULL)
Arguments
model |
A SCIP model. |
vars |
Integer vector; 1-based variable indices. |
coefs |
Numeric vector; coefficients (same length as |
lhs |
Numeric; left-hand side. Default |
rhs |
Numeric; right-hand side. Default |
name |
Character; constraint name. Default auto-generated. |
Value
Integer; 1-based constraint index.
Add a quadratic constraint to a SCIP model
Description
Adds lhs <= linexpr + quadexpr <= rhs where
quadexpr = sum(quadcoefs[k] * x[quadvars1[k]] * x[quadvars2[k]]).
Usage
scip_add_quadratic_cons(
model,
linvars = integer(0),
lincoefs = double(0),
quadvars1 = integer(0),
quadvars2 = integer(0),
quadcoefs = double(0),
lhs = -Inf,
rhs = Inf,
name = NULL
)
Arguments
model |
A SCIP model. |
linvars |
Integer vector; 1-based variable indices for linear part. |
lincoefs |
Numeric vector; linear coefficients. |
quadvars1, quadvars2 |
Integer vectors; 1-based variable indices for quadratic terms. |
quadcoefs |
Numeric vector; quadratic coefficients. |
lhs, rhs |
Numeric; constraint bounds. |
name |
Character; constraint name. |
Value
Integer; 1-based constraint index.
Add a SOS1 constraint to a SCIP model
Description
At most one variable in the set can be nonzero.
Usage
scip_add_sos1_cons(model, vars, weights = NULL, name = NULL)
Arguments
model |
A SCIP model. |
vars |
Integer vector; 1-based variable indices. |
weights |
Numeric vector; weights determining branching order. |
name |
Character; constraint name. |
Value
Integer; 1-based constraint index.
Add a SOS2 constraint to a SCIP model
Description
At most two adjacent variables in the set can be nonzero.
Usage
scip_add_sos2_cons(model, vars, weights = NULL, name = NULL)
Arguments
model |
A SCIP model. |
vars |
Integer vector; 1-based variable indices. |
weights |
Numeric vector; weights determining adjacency order. |
name |
Character; constraint name. |
Value
Integer; 1-based constraint index.
Add a variable to a SCIP model
Description
Add a variable to a SCIP model
Usage
scip_add_var(model, obj, lb = 0, ub = Inf, vtype = "C", name = NULL)
Arguments
model |
A SCIP model (external pointer from |
obj |
Numeric; objective coefficient. |
lb |
Numeric; lower bound. Default |
ub |
Numeric; upper bound. Default |
vtype |
Character; variable type: |
name |
Character; variable name. Default auto-generated. |
Value
Integer; 1-based variable index.
Add multiple variables to a SCIP model
Description
Add multiple variables to a SCIP model
Usage
scip_add_vars(model, obj, lb = 0, ub = Inf, vtype = "C", names = NULL)
Arguments
model |
A SCIP model. |
obj |
Numeric vector; objective coefficients. |
lb |
Numeric; lower bounds (scalar or vector). Default |
ub |
Numeric; upper bounds (scalar or vector). Default |
vtype |
Character; variable types (scalar or vector). Default |
names |
Character vector; variable names. Default auto-generated. |
Value
Integer; 1-based index of first variable added.
SCIP solver control parameters
Description
Create a list of control parameters for the SCIP solver. Parameters are
organized into logical groups: output, limits, tolerances, presolving,
LP, branching, and heuristics. Any SCIP parameter can also be set directly
using its native path via ....
Usage
scip_control(
verbose = TRUE,
verbosity_level = 3L,
display_freq = 100L,
time_limit = Inf,
node_limit = -1L,
stall_node_limit = -1L,
sol_limit = -1L,
best_sol_limit = -1L,
mem_limit = Inf,
restart_limit = -1L,
gap_limit = 0,
abs_gap_limit = 0,
feastol = 1e-06,
dualfeastol = 1e-07,
epsilon = 1e-09,
presolving = TRUE,
presolve_rounds = -1L,
lp_threads = 1L,
lp_iteration_limit = -1L,
lp_scaling = TRUE,
branching_score = "p",
heuristics_emphasis = "default",
threads = 1L,
...
)
Arguments
verbose |
Logical; print solver output. Default |
verbosity_level |
Integer 0–5; verbosity detail. Default |
display_freq |
Integer; node display frequency. Default |
time_limit |
Numeric; time limit in seconds. Default |
node_limit |
Integer; max nodes. Default |
stall_node_limit |
Integer; stall nodes. Default |
sol_limit |
Integer; solution limit. Default |
best_sol_limit |
Integer; improving solution limit. Default |
mem_limit |
Numeric; memory limit in MB. Default |
restart_limit |
Integer; restart limit. Default |
gap_limit |
Numeric; relative MIP gap. Default |
abs_gap_limit |
Numeric; absolute gap. Default |
feastol |
Numeric; feasibility tolerance. Default |
dualfeastol |
Numeric; dual feasibility tolerance. Default |
epsilon |
Numeric; zero tolerance. Default |
presolving |
Logical; enable presolving. Default |
presolve_rounds |
Integer; presolve rounds. Default |
lp_threads |
Integer; LP solver threads. Default |
lp_iteration_limit |
Integer; LP iteration limit. Default |
lp_scaling |
Logical; LP scaling. Default |
branching_score |
Character; score function. Default |
heuristics_emphasis |
Character; heuristic emphasis. Default |
threads |
Integer; parallel solving threads. Default |
... |
Additional SCIP parameters as name-value pairs, using SCIP's
native hierarchical parameter paths (e.g., |
Value
A named list of class "scip_control" with components:
verboseLogical; verbosity flag.
scip_paramsNamed list; all parameters as SCIP native paths.
Output
verboseLogical; print solver output. Default
TRUE.verbosity_levelInteger 0–5; verbosity detail (0 = none, 3 = normal, 5 = full). Default
3. Ignored ifverbose = FALSE.display_freqInteger; display a status line every this many nodes (
-1= never). Default100.
Termination Limits
time_limitNumeric; maximum solving time in seconds. Default
Inf(no limit).node_limitInteger; maximum number of branch-and-bound nodes. Default
-1L(no limit).stall_node_limitInteger; nodes without improvement before stopping. Default
-1L(no limit).sol_limitInteger; stop after finding this many feasible solutions. Default
-1L(no limit).best_sol_limitInteger; stop after this many improving solutions. Default
-1L(no limit).mem_limitNumeric; memory limit in MB. Default
Inf(no limit).restart_limitInteger; maximum restarts. Default
-1L(no limit).
Tolerances
gap_limitNumeric; relative MIP gap tolerance; solver stops when the gap falls below this value. Default
0(prove optimality).abs_gap_limitNumeric; absolute gap between primal and dual bound. Default
0.feastolNumeric; feasibility tolerance for LP constraints. Default
1e-6.dualfeastolNumeric; dual feasibility tolerance. Default
1e-7.epsilonNumeric; absolute values below this are treated as zero. Default
1e-9.
Presolving
presolvingLogical; enable presolving. Default
TRUE.presolve_roundsInteger; maximum presolving rounds (
-1= unlimited). Default-1L.
LP
lp_threadsInteger; number of threads for LP solver. Default
1L.lp_iteration_limitInteger; LP iteration limit per solve (
-1= no limit). Default-1L.lp_scalingLogical; enable LP scaling. Default
TRUE.
Branching
branching_scoreCharacter; branching score function:
"s"(sum),"p"(product),"q"(quotient). Default"p".
Heuristics
heuristics_emphasisCharacter; heuristic emphasis setting:
"default","aggressive","fast", or"off". Default"default".
Parallel
threadsInteger; number of threads for concurrent solving. Default
1L. Note: concurrent solving may require a SCIP build compiled with parallel support (e.g.,PARASCIP=true); not all installations provide this.
See Also
Examples
## Quick solve with 60-second time limit
ctrl <- scip_control(time_limit = 60)
## Quiet solve with 1% gap tolerance
ctrl <- scip_control(verbose = FALSE, gap_limit = 0.01)
## Aggressive heuristics, no presolving
ctrl <- scip_control(heuristics_emphasis = "aggressive", presolving = FALSE)
## Pass a native SCIP parameter directly
ctrl <- scip_control("conflict/enable" = FALSE, "separating/maxrounds" = 5L)
Get solver information
Description
Get solver information
Usage
scip_get_info(model)
Arguments
model |
A SCIP model (after |
Value
A list with solve_time, nodes, iterations,
gap, sol_count.
Get number of solutions found
Description
Get number of solutions found
Usage
scip_get_nsols(model)
Arguments
model |
A SCIP model (after |
Value
Integer.
Get objective value of best solution
Description
Get objective value of best solution
Usage
scip_get_objval(model)
Arguments
model |
A SCIP model (after |
Value
Numeric; objective value, or NA if no solution.
Get the k-th solution from the solution pool
Description
Get the k-th solution from the solution pool
Usage
scip_get_sol(model, k)
Arguments
model |
A SCIP model. |
k |
Integer; 1-based solution index (1 = best). |
Value
A list with objval and x.
Get the best solution
Description
Get the best solution
Usage
scip_get_solution(model)
Arguments
model |
A SCIP model (after |
Value
A list with objval and x.
Get solver status
Description
Get solver status
Usage
scip_get_status(model)
Arguments
model |
A SCIP model (after |
Value
Character; status string (e.g., "optimal", "infeasible").
Create a SCIP model
Description
Creates a new SCIP optimization model for incremental problem construction.
Usage
scip_model(name = "scip_model")
Arguments
name |
Character; problem name. Default |
Value
An external pointer representing the SCIP model.
Free a SCIP model
Description
Explicitly frees the SCIP model and all associated memory. The model is also freed automatically when garbage collected.
Usage
scip_model_free(model)
Arguments
model |
A SCIP model. |
Value
Invisible NULL.
Solve a SCIP model
Description
Solve a SCIP model
Usage
scip_optimize(model)
Arguments
model |
A SCIP model. |
Value
Invisible NULL. Use scip_get_status and
scip_get_solution to retrieve results.
Set objective sense
Description
Set objective sense
Usage
scip_set_objective_sense(model, sense = "minimize")
Arguments
model |
A SCIP model. |
sense |
Character; |
Value
Invisible NULL.
Set a SCIP parameter
Description
Set a SCIP parameter
Usage
scip_set_param(model, name, value)
Arguments
model |
A SCIP model. |
name |
Character; SCIP parameter name (e.g., |
value |
The parameter value (type is auto-detected by SCIP). |
Value
Invisible NULL.
Solve a linear or mixed-integer program using SCIP
Description
One-shot interface to the SCIP solver. Formulates and solves:
\min_{x} \; obj' x
subject to constraint rows defined by A, b, sense,
with variable types vtype and bounds lb, ub.
Usage
scip_solve(obj, A, b, sense, vtype = "C", lb = 0, ub = Inf, control = list())
Arguments
obj |
Numeric vector of length |
A |
Constraint matrix ( |
b |
Numeric vector of length |
sense |
Character vector of length |
vtype |
Character; variable types. Either a single value applied to all
variables, or a vector of length |
lb |
Numeric; lower bounds for variables. Single value or vector of
length |
ub |
Numeric; upper bounds for variables. Single value or vector of
length |
control |
A list of solver parameters, typically from |
Value
A named list with components:
- status
Character; solver status (e.g., "optimal", "infeasible", "unbounded").
- objval
Numeric; optimal objective value (or
NAif no solution).- x
Numeric vector; primal solution (or
NULLif no solution).- sol_count
Integer; number of solutions found.
- gap
Numeric; relative optimality gap.
- info
List with additional solver information (solve_time, iterations, nodes).