Skip to content

Commit

Permalink
[docs] clarify that JuMP can reformulate indicator constraints (#3703)
Browse files Browse the repository at this point in the history
  • Loading branch information
odow committed Mar 6, 2024
1 parent 434940d commit cb25a91
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions docs/src/tutorials/linear/tips_and_tricks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -234,26 +234,28 @@ M = 100

# ### Trick 1

# Some solvers have native support for indicator constraints.
# Some solvers have native support for indicator constraints. In addition, if
# the variables involved have finite domains, then JuMP can automatically
# reformulate an indicator into a mixed-integer program.

# **Example** $x_1 + x_2 \leq 1$ if $z = 1$.

model = Model();
@variable(model, x[1:2])
@variable(model, 0 <= x[1:2] <= 10)
@variable(model, z, Bin)
@constraint(model, z --> {sum(x) <= 1})

# **Example** $x_1 + x_2 \leq 1$ if $z = 0$.

model = Model();
@variable(model, x[1:2])
@variable(model, 0 <= x[1:2] <= 10)
@variable(model, z, Bin)
@constraint(model, !z --> {sum(x) <= 1})

# ### Trick 2

# If the solver doesn't support indicator constraints, you an use the big-M
# trick.
# If the solver doesn't support indicator constraints and the variables do not
# have a finite domain, you an use the big-M trick.

# **Example** $x_1 + x_2 \leq 1$ if $z = 1$.

Expand Down

0 comments on commit cb25a91

Please sign in to comment.