highs_solve {highs}R Documentation

Solve an Optimization Problems

Description

Solve linear and quadratic mixed integer optimization problems.

Usage

highs_solve(
  Q = NULL,
  L,
  lower,
  upper,
  A,
  lhs,
  rhs,
  types,
  maximum = FALSE,
  offset = 0,
  control = highs_control()
)

Arguments

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. 'C' or '1' for continuous, 'I' or '2' for integer, 'SC' or '3' for semi continuous, 'SI' or '4' for semi integer and 'II' or '5' for implicit integer.

maximum

a logical if TRUE the solver searches for a maximum, if FALSE the solver searches for a minimum.

offset

a numeric value giving the offset (default is 0).

control

a list giving additional options for the solver, see highs_available_solver_options or the README file for a list of all available options.

Value

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 status_code).

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.

Examples

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"]]

[Package highs version 0.1-10 Index]