add_constraint function

Add a constraint

Add a constraint

Add one or more constraints to the model using quantifiers.

add_constraint(.model, .constraint_expr, ..., .show_progress_bar = TRUE) add_constraint_( .model, .constraint_expr, ..., .dots, .show_progress_bar = TRUE )

Arguments

  • .model: the model
  • .constraint_expr: the constraint. Must be a linear (in)equality with operator "<=", "==" or ">=".
  • ...: quantifiers for the indexed variables. For all combinations of bound variables a new constraint is created. In addition you can add filter expressions
  • .show_progress_bar: displays a progressbar when adding multiple constraints
  • .dots: Used to work around non-standard evaluation.

Returns

a Model with new constraints added

Examples

library(magrittr) MIPModel() %>% add_variable(x[i], i = 1:5) %>% # creates 5 constraints add_constraint(x[i] >= 1, i = 1:5) %>% # you can also use filter expressions add_constraint(x[i] >= 1, i = 1:5, i %% 2 == 0) %>% # and depent on other indexes add_constraint(x[j] >= 1, i = 1:10, j = 1:i, j <= 5)
  • Maintainer: Dirk Schumacher
  • License: MIT + file LICENSE
  • Last published: 2023-09-09