Title: | 'HiGHS' Optimization Solver |
---|---|
Description: | R interface to 'HiGHS', an optimization solver for solving mixed integer optimization problems with quadratic or linear objective and linear constraints. |
Authors: | Florian Schwendinger [aut, cre], Dirk Schumacher [aut], Julian Hall [cph], Ivet Galabova [cph], Leona Gottwald [cph], Michael Feldmeier [cph] |
Maintainer: | Florian Schwendinger <[email protected]> |
License: | GPL (>= 2) |
Version: | 0.1-10 |
Built: | 2024-10-27 06:44:56 UTC |
Source: | CRAN |
Reference for the available solver options.
highs_available_solver_options()
highs_available_solver_options()
A data.frame
containing the available solver options.
highs_available_solver_options()
highs_available_solver_options()
Highs Control
highs_control(threads = 1L, time_limit = Inf, log_to_console = FALSE, ...)
highs_control(threads = 1L, time_limit = Inf, log_to_console = FALSE, ...)
threads |
an integer giving the number of threads to be used. |
time_limit |
a double giving the time limit. |
log_to_console |
a logical giving if the output should be shown in the console. |
... |
other arguments supported by the |
control <- highs_control()
control <- highs_control()
Solve linear and quadratic mixed integer optimization problems.
highs_model( Q = NULL, L, lower, upper, A, lhs, rhs, types, maximum = FALSE, offset = 0 )
highs_model( Q = NULL, L, lower, upper, A, lhs, rhs, types, maximum = FALSE, offset = 0 )
Q |
a numeric symmetric matrix giving the quadratic part of the objective. |
L |
a numeric vector giving the linear part of the objective function. |
lower |
a numeric vector giving the lower bounds of the variables. |
upper |
a numeric vector giving the upper bounds of the variables. |
A |
a numeric matrix giving the linear part of the constraints. Rows are constraints, and columns are decision variables. |
lhs |
a numeric vector giving the left hand-side of the linear constraints. |
rhs |
a numeric vector giving the right hand-side of the linear constraints. |
types |
a integer vector or character vector giving the variable types.
|
maximum |
a logical if |
offset |
a numeric value giving the offset (default is |
A an object of class highs_model
.
library("highs") # Minimize: # x_0 + x_1 + 3 # Subject to: # x_1 <= 7 # 5 <= x_0 + 2x_1 <= 15 # 6 <= 3x_0 + 2x_1 # 0 <= x_0 <= 4 # 1 <= x_1 A <- rbind(c(0, 1), c(1, 2), c(3, 2)) m <- highs_model(L = c(1.0, 1), lower = c(0, 1), upper = c(4, Inf), A = A, lhs = c(-Inf, 5, 6), rhs = c(7, 15, Inf), offset = 3) m # Minimize: # -x_2 - 3x_3 + (1/2) * (2 x_1^2 - 2 x_1x_3 + 0.2 x_2^2 + 2 x_3^2) # Subject to: # x_1 + x_3 <= 2 # 0 <= x L <- c(0, -1, -3) Q <- rbind(c(2, 0.0, -1), c(0, 0.2, 0), c(-1, 0.0, 2)) A <- cbind(1, 0, 1) m <- highs_model(Q = Q, L = L, lower = 0, A = A, rhs = 2) m
library("highs") # Minimize: # x_0 + x_1 + 3 # Subject to: # x_1 <= 7 # 5 <= x_0 + 2x_1 <= 15 # 6 <= 3x_0 + 2x_1 # 0 <= x_0 <= 4 # 1 <= x_1 A <- rbind(c(0, 1), c(1, 2), c(3, 2)) m <- highs_model(L = c(1.0, 1), lower = c(0, 1), upper = c(4, Inf), A = A, lhs = c(-Inf, 5, 6), rhs = c(7, 15, Inf), offset = 3) m # Minimize: # -x_2 - 3x_3 + (1/2) * (2 x_1^2 - 2 x_1x_3 + 0.2 x_2^2 + 2 x_3^2) # Subject to: # x_1 + x_3 <= 2 # 0 <= x L <- c(0, -1, -3) Q <- rbind(c(2, 0.0, -1), c(0, 0.2, 0), c(-1, 0.0, 2)) A <- cbind(1, 0, 1) m <- highs_model(Q = Q, L = L, lower = 0, A = A, rhs = 2) m
Solve linear and quadratic mixed integer optimization problems.
highs_solve( Q = NULL, L, lower, upper, A, lhs, rhs, types, maximum = FALSE, offset = 0, control = highs_control() )
highs_solve( Q = NULL, L, lower, upper, A, lhs, rhs, types, maximum = FALSE, offset = 0, control = highs_control() )
Q |
a numeric symmetric matrix giving the quadratic part of the objective. |
L |
a numeric vector giving the linear part of the objective function. |
lower |
a numeric vector giving the lower bounds of the variables. |
upper |
a numeric vector giving the upper bounds of the variables. |
A |
a numeric matrix giving the linear part of the constraints. Rows are constraints, and columns are decision variables. |
lhs |
a numeric vector giving the left hand-side of the linear constraints. |
rhs |
a numeric vector giving the right hand-side of the linear constraints. |
types |
a integer vector or character vector giving the variable types.
|
maximum |
a logical if |
offset |
a numeric value giving the offset (default is |
control |
a list giving additional options for the solver,
see highs_available_solver_options or the |
A list
containing the result provided by the solver,
containing the following named objects:
primal_solution |
a numeric vector giving the primal solution. |
objective_value |
a numeric giving the objective value. |
status |
an integer giving the status code |
status_message |
a character string giving the status message (explanation of the |
solver_msg |
a list giving the original (not canonicalized) solver message. |
info |
a list giving additional information provided by the solver. |
Additional information on can be found in the README
file.
library("highs") # Minimize: # x_0 + x_1 + 3 # Subject to: # x_1 <= 7 # 5 <= x_0 + 2x_1 <= 15 # 6 <= 3x_0 + 2x_1 # 0 <= x_0 <= 4 # 1 <= x_1 A <- rbind(c(0, 1), c(1, 2), c(3, 2)) s <- highs_solve(L = c(1.0, 1), lower = c(0, 1), upper = c(4, Inf), A = A, lhs = c(-Inf, 5, 6), rhs = c(7, 15, Inf), offset = 3) s[["objective_value"]] s[["primal_solution"]] # Minimize: # -x_2 - 3x_3 + (1/2) * (2 x_1^2 - 2 x_1x_3 + 0.2 x_2^2 + 2 x_3^2) # Subject to: # x_1 + x_3 <= 2 # 0 <= x L <- c(0, -1, -3) Q <- rbind(c(2, 0.0, -1), c(0, 0.2, 0), c(-1, 0.0, 2)) A <- cbind(1, 0, 1) s <- highs_solve(Q = Q, L = L, lower = 0, A = A, rhs = 2) s[["objective_value"]] s[["primal_solution"]]
library("highs") # Minimize: # x_0 + x_1 + 3 # Subject to: # x_1 <= 7 # 5 <= x_0 + 2x_1 <= 15 # 6 <= 3x_0 + 2x_1 # 0 <= x_0 <= 4 # 1 <= x_1 A <- rbind(c(0, 1), c(1, 2), c(3, 2)) s <- highs_solve(L = c(1.0, 1), lower = c(0, 1), upper = c(4, Inf), A = A, lhs = c(-Inf, 5, 6), rhs = c(7, 15, Inf), offset = 3) s[["objective_value"]] s[["primal_solution"]] # Minimize: # -x_2 - 3x_3 + (1/2) * (2 x_1^2 - 2 x_1x_3 + 0.2 x_2^2 + 2 x_3^2) # Subject to: # x_1 + x_3 <= 2 # 0 <= x L <- c(0, -1, -3) Q <- rbind(c(2, 0.0, -1), c(0, 0.2, 0), c(-1, 0.0, 2)) A <- cbind(1, 0, 1) s <- highs_solve(Q = Q, L = L, lower = 0, A = A, rhs = 2) s[["objective_value"]] s[["primal_solution"]]
Create a wrapper around the HiGHS
solver. Manly usefull if one wants
a low level wrapper around highs with hot-start capabilities.
highs_solver(model, control = highs_control())
highs_solver(model, control = highs_control())
model |
an object of class |
control |
an object of class |
Methods
The following methods are provided by the "highs_solver"
class.
solve(...)
method to be called to solve the optimization problem.
Returns an integer giving the status code returned by HiGHS.
status()
method to obtain the status from the solver.
status_message()
method to obtain the status message from the solver.
solution()
method to obtain the solution from the solver.
info()
info to obtain addtional information from the solver.
L(i, v)
method to get and set the linear part of the objective.
A(i, j, v)
method to get and set the constraint matrix coefficients.
cbounds(i, lhs, rhs)
method to get and set the constraint bounds
(left hand-side and right hand-side).
types(i, v)
method to get and set the variable types.
vbounds(i, lower, upper)
method to get and set the variable bounds.
maximum(maximize)
method to get and set the sense of the problem.
Method arguments
...
optional control arguments, which can be used to alter the options
set via the control
argument when initializing the solver.
i
a vector of integers giving the index (vector index or row index)
of the coeficcients to be altered.
j
a vector of integers giving the index (column index) of the coeficcients to be altered.
v
a vector of doubles giving the values of the coeficcients to be altered.
lhs
a vector of doubles giving left hand-side.
rhs
a vector of doubles giving right hand-side.
lower
a vector of doubles giving the lower bounds to be altered.
upper
a vector of doubles giving the upper bounds to be altered.
an object of class "highs_solver"
.
A <- rbind(c(0, 1), c(1, 2), c(3, 2)) m <- highs_model(L = c(1.0, 1), lower = c(0, 1), upper = c(4, Inf), A = A, lhs = c(-Inf, 5, 6), rhs = c(7, 15, Inf), offset = 3) solver <- highs_solver(m)
A <- rbind(c(0, 1), c(1, 2), c(3, 2)) m <- highs_model(L = c(1.0, 1), lower = c(0, 1), upper = c(4, Inf), A = A, lhs = c(-Inf, 5, 6), rhs = c(7, 15, Inf), offset = 3) solver <- highs_solver(m)