Skip to content

Commit

Permalink
Merge pull request #87 from hdavid16/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
hdavid16 authored Oct 18, 2023
2 parents de77f25 + 7fc045b commit 3af182e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 16 deletions.
10 changes: 2 additions & 8 deletions src/hull.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,8 @@ function _disaggregate_variable(model::Model, lvref::LogicalVariableRef, vref::V
dvname = name(dvref)
lbname = isempty(dvname) ? "" : "$(dvname)_lower_bound"
ubname = isempty(dvname) ? "" : "$(dvname)_upper_bound"
new_con_lb_ref = add_constraint(model,
build_constraint(error, lb*bvref - dvref, _MOI.LessThan(0)),
lbname
)
new_con_ub_ref = add_constraint(model,
build_constraint(error, dvref - ub*bvref, _MOI.LessThan(0)),
ubname
)
new_con_lb_ref = @constraint(model, lb*bvref - dvref <= 0, base_name = lbname)
new_con_ub_ref = @constraint(model, dvref - ub*bvref <= 0, base_name = ubname)
push!(_reformulation_constraints(model), new_con_lb_ref, new_con_ub_ref)
return dvref
end
Expand Down
11 changes: 3 additions & 8 deletions src/logic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -222,18 +222,14 @@ function _reformulate_selector(model::Model, func, set::Union{_MOIAtLeast, _MOIA
dict = _indicator_to_binary(model)
bvrefs = [dict[lvref] for lvref in func[2:end]]
new_set = _vec_to_scalar_set(set)(func[1].constant)
cref = add_constraint(model,
build_constraint(error, @expression(model, sum(bvrefs)), new_set)
)
cref = @constraint(model, sum(bvrefs) in new_set)
push!(_reformulation_constraints(model), cref)
end
function _reformulate_selector(model::Model, func::Vector{LogicalVariableRef}, set::Union{_MOIAtLeast, _MOIAtMost, _MOIExactly})
dict = _indicator_to_binary(model)
bvref, bvrefs... = [dict[lvref] for lvref in func]
new_set = _vec_to_scalar_set(set)(0)
cref = add_constraint(model,
build_constraint(error, @expression(model, sum(bvrefs) - bvref), new_set)
)
cref = @constraint(model, sum(bvrefs) - bvref in new_set)
push!(_reformulation_constraints(model), cref)
end

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

0 comments on commit 3af182e

Please sign in to comment.