Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix macro issue in indicator constraints #3813

Merged
merged 1 commit into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/indicator.jl
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,16 @@ function parse_constraint_call(
)
end
f, lhs_parse_code = _rewrite_expression(variable)
push!(rhs_parsecode.args, lhs_parse_code)
parsecode = quote
$rhs_parsecode
$lhs_parse_code
end
build_call = if vectorized
:(_build_indicator_constraint.($error_fn, $f, $rhs_build_call, $S))
else
:(_build_indicator_constraint($error_fn, $f, $rhs_build_call, $S))
end
return rhs_parsecode, build_call
return parsecode, build_call
end

function constraint_string(
Expand Down
11 changes: 11 additions & 0 deletions test/test_constraint.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2107,4 +2107,15 @@ function test_real_hermitian_in_zeros()
return
end

function test_issue_3812()
model = Model()
@variable(model, b, Bin)
@variable(model, x)
c = @constraint(model, b => {x in MOI.EqualTo(1.0)})
o = constraint_object(c)
@test o.func == [b, x]
@test o.set == MOI.Indicator{MOI.ACTIVATE_ON_ONE}(MOI.EqualTo(1.0))
return
end

end # module
Loading