Skip to content
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
14 changes: 4 additions & 10 deletions src/JuMP/moi_bridge.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,16 @@

# ── moi_function: JuMP → MOI ─────────────────────────────────────────────────

function _to_moi_arg(x::ArrayOfVariables{T,N}) where {T,N}
function JuMP.moi_function(x::ArrayOfVariables{T,N}) where {T,N}
return ArrayOfContiguousVariables{N}(x.offset, x.size)
end

function _to_moi_arg(x::GenericArrayExpr{V,N}) where {V,N}
args = Any[_to_moi_arg(a) for a in x.args]
function JuMP.moi_function(x::GenericArrayExpr{V,N}) where {V,N}
args = Any[JuMP.moi_function(a) for a in x.args]
return ArrayNonlinearFunction{N}(x.head, args, x.size, x.broadcasted)
end

_to_moi_arg(x::Array{<:Real}) = x

_to_moi_arg(x::Real) = x

function JuMP.moi_function(x::GenericArrayExpr{V,N}) where {V,N}
return _to_moi_arg(x)
end
JuMP.moi_function(x::Array{<:Real}) = x

# ── Detect whether a JuMP expression contains array args ─────────────────────

Expand Down
2 changes: 2 additions & 0 deletions src/JuMP/nlp_expr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ Base.size(expr::GenericArrayExpr) = expr.size
JuMP.variable_ref_type(::Type{GenericArrayExpr{V,N}}) where {V,N} = V

JuMP._is_real(::GenericArrayExpr) = true

JuMP._is_real(::Array{<:Real}) = true
Loading