File tree Expand file tree Collapse file tree 5 files changed +33
-5
lines changed
Expand file tree Collapse file tree 5 files changed +33
-5
lines changed Original file line number Diff line number Diff line change @@ -4,3 +4,8 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
44NLPModels = " a4795742-8479-5a88-8948-cc11e1c8c1a6"
55NLPModelsTest = " 7998695d-6960-4d3a-85c4-e1bceb8cd856"
66Test = " 8dfed614-e22c-5e08-85e1-65c5234f0b40"
7+
8+ [compat ]
9+ CUDA = " 5.8"
10+ NLPModels = " 0.21"
11+ NLPModelsTest = " 0.10"
Original file line number Diff line number Diff line change 1+ @testset " Allocations" begin
2+ @testset " Allocations for hs5" begin
3+ @testset " hs5" begin
4+ include (" problems/hs5.jl" )
5+ test_zero_allocations (hs5 ())
6+ end
7+ end
8+
9+ @testset " Allocations for hs6" begin
10+ @testset " hs6" begin
11+ include (" problems/hs6.jl" )
12+ test_zero_allocations (hs6 ())
13+ end
14+ end
15+ end
Original file line number Diff line number Diff line change @@ -19,16 +19,23 @@ hs5() = hs5(Float64)
1919hs5 (:: Type{T} ) where {T <: Number } = hs5 (Vector{T})
2020function hs5 (:: Type{V} ) where {V}
2121 T = eltype (V)
22- hprod (hv, x, v; obj_weight = one (T)) =
23- (hv .= (- sin (x[1 ] + x[2 ]) * (v[1 ] + v[2 ]) .+ 2 * V ([v[1 ] - v[2 ]; v[2 ] - v[1 ]])) * obj_weight)
22+ hprod (hv, x, v; obj_weight = one (T)) = begin
23+ hv[1 ] = v[1 ] - v[2 ]
24+ hv[2 ] = v[2 ] - v[1 ]
25+ hv .*= 2 * obj_weight
26+ hv .+ = - sin (x[1 ] + x[2 ]) * (v[1 ] + v[2 ])
27+ end
2428 hess_coord (vals, x; obj_weight = one (T)) = begin
2529 vals[1 ] = vals[3 ] = - sin (x[1 ] + x[2 ]) + 2
2630 vals[2 ] = - sin (x[1 ] + x[2 ]) - 2
2731 vals .*= obj_weight
2832 end
2933 f (x) = sin (x[1 ] + x[2 ]) + (x[1 ] - x[2 ])^ 2 - 3 x[1 ] / 2 + 5 x[2 ] / 2 + 1
30- grad (gx, x) =
31- (gx .= cos (x[1 ] + x[2 ]) .+ 2 * (x[1 ] - x[2 ]) * V ([1 ; - 1 ]) + V ([- 15 // 10 ; 25 // 10 ]))
34+ grad (gx, x) = begin
35+ gx[1 ] = - 15 // 10 + 2 * (x[1 ] - x[2 ])
36+ gx[2 ] = 25 // 10 - 2 * (x[1 ] - x[2 ])
37+ gx .+ = cos (x[1 ] + x[2 ])
38+ end
3239 objgrad (gx, x) = f (x), grad (gx, x)
3340 return NLPModel (
3441 fill! (V (undef, 2 ), 0 ),
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ function hs6(::Type{V}) where {V}
2525 return NLPModel (
2626 V ([- 12 // 10 ; 1 ]),
2727 x -> (1 - x[1 ])^ 2 ;
28- grad = (gx, x) -> gx . = V ([ 2 * (x[1 ] - 1 ); 0 ] ),
28+ grad = (gx, x) -> (gx[ 1 ] = 2 * (x[1 ] - 1 ); gx[ 2 ] = 0 ; gx ),
2929 # objgrad explicitly not implemented
3030 hprod = hprod,
3131 hess_coord = ([1 ], [1 ], hess_coord),
Original file line number Diff line number Diff line change @@ -4,3 +4,4 @@ using CUDA, Test
44
55include (" nlpmodelstest.jl" )
66include (" notimplemented.jl" )
7+ include (" allocs.jl" )
You can’t perform that action at this time.
0 commit comments