| Title: | Conic Benchmark Format (CBF) Plugin for the R Optimization Infrastructure |
|---|---|
| Description: | Provides read and write support for the Conic Benchmark Format (CBF, version 4) within the R Optimization Infrastructure ('ROI'). Supported cone types include the positive orthant, second-order (SOC), rotated second-order (bridged automatically to standard SOC), exponential (primal and dual), power (primal and dual), and semidefinite (symmetric-vectorised) cones, as well as their mixed-integer variants. The reader translates a .cbf file into an ROI 'OP' object, handling coordinate-convention differences between CBF and ROI transparently; the writer serialises an ROI 'OP' object back to CBF plain-text. |
| Authors: | Benjamin Schwendinger [aut, cre] |
| Maintainer: | Benjamin Schwendinger <[email protected]> |
| License: | GPL-3 |
| Version: | 0.1-0 |
| Built: | 2026-05-22 08:33:54 UTC |
| Source: | https://github.com/cran/ROI.format.cbf |
Downloads one Conic Benchmark Library (CBLIB) instance from
https://cblib.zib.de/download/all/. By default the downloaded
.cbf.gz archive is decompressed to a plain .cbf file so it can
be passed directly to read_cbf.
cblib_download( instance, folder, url = .CBLIB_DOWNLOAD_ALL_URL, method = NULL, quiet = TRUE, force = FALSE, decompress = TRUE, keep_archive = !decompress )cblib_download( instance, folder, url = .CBLIB_DOWNLOAD_ALL_URL, method = NULL, quiet = TRUE, force = FALSE, decompress = TRUE, keep_archive = !decompress )
instance |
Character string. Instance name, with or without the
|
folder |
Character string. Destination directory. No default is
provided; pass |
url |
Character string. Base URL of the CBLIB download directory. |
method |
Character string passed to |
quiet |
Logical. Passed to |
force |
Logical. If |
decompress |
Logical. If |
keep_archive |
Logical. If |
The CBLIB download README documents recursive retrieval from
https://cblib.zib.de/download/all/ using wget. These helpers
provide the same access pattern directly from R for either a single instance
or the full directory listing.
Character string giving the path to the downloaded file. Returns the
decompressed .cbf path when decompress = TRUE, otherwise the
.cbf.gz archive path.
## Not run: path <- cblib_download("CBLIB_ex1.cbf", folder = tempdir()) op <- read_cbf(path) ## End(Not run)## Not run: path <- cblib_download("CBLIB_ex1.cbf", folder = tempdir()) op <- read_cbf(path) ## End(Not run)
Downloads every .cbf.gz instance linked from
https://cblib.zib.de/download/all/. By default each archive is
decompressed to a plain .cbf file.
cblib_download_all( folder, url = .CBLIB_DOWNLOAD_ALL_URL, method = NULL, quiet = TRUE, force = FALSE, decompress = TRUE, keep_archive = !decompress )cblib_download_all( folder, url = .CBLIB_DOWNLOAD_ALL_URL, method = NULL, quiet = TRUE, force = FALSE, decompress = TRUE, keep_archive = !decompress )
folder |
Character string. Destination directory. No default is
provided; pass |
url |
Character string. Base URL of the CBLIB download directory. |
method |
Character string passed to |
quiet |
Logical. Passed to |
force |
Logical. If |
decompress |
Logical. If |
keep_archive |
Logical. If |
According to the CBLIB download README, the complete collection is intended
to be fetched recursively from the /download/all/ directory. This
helper first reads that index page, extracts all linked .cbf.gz
archives, and then downloads them one by one.
Named character vector of downloaded file paths. Names are the CBLIB archive file names listed in the index.
## Not run: paths <- cblib_download_all(folder = tempdir()) ## End(Not run)## Not run: paths <- cblib_download_all(folder = tempdir()) ## End(Not run)
Parses a file in the Conic Benchmark Format (CBF version 4) and returns
an OP object representing the encoded optimisation
problem.
read_cbf(file, ...)read_cbf(file, ...)
file |
Character string. Path to the |
... |
Currently unused; present for API compatibility with
|
Supported features
Scalar variables (VAR) with all non-parametric cone types:
F., L+., L-., L=..
Scalar constraints (CON) with non-parametric cones:
F., L+., L-., L=., Q., QR.,
EXP., EXP*., SVECPSD., GMEANABS.,
GMEAN., and their duals.
Parametric power cones (@k:POW, @k:POW*) via the
POWCONES / POW*CONES lookup tables.
Integer variables (INT section).
Linear and constant-term objective coefficients (OBJACOORD, OBJBCOORD).
PSD matrix variables (PSDVAR): each
is replaced by its symmetric vectorisation of
length , appended as new scalar variables with a
K_psd(m_j) cone constraint. Objective terms (OBJFCOORD) and
scalar-constraint terms (FCOORD) involving are translated via
the trace inner-product identity
.
PSD matrix constraints (PSDCON / HCOORD / DCOORD): each LMI
is svec-ed
into a K_psd(m_p) conic constraint on the scalar variables.
Features that generate a warning() and are skipped:
Hotstart sequences (CHANGE keyword is treated as end-of-file).
An OP object.
## round-trip: write a simple LP to a temp file then read it back op <- ROI::OP( objective = ROI::L_objective(c(1, 1)), constraints = ROI::L_constraint( L = matrix(c(1, 1), nrow = 1), dir = ">=", rhs = 1 ) ) f <- file.path(tempdir(), "lp.cbf") write_cbf(op, f) op2 <- read_cbf(f)## round-trip: write a simple LP to a temp file then read it back op <- ROI::OP( objective = ROI::L_objective(c(1, 1)), constraints = ROI::L_constraint( L = matrix(c(1, 1), nrow = 1), dir = ">=", rhs = 1 ) ) f <- file.path(tempdir(), "lp.cbf") write_cbf(op, f) op2 <- read_cbf(f)
Serialises an ROI optimisation problem (OP) to a plain
text file in the Conic Benchmark Format (CBF version 4).
write_cbf(op, file, ...)write_cbf(op, file, ...)
op |
An |
file |
Character string. Destination file path (created or overwritten). |
... |
Currently unused. |
Supported OP components
Linear objectives (L_objective).
L_constraint is mapped to L+ (">="),
L- ("<="), or L= ("==") cone chunks.C_constraint is mapped to the appropriate CBF cone:
Q., QR., EXP., EXP*., SVECPSD.,
@k:POW, or @k:POW*.
Continuous ("C") and integer ("I");
integer variables are written to the INT section.
Translated to F., L+, L-,
or L= chunks in the VAR section.
Invisibly returns file.
CBF encodes . ROI stores .
Therefore write_cbf writes to the BCOORD
section.
## simple LP: min x + y s.t. x + y >= 1, x, y >= 0 op <- ROI::OP( objective = ROI::L_objective(c(1, 1)), constraints = ROI::L_constraint( L = matrix(c(1, 1), nrow = 1), dir = ">=", rhs = 1 ) ) f <- file.path(tempdir(), "lp.cbf") write_cbf(op, f)## simple LP: min x + y s.t. x + y >= 1, x, y >= 0 op <- ROI::OP( objective = ROI::L_objective(c(1, 1)), constraints = ROI::L_constraint( L = matrix(c(1, 1), nrow = 1), dir = ">=", rhs = 1 ) ) f <- file.path(tempdir(), "lp.cbf") write_cbf(op, f)