Skip to content

Commit

Permalink
Update tips_and_tricks
Browse files Browse the repository at this point in the history
  • Loading branch information
odow committed Nov 6, 2023
1 parent ee544c9 commit b4eb983
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions docs/src/tutorials/linear/tips_and_tricks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -237,15 +237,6 @@ M = 100

# ## Semi-continuous variables

# !!! info
# This section uses sets from [MathOptInterface](@ref moi_documentation).
# By default, JuMP exports the `MOI` symbol as an alias for the
# MathOptInterface.jl package. We recommend making this more explicit in
# your code by adding the following lines:
# ```julia
# import MathOptInterface as MOI
# ```

# A semi-continuous variable is a continuous variable between bounds $[l,u]$
# that also can assume the value zero, that is:
# $$x \in \{0\} \cup [l,u].$$
Expand All @@ -255,6 +246,17 @@ M = 100
model = Model();
@variable(model, x in Semicontinuous(1.0, 2.0))

# You can also represent a semi-continuous variable using the reformulation:

model = Model();
@variable(model, x)
@variable(model, z, Bin)
@constraint(model, x <= 2 * z)
@constraint(model, x >= 1 * z)

# When `z = 0` the two constraints are equivalent to `0 <= x <= 0`. When `z = 1`,
# the two constraints are equivalennt to `1 <= x <= 2`.

# ## Semi-integer variables

# A semi-integer variable is a variable which assumes integer values between
Expand All @@ -264,6 +266,17 @@ model = Model();
model = Model();
@variable(model, x in Semiinteger(5.0, 10.0))

# You can also represent a semi-integer variable using the reformulation:

model = Model();
@variable(model, x, Int)
@variable(model, z, Bin)
@constraint(model, x <= 10 * z)
@constraint(model, x >= 5 * z)

# When `z = 0` the two constraints are equivalent to `0 <= x <= 0`. When `z = 1`,
# the two constraints are equivalennt to `5 <= x <= 10`.

# ## Special Ordered Sets of Type 1

# A Special Ordered Set of Type 1 is a set of variables, at most one of which
Expand Down

0 comments on commit b4eb983

Please sign in to comment.