Skip to content

Commit 5b0daae

Browse files
committed
Update
1 parent 6e7cbc3 commit 5b0daae

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/Nonlinear/SymbolicAD/SymbolicAD.jl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,9 +262,6 @@ function simplify!(::Val{:+}, f::MOI.ScalarNonlinearFunction)
262262
push!(new_args, arg)
263263
end
264264
end
265-
if first_affine_term !== 0 && !(new_args[first_affine_term] isa Real)
266-
MOI.Utilities.canonicalize!(new_args[first_affine_term])
267-
end
268265
if length(new_args) == 0
269266
# +() -> false
270267
return false

test/Nonlinear/SymbolicAD.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,9 @@ function test_simplify_if_affine()
720720
op(:+, x, x)=>2.0*x,
721721
op(:+, x, 2, x)=>2.0*x+2.0,
722722
op(:+, x, 2, op(:+, x))=>2.0*x+2.0,
723+
op(:+, 1.0*x, 1.0*x+2.0)=>2.0*x+2.0,
724+
op(:-, 1.0*x+2.0)=>-1.0*x-2.0,
725+
op(:*, 2, 1.0*x+2.0, 3)=>6.0*x+12.0,
723726
# Early termination because not affine
724727
op(:+, op(:sin, x))=>nothing,
725728
op(:-, op(:sin, x))=>nothing,
@@ -730,6 +733,7 @@ function test_simplify_if_affine()
730733
op(:log, x)=>nothing,
731734
op(:+, big(1) * x, big(2))=>nothing,
732735
op(:+, x, big(2))=>nothing,
736+
op(:+, 1.0 * x * x)=>nothing,
733737
]
734738
@test SymbolicAD._simplify_if_affine!(f) something(ret, f)
735739
end

0 commit comments

Comments
 (0)