Skip to content

Commit 7fc045b

Browse files
committed
1 parent b6e0902 commit 7fc045b

File tree

2 files changed

+5
-16
lines changed

2 files changed

+5
-16
lines changed

src/hull.jl

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,8 @@ function _disaggregate_variable(model::Model, lvref::LogicalVariableRef, vref::V
3636
dvname = name(dvref)
3737
lbname = isempty(dvname) ? "" : "$(dvname)_lower_bound"
3838
ubname = isempty(dvname) ? "" : "$(dvname)_upper_bound"
39-
new_con_lb_ref = add_constraint(model,
40-
build_constraint(error, lb*bvref - dvref, _MOI.LessThan(0)),
41-
lbname
42-
)
43-
new_con_ub_ref = add_constraint(model,
44-
build_constraint(error, dvref - ub*bvref, _MOI.LessThan(0)),
45-
ubname
46-
)
39+
new_con_lb_ref = @constraint(model, lb*bvref - dvref <= 0, base_name = lbname)
40+
new_con_ub_ref = @constraint(model, dvref - ub*bvref <= 0, base_name = ubname)
4741
push!(_reformulation_constraints(model), new_con_lb_ref, new_con_ub_ref)
4842
return dvref
4943
end

src/logic.jl

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -222,18 +222,14 @@ function _reformulate_selector(model::Model, func, set::Union{_MOIAtLeast, _MOIA
222222
dict = _indicator_to_binary(model)
223223
bvrefs = [dict[lvref] for lvref in func[2:end]]
224224
new_set = _vec_to_scalar_set(set)(func[1].constant)
225-
cref = add_constraint(model,
226-
build_constraint(error, @expression(model, sum(bvrefs)), new_set)
227-
)
225+
cref = @constraint(model, sum(bvrefs) in new_set)
228226
push!(_reformulation_constraints(model), cref)
229227
end
230228
function _reformulate_selector(model::Model, func::Vector{LogicalVariableRef}, set::Union{_MOIAtLeast, _MOIAtMost, _MOIExactly})
231229
dict = _indicator_to_binary(model)
232230
bvref, bvrefs... = [dict[lvref] for lvref in func]
233231
new_set = _vec_to_scalar_set(set)(0)
234-
cref = add_constraint(model,
235-
build_constraint(error, @expression(model, sum(bvrefs) - bvref), new_set)
236-
)
232+
cref = @constraint(model, sum(bvrefs) - bvref in new_set)
237233
push!(_reformulation_constraints(model), cref)
238234
end
239235

@@ -261,8 +257,7 @@ _isa_literal(v) = false
261257
function _add_reformulated_proposition(model::Model, arg::Union{LogicalVariableRef,_LogicalExpr})
262258
func = _reformulate_clause(model, arg)
263259
if !isempty(func.terms) && !all(iszero.(values(func.terms)))
264-
con = build_constraint(error, func, _MOI.GreaterThan(1))
265-
cref = add_constraint(model, con)
260+
cref = @constraint(model, func >= 1)
266261
push!(_reformulation_constraints(model), cref)
267262
end
268263
return

0 commit comments

Comments
 (0)