dirkschumacher / ompr

R package to model Mixed Integer Linear Programs
https://dirkschumacher.github.io/ompr/
Other
268 stars 35 forks source link

set_bounds also supports (in)equalities to define bounds #368

Closed dirkschumacher closed 2 years ago

dirkschumacher commented 2 years ago

See #365

library(ompr)
MIPModel() |>
  add_variable(x[i], i = 1:5) |>
  set_bounds(x[i] <= i, i = 1:5) |> # upper bound
  set_bounds(x[i] >= 0, i = 1:5) |> # lower bound
  set_bounds(x[5] == 45) |> # lower and upper bound
  variable_bounds()
#> $lower
#> [1]  0  0  0  0 45
#> 
#> $upper
#> [1]  1  2  3  4 45