From 7439e4c11f653df509917f575c76025b038204bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Legat?= Date: Tue, 15 Aug 2023 14:37:43 +0200 Subject: [PATCH] [POC] Allow array in nonlinear expressions --- src/nlp_expr.jl | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/nlp_expr.jl b/src/nlp_expr.jl index 0dfd6c54b91..9b1adc2b5de 100644 --- a/src/nlp_expr.jl +++ b/src/nlp_expr.jl @@ -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) +end + # Multivariate operators # The multivariate operators in MOI are +, -, *, ^, /, ifelse, atan @@ -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)) else push!(parent.args, moi_function(arg)) end @@ -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)) else push!(parent.args, jump_function(model, arg)) end