| Title: | 'lp_solve' Plugin for the 'R' Optimization Infrastructure |
|---|---|
| Description: | Enhances the 'R' Optimization Infrastructure ('ROI') package with the 'lp_solve' solver. |
| Authors: | Florian Schwendinger [aut, cre] |
| Maintainer: | Florian Schwendinger <[email protected]> |
| License: | GPL-3 |
| Version: | 1.0-2 |
| Built: | 2026-09-15 09:15:52 UTC |
| Source: | https://gitlab.com/roigrp/solver/roi.plugin.lpsolve |
library(ROI) mat <- matrix(c(3, 4, 2, 2, 1, 2, 1, 3, 2), nrow=3, byrow=TRUE) x <- OP(objective = c(2, 4, 3), constraints = L_constraint(L = mat, dir = c("<=", "<=", "<="), rhs = c(60, 40, 80)), maximum = TRUE) opt <- ROI_solve(x, solver = "lpsolve") opt ## Optimal solution found. ## The objective value is: 7.666667e+01 solution(opt) ## [1] 0.000000 6.666667 16.666667library(ROI) mat <- matrix(c(3, 4, 2, 2, 1, 2, 1, 3, 2), nrow=3, byrow=TRUE) x <- OP(objective = c(2, 4, 3), constraints = L_constraint(L = mat, dir = c("<=", "<=", "<="), rhs = c(60, 40, 80)), maximum = TRUE) opt <- ROI_solve(x, solver = "lpsolve") opt ## Optimal solution found. ## The objective value is: 7.666667e+01 solution(opt) ## [1] 0.000000 6.666667 16.666667
lp_solve Control ParametersA helper function to construct the control argument passed to
ROI_solve when using the lpsolve solver. All arguments are
optional and default to NULL, in which case they are dropped from
the resulting list and the lpSolveAPI / lp_solve default is
used.
lp_control(basis = NULL, branch.mode = NULL, branch.weights = NULL, verbose = NULL, anti.degen = NULL, basis.crash = NULL, bb.depthlimit = NULL, bb.floorfirst = NULL, bb.rule = NULL, break.at.first = NULL, break.at.value = NULL, epslevel = NULL, epsb = NULL, epsd = NULL, epsel = NULL, epsint = NULL, epsperturb = NULL, epspivot = NULL, improve = NULL, infinite = NULL, maxpivot = NULL, mip.gap = NULL, negrange = NULL, obj.in.bas = NULL, pivoting = NULL, presolve = NULL, scalelimit = NULL, scaling = NULL, simplextype = NULL, timeout = NULL)lp_control(basis = NULL, branch.mode = NULL, branch.weights = NULL, verbose = NULL, anti.degen = NULL, basis.crash = NULL, bb.depthlimit = NULL, bb.floorfirst = NULL, bb.rule = NULL, break.at.first = NULL, break.at.value = NULL, epslevel = NULL, epsb = NULL, epsd = NULL, epsel = NULL, epsint = NULL, epsperturb = NULL, epspivot = NULL, improve = NULL, infinite = NULL, maxpivot = NULL, mip.gap = NULL, negrange = NULL, obj.in.bas = NULL, pivoting = NULL, presolve = NULL, scalelimit = NULL, scaling = NULL, simplextype = NULL, timeout = NULL)
basis |
an optional named list used to set the initial basis of the
|
branch.mode |
an optional list used to set the branch and bound mode,
e.g.,
|
branch.weights |
an optional numeric vector giving the weights for the decision variables.
The length of |
verbose |
a character string controlling the severity of messages reported by
|
anti.degen |
a character vector containing one or more anti-degeneracy options,
e.g., |
basis.crash |
a character string specifying the basis crash mode, one of |
bb.depthlimit |
an integer giving the maximum branch-and-bound depth. The default is
|
bb.floorfirst |
a character string specifying which branch to take first, one of
|
bb.rule |
a character vector giving the branch-and-bound rule, e.g.,
|
break.at.first |
a logical controlling whether the branch-and-bound algorithm should be
stopped at the first solution or the branch-and-bound algorithm continues
until an optimal solution is found. The default is |
break.at.value |
a numeric, if given the branch-and-bound algorithm stops
when the objective function becomes better than the specified value.
The default is to continue until an optimal value is found
(for more information see |
epslevel |
a character string giving the type of tolerance thresholds, one of
|
epsb |
a positive numeric giving the tolerance used to determine whether a
right-hand-side value should be considered zero. The default is
|
epsd |
a positive numeric giving the tolerance used to determine whether a
computed reduced cost should be considered zero. The default is
|
epsel |
a positive numeric giving the tolerance used for rounding values to
zero. The default is |
epsint |
a positive numeric giving the tolerance used to determine whether a
floating-point number is an integer. The default is |
epsperturb |
a positive numeric giving the perturbation scalar for degenerate
problems. The default is |
epspivot |
a positive numeric giving the tolerance used to determine whether a
pivot element is zero. The default is |
improve |
a character vector specifying the iterative improvement level, e.g.,
|
infinite |
a positive numeric specifying the practical value used for infinity.
The default is |
maxpivot |
a positive integer giving the maximum number of pivots between
re-inversion of the matrix. The default is |
mip.gap |
a numeric vector of length two giving the absolute and relative MIP
gap used in the branch-and-bound algorithm. The default is
|
negrange |
a nonpositive numeric below which variables are split into negative
and positive parts. The default is |
obj.in.bas |
a logical specifying whether the objective function is stored in the
constraint matrix. The default is |
pivoting |
a character vector specifying the pivot rule and mode, e.g.,
|
presolve |
a character vector specifying the presolve steps to be carried out
before solving, e.g., |
scalelimit |
a numeric giving the relative scaling convergence criterion. The
default is |
scaling |
a character vector specifying the scaling algorithm, e.g.,
|
simplextype |
a character vector of length one or two giving the simplex type, one of
|
timeout |
an integer giving the number of seconds after which a timeout occurs.
If zero, no timeout occurs
(for more information see |
a named list containing only the non-NULL arguments, suitable for
use as the control argument of ROI_solve.
control, lp.control,
lp.control.options.
lp_control(epsel = 1e-10, presolve = c("rows", "cols"), timeout = 30)lp_control(epsel = 1e-10, presolve = c("rows", "cols"), timeout = 30)
Read a optimization problem from a file.
read.lp(file, type=c("lp", "mps", "freemps"))read.lp(file, type=c("lp", "mps", "freemps"))
file |
a character giving the name of the file the optimization problem is read from. |
type |
a character giving the name of the file format the optimization problem is stored in. |
The optimization problems can be read from the three file formats "lp",
"mps" and "freemps".
Where it seems important to note that the "lp" format refers to
lpsolves native file format
(https://lpsolve.sourceforge.net/5.5/lp-format.htm)
and not to the CPLEX LP format.
## Not run: op <- read.lp("optimization_problem.lp") sol <- ROI_solve(op) solution(sol) ## End(Not run)## Not run: op <- read.lp("optimization_problem.lp") sol <- ROI_solve(op) solution(sol) ## End(Not run)
Write a optimization problem to a file.
write.lp(x, file, type=c("lp", "mps", "freemps"))write.lp(x, file, type=c("lp", "mps", "freemps"))
x |
an object of type |
file |
a character giving the name of the file the optimization problem is written to. |
type |
a character giving the name of the file format used to store the optimization problem. |
The optimization problems can be written to the three file formats "lp",
"mps" and "freemps".
Where it seems important to note that the "lp" format refers to
lpsolves native file format
(https://lpsolve.sourceforge.net/5.5/lp-format.htm)
and not to the CPLEX LP format.
## Not run: mat <- matrix(c(3, 4, 2, 2, 1, 2, 1, 3, 2), nrow=3, byrow=TRUE) x <- OP(objective = c(2, 4, 3), constraints = L_constraint(L = mat, dir = c("<=", "<=", "<="), rhs = c(60, 40, 80)), bounds = V_bound(ui = seq_len(3), ub = c(1000, Inf, 1000), nobj = 3), maximum = TRUE) write.lp(x, "optimization_problem.lp") ## End(Not run)## Not run: mat <- matrix(c(3, 4, 2, 2, 1, 2, 1, 3, 2), nrow=3, byrow=TRUE) x <- OP(objective = c(2, 4, 3), constraints = L_constraint(L = mat, dir = c("<=", "<=", "<="), rhs = c(60, 40, 80)), bounds = V_bound(ui = seq_len(3), ub = c(1000, Inf, 1000), nobj = 3), maximum = TRUE) write.lp(x, "optimization_problem.lp") ## End(Not run)