Skip to content

Commit f89128d

Browse files
committed
update
1 parent b86bb21 commit f89128d

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

src/Nonlinear/SymbolicAD/SymbolicAD.jl

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,7 @@ end
8989
function simplify!(f::MOI.ScalarQuadraticFunction{T}) where {T}
9090
f = MOI.Utilities.canonicalize!(f)
9191
if isempty(f.quadratic_terms)
92-
if isempty(f.affine_terms)
93-
return f.constant
94-
end
95-
return MOI.ScalarAffineFunction(f.affine_terms, f.constant)
92+
return simplify!(MOI.ScalarAffineFunction(f.affine_terms, f.constant))
9693
end
9794
return f
9895
end

test/Nonlinear/SymbolicAD.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ function test_derivative()
4646
# derivative(f::MOI.ScalarQuadraticFunction{T}, x::MOI.VariableIndex)
4747
convert(MOI.ScalarQuadraticFunction{Float64}, 1.0 * x)=>1.0,
4848
convert(MOI.ScalarQuadraticFunction{Float64}, 1.0 * x + 0.0 * y)=>1.0,
49-
1.0*x*y=>1.0*y,
50-
1.0*y*x=>1.0*y,
49+
1.0*x*y=>y,
50+
1.0*y*x=>y,
5151
1.0*x*x=>2.0*x,
5252
1.0*x*x+3.0*x+4.0=>2.0*x+3.0,
5353
2.0*x*x-2.0*x+1.0=>4.0*x-2.0,

0 commit comments

Comments
 (0)