Skip to content

Commit

Permalink
Added ∈ for @variable (#2576)
Browse files Browse the repository at this point in the history
  • Loading branch information
pulsipher committed Apr 28, 2021
1 parent 35fd771 commit 9d4a379
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/macros.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1325,7 +1325,7 @@ function parse_one_operator_variable end
function parse_one_operator_variable(
_error::Function,
infoexpr::_VariableInfoExpr,
::Val{:in},
::Union{Val{:in},Val{:∈}},
set,
)
return set
Expand Down Expand Up @@ -1491,7 +1491,8 @@ arguments `kw_args` and returns the variable.
Add a variable to the model `model` described by the expression `expr`, the
positional arguments `args` and the keyword arguments `kw_args`. The expression
`expr` can either be (note that in the following the symbol `<=` can be used
instead of `≤` and the symbol `>=`can be used instead of `≥`)
instead of `≤`, the symbol `>=`can be used instead of `≥`, the symbol `in` can be
used instead of `∈`)
* of the form `varexpr` creating variables described by `varexpr`;
* of the form `varexpr ≤ ub` (resp. `varexpr ≥ lb`) creating variables described by
Expand All @@ -1501,7 +1502,7 @@ instead of `≤` and the symbol `>=`can be used instead of `≥`)
* of the form `lb ≤ varexpr ≤ ub` or `ub ≥ varexpr ≥ lb` creating variables
described by `varexpr` with lower bounds given by `lb` and upper bounds given
by `ub`.
* of the form `varexpr in set` creating variables described by
* of the form `varexpr set` creating variables described by
`varexpr` constrained to belong to `set`, see [Variables constrained on creation](@ref).
The expression `varexpr` can either be
Expand Down
4 changes: 2 additions & 2 deletions test/variable.jl
Original file line number Diff line number Diff line change
Expand Up @@ -547,10 +547,10 @@ function test_variables_constrained_on_creation(ModelType, ::Any)
@variable(model, [1:2] in SecondOrderCone())
@test num_constraints(model, typeof(x), MOI.SecondOrderCone) == 2

@variable(model, [1:3] in MOI.SecondOrderCone(3))
@variable(model, [1:3] MOI.SecondOrderCone(3))
@test num_constraints(model, typeof(x), MOI.SecondOrderCone) == 3

z = @variable(model, z in MOI.Semiinteger(1.0, 2.0))
z = @variable(model, z MOI.Semiinteger(1.0, 2.0))
@test num_constraints(model, typeof(z), MOI.Semiinteger{Float64}) == 1

@variable(model, set = MOI.Semiinteger(1.0, 2.0))
Expand Down

0 comments on commit 9d4a379

Please sign in to comment.