@@ -4,28 +4,13 @@ function test_nlp_consistency(nlp, model; counters = true)
44 v = 2 * ones (nvar)
55 y = ones (ncon)
66
7- @test grad (nlp, x) == grad (model, x)
8- @test ! counters || (neval_grad (model) == 2 )
9- @test hess_coord (nlp, x) == hess_coord (model, x)
10- @test ! counters || (neval_hess (model) == 2 )
11- @test hprod (nlp, x, v) == hprod (model, x, v)
12- @test ! counters || (neval_hprod (model) == 2 )
7+ # TODO : only test the backends that are defined
138 if model. meta. nnln > 0
149 @test jac (nlp, x) == jac (model, x)
1510 @test ! counters || (neval_jac_nln (model) == 2 )
1611 @test jprod (nlp, x, v) == jprod (model, x, v)
1712 @test ! counters || (neval_jprod_nln (model) == 2 )
1813 @test jtprod (nlp, x, y) == jtprod (model, x, y)
19- @test hess_coord (nlp, x, y) == hess_coord (model, x, y)
20- @test ! counters || (neval_hess (model) == 4 )
21- @test hprod (nlp, x, y, v) == hprod (model, x, y, v)
22- @test ! counters || (neval_hprod (model) == 4 )
23- @test ghjvprod (nlp, x, x, v) == ghjvprod (model, x, x, v)
24- @test ! counters || (neval_hprod (model) == 6 )
25- for j in model. meta. nln
26- @test jth_hess (nlp, x, j) == jth_hess (model, x, j)
27- @test jth_hprod (nlp, x, v, j) == jth_hprod (model, x, v, j)
28- end
2914 end
3015
3116 if (nlp isa AbstractNLSModel) && (model isa AbstractNLSModel)
@@ -41,6 +26,25 @@ function test_nlp_consistency(nlp, model; counters = true)
4126 # for i=1:nequ
4227 # @test hprod_residual(nlp, x, i, v) == hprod_residual(model, x, i, v)
4328 # end
29+ else
30+ @test grad (nlp, x) == grad (model, x)
31+ @test ! counters || (neval_grad (model) == 2 )
32+ @test hess_coord (nlp, x) == hess_coord (model, x)
33+ @test ! counters || (neval_hess (model) == 2 )
34+ @test hprod (nlp, x, v) == hprod (model, x, v)
35+ @test ! counters || (neval_hprod (model) == 2 )
36+ if model. meta. nnln > 0
37+ @test hess_coord (nlp, x, y) == hess_coord (model, x, y)
38+ @test ! counters || (neval_hess (model) == 4 )
39+ @test hprod (nlp, x, y, v) == hprod (model, x, y, v)
40+ @test ! counters || (neval_hprod (model) == 4 )
41+ @test ghjvprod (nlp, x, x, v) == ghjvprod (model, x, x, v)
42+ @test ! counters || (neval_hprod (model) == 6 )
43+ for j in model. meta. nln
44+ @test jth_hess (nlp, x, j) == jth_hess (model, x, j)
45+ @test jth_hprod (nlp, x, v, j) == jth_hprod (model, x, v, j)
46+ end
47+ end
4448 end
4549end
4650
@@ -250,18 +254,12 @@ end
250254 c!,
251255 lcon,
252256 ucon,
253- gradient_backend = adbackend. gradient_backend,
254- hprod_backend = adbackend. hprod_backend,
255- hessian_backend = adbackend. hessian_backend,
256257 jprod_backend = adbackend. jprod_backend,
257258 jtprod_backend = adbackend. jtprod_backend,
258259 jacobian_backend = adbackend. jacobian_backend,
259- ghjvprod_backend = adbackend. ghjvprod_backend,
260- hprod_residual_backend = adbackend. hprod_residual_backend,
261260 jprod_residual_backend = adbackend. jprod_residual_backend,
262261 jtprod_residual_backend = adbackend. jtprod_residual_backend,
263262 jacobian_residual_backend = adbackend. jacobian_residual_backend,
264- hessian_residual_backend = adbackend. hessian_residual_backend,
265263 )
266264 test_nlp_consistency (nlp, nlp; counters = false )
267265end
0 commit comments