| Version: | 1.0-2 |
| Title: | 'lp_solve' Plugin for the 'R' Optimization Infrastructure |
| Description: | Enhances the 'R' Optimization Infrastructure ('ROI') package with the 'lp_solve' solver. |
| Imports: | stats, methods, utils, ROI (≥ 0.3-0), lpSolveAPI (≥ 5.5.2.0-1) |
| Suggests: | slam |
| License: | GPL-3 |
| URL: | https://roigrp.gitlab.io, https://gitlab.com/roigrp/solver/ROI.plugin.lpsolve |
| NeedsCompilation: | no |
| Packaged: | 2023-07-06 15:54:22 UTC; f |
| Author: | Florian Schwendinger [aut, cre] |
| Maintainer: | Florian Schwendinger <FlorianSchwendinger@gmx.at> |
| Repository: | CRAN |
| Date/Publication: | 2023-07-07 11:50:05 UTC |
Linear Problem 1
Description
maximize \ \ 2 x_1 + 4 x_2 + 3 x_3
subject \ to:
3 x_1 + 4 x_2 + 2 x_3 \leq 60
2 x_1 + x_2 + 2 x_3 \leq 40
x_1 + 3 x_2 + 2 x_3 \leq 80
x_1, x_2, x_3 \geq 0
Examples
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.666667
Control Variables
Description
The control variables are all optional, but can in some cases be used to improve the solving time and the solutions.
Arguments
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 the |
verbose |
a character string (for more information see lp.control). |
anti.degen |
a character vector (for more information see |
basis.crash |
a character string (for more information see |
bb.depthlimit |
a integer giving the maximum branch-and-bound depth (for more information see |
bb.floorfirst |
a character string (for more information see |
bb.rule |
a character vector giving the branch-and-bound rule (for more information see |
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 continuous
until an optimal solution is found
(for more information see |
break.at.value |
a numeric, if given the branch-and-bound algorithm stops
when the objective function becomes smaller than the specified value.
(for more information see |
epslevel |
a character string giving the type of thresholds
(for more information see |
epsb |
a numeric giving the tolerance for the right-hand-side
(for more information see |
epsd |
a numeric
(for more information see |
epsel |
a numeric
(for more information see |
epsint |
a numeric
(for more information see |
epsperturb |
a numeric
(for more information see |
epspivot |
a numeric
(for more information see |
improve |
a character vector
(for more information see |
infinite |
a numeric
(for more information see |
maxpivot |
a integer
(for more information see |
mip.gap |
a numeric vector
(for more information see |
negrange |
a numeric
(for more information see |
obj.in.bas |
a logical
(for more information see |
pivoting |
a character vector
(for more information see |
presolve |
a character vector
(for more information see |
scalelimit |
a numeric
(for more information see |
scaling |
a character vector
(for more information see |
simplextype |
a character vector which an take one of the following values
|
timeout |
a integer giving the number of seconds till a timeout occurs
(for more information see |
Read Optimization Problem
Description
Read a optimization problem from a file.
Usage
read.lp(file, type=c("lp", "mps", "freemps"))
Arguments
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. |
Details
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.
Examples
## Not run:
op <- read.lp("optimization_problem.lp")
sol <- ROI_solve(op)
solution(sol)
## End(Not run)
Write Optimization Problem
Description
Write a optimization problem to a file.
Usage
write.lp(x, file, type=c("lp", "mps", "freemps"))
Arguments
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. |
Details
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.
Examples
## 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)