Skip to content

Commit

Permalink
[POC] Allow array in nonlinear expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
blegat committed Aug 15, 2023
1 parent ef2b488 commit c91039e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/nlp_expr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,10 @@ for f in MOI.Nonlinear.DEFAULT_UNIVARIATE_OPERATORS
end
end

function LinearAlgebra.det(A::LinearAlgebra.Symmetric{<:AbstractJuMPScalar})
return GenericNonlinearExpr{variable_ref_type(eltype(A))}(:det, A)

Check warning on line 298 in src/nlp_expr.jl

View check run for this annotation

Codecov / codecov/patch

src/nlp_expr.jl#L297-L298

Added lines #L297 - L298 were not covered by tests
end

# Multivariate operators

# The multivariate operators in MOI are +, -, *, ^, /, ifelse, atan
Expand Down Expand Up @@ -460,6 +464,8 @@ function moi_function(f::GenericNonlinearExpr)
end
elseif arg isa Number
push!(parent.args, arg)
elseif arg isa AbstractArray
push!(parent.args, moi_function.(arg))

Check warning on line 468 in src/nlp_expr.jl

View check run for this annotation

Codecov / codecov/patch

src/nlp_expr.jl#L468

Added line #L468 was not covered by tests
else
push!(parent.args, moi_function(arg))
end
Expand All @@ -484,6 +490,8 @@ function jump_function(model::GenericModel, f::MOI.ScalarNonlinearFunction)
end
elseif arg isa Number
push!(parent.args, arg)
elseif arg isa AbstractArray
push!(parent.args, jump_function.(model, arg))

Check warning on line 494 in src/nlp_expr.jl

View check run for this annotation

Codecov / codecov/patch

src/nlp_expr.jl#L494

Added line #L494 was not covered by tests
else
push!(parent.args, jump_function(model, arg))
end
Expand Down

0 comments on commit c91039e

Please sign in to comment.