Skip to content

Commit 88b79d9

Browse files
Add test
1 parent 01f637f commit 88b79d9

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

test/ADtests.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,14 @@ H2 = Array{Float64}(undef, 2, 2)
232232
optprob.hess(H2, [5.0, 3.0])
233233
@test all(isapprox(H2, [28802.0 -2000.0; -2000.0 200.0]; rtol=1e-3))
234234

235+
cons_j = optprob.cons_j
236+
optf = OptimizationFunction(rosenbrock, Optimization.AutoForwardDiff(), cons=con2_c, cons_j=cons_j, cons_jac_prototype=cons_jac_proto)
237+
optprob = Optimization.instantiate_function(optf, x0, Optimization.AutoForwardDiff(), nothing, 2)
238+
@test optprob.cons_jac_prototype == sparse([1.0 1.0; 1.0 1.0]) # make sure it's still using it
239+
J = Array{Float64}(undef, 2, 2)
240+
optprob.cons_j(J, [5.0, 3.0])
241+
@test all(isapprox(J, [10.0 6.0; -0.149013 -0.958924]; rtol=1e-3))
242+
235243
# Can we solve problems? Using AutoForwardDiff to test since we know that works
236244
for consf in [cons, con2_c]
237245
optf1 = OptimizationFunction(rosenbrock, Optimization.AutoFiniteDiff(); cons=consf)

0 commit comments

Comments
 (0)