diff --git a/src/aff_expr.jl b/src/aff_expr.jl index 86570a9ad2b..b6352eae1f5 100644 --- a/src/aff_expr.jl +++ b/src/aff_expr.jl @@ -203,8 +203,12 @@ Base.zero(a::GenericAffExpr) = zero(typeof(a)) function Base.one(::Type{GenericAffExpr{C,V}}) where {C,V} return GenericAffExpr{C,V}(one(C), OrderedDict{V,C}()) end +function Base.oneunit(::Type{GenericAffExpr{C,V}}) where {C,V} + return GenericAffExpr{C,V}(oneunit(C), OrderedDict{V,C}()) +end Base.one(a::GenericAffExpr) = one(typeof(a)) +Base.oneunit(a::GenericAffExpr) = oneunit(typeof(a)) Base.copy(a::GenericAffExpr) = GenericAffExpr(copy(a.constant), copy(a.terms)) diff --git a/src/variables.jl b/src/variables.jl index df70cf9e9a3..693ec20a05f 100644 --- a/src/variables.jl +++ b/src/variables.jl @@ -360,10 +360,14 @@ function Base.zero(::Type{V}) where {V<:AbstractVariableRef} end Base.one(v::AbstractVariableRef) = one(typeof(v)) +Base.oneunit(v::AbstractVariableRef) = oneunit(typeof(v)) function Base.one(::Type{V}) where {V<:AbstractVariableRef} return one(GenericAffExpr{value_type(V),V}) end +function Base.oneunit(::Type{V}) where {V<:AbstractVariableRef} + return oneunit(GenericAffExpr{value_type(V),V}) +end """ coefficient(v1::GenericVariableRef{T}, v2::GenericVariableRef{T}) where {T}