Skip to content

Commit b5a2a2a

Browse files
authored
Use concrete AffExpr in reformulation (#150)
1 parent 6ab70a6 commit b5a2a2a

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

‎src/logic.jl‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,9 @@ function _reformulate_selector(
223223
func::Vector{JuMP.AbstractJuMPScalar},
224224
set::AbstractCardinalitySet
225225
) where {M <: JuMP.AbstractModel}
226-
bvrefs = [binary_variable(lvref) for lvref in func[2:end]]
226+
aff_type =
227+
JuMP.GenericAffExpr{JuMP.value_type(M), JuMP.variable_ref_type(M)}
228+
bvrefs = aff_type[binary_variable(lvref) for lvref in func[2:end]]
227229
c = JuMP.constant(func[1])
228230
new_set = _vec_to_scalar_set(set)(c)
229231
init = zero(JuMP.value_type(M))
@@ -235,7 +237,9 @@ function _reformulate_selector(
235237
func::Vector{<:LogicalVariableRef},
236238
set::AbstractCardinalitySet
237239
) where {M <: JuMP.AbstractModel}
238-
bvref, bvrefs... = [binary_variable(lvref) for lvref in func]
240+
aff_type =
241+
JuMP.GenericAffExpr{JuMP.value_type(M), JuMP.variable_ref_type(M)}
242+
bvref, bvrefs... = aff_type[binary_variable(lvref) for lvref in func]
239243
new_set = _vec_to_scalar_set(set)(0)
240244
init = zero(JuMP.value_type(M))
241245
cref = JuMP.@constraint(model, sum(bvrefs, init = init) - bvref in new_set)

0 commit comments

Comments
 (0)