add_constraint {ompr}R Documentation

Add a constraint

Description

Add one or more constraints to the model using quantifiers.

Usage

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.

Value

a Model with new constraints added

Examples

library(magrittr)
MIPModel() %>%
 add_variable(x[i], i = 1:5) %>%
 add_constraint(x[i] >= 1, i = 1:5) # creates 5 constraints


[Package ompr version 0.8.1 Index]