Skip to content

Commit f402f75

Browse files
committed
Add test
1 parent e39fdbc commit f402f75

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

test/Nonlinear/ReverseAD.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,18 @@ function test_linearity()
630630
return
631631
end
632632

633+
function test_linearity_no_hess()
634+
x = MOI.VariableIndex(1)
635+
model = Nonlinear.Model()
636+
ex = Nonlinear.add_expression(model, :($x + 1))
637+
Nonlinear.set_objective(model, ex)
638+
evaluator = Nonlinear.Evaluator(model, Nonlinear.SparseReverseMode(), [x])
639+
MOI.initialize(evaluator, [:Grad, :Jac])
640+
# We initialized without the need for the hessian so
641+
# the linearity shouldn't be computed.
642+
@test only(evaluator.backend.subexpressions).linearity == ReverseAD.NONLINEAR
643+
end
644+
633645
function test_dual_forward()
634646
x = MOI.VariableIndex(1)
635647
y = MOI.VariableIndex(2)

0 commit comments

Comments
 (0)