From d61127b9d990087f7fb84932c572246c2e1702f3 Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Thu, 7 Mar 2024 08:49:11 +1300 Subject: [PATCH] [docs] clarify that JuMP can reformulate indicator constraints --- docs/src/tutorials/linear/tips_and_tricks.jl | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/docs/src/tutorials/linear/tips_and_tricks.jl b/docs/src/tutorials/linear/tips_and_tricks.jl index 547b4ca11d1..6a34550a348 100644 --- a/docs/src/tutorials/linear/tips_and_tricks.jl +++ b/docs/src/tutorials/linear/tips_and_tricks.jl @@ -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$.