Skip to content

Commit

Permalink
🤖 Format .jl files (#26)
Browse files Browse the repository at this point in the history
Co-authored-by: tmigot <[email protected]>
  • Loading branch information
github-actions[bot] and tmigot authored May 7, 2024
1 parent feff607 commit 41acaca
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
10 changes: 4 additions & 6 deletions test/problems/hs5.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,16 @@ hs5() = hs5(Float64)
hs5(::Type{T}) where {T <: Number} = hs5(Vector{T})
function hs5(::Type{V}) where {V}
T = eltype(V)
hprod(hv, x, v; obj_weight = one(T)) = (
hv .=
(-sin(x[1] + x[2]) * (v[1] + v[2]) .+ 2 * V([v[1] - v[2]; v[2] - v[1]])) *
obj_weight
)
hprod(hv, x, v; obj_weight = one(T)) =
(hv .= (-sin(x[1] + x[2]) * (v[1] + v[2]) .+ 2 * V([v[1] - v[2]; v[2] - v[1]])) * obj_weight)
hess_coord(vals, x; obj_weight = one(T)) = begin
vals[1] = vals[3] = -sin(x[1] + x[2]) + 2
vals[2] = -sin(x[1] + x[2]) - 2
vals .*= obj_weight
end
f(x) = sin(x[1] + x[2]) + (x[1] - x[2])^2 - 3x[1] / 2 + 5x[2] / 2 + 1
grad(gx, x) = (gx .= cos(x[1] + x[2]) .+ 2 * (x[1] - x[2]) * V([1; -1]) + V([-15 // 10; 25 // 10]))
grad(gx, x) =
(gx .= cos(x[1] + x[2]) .+ 2 * (x[1] - x[2]) * V([1; -1]) + V([-15 // 10; 25 // 10]))
objgrad(gx, x) = f(x), grad(gx, x)
return NLPModel(
fill!(V(undef, 2), 0),
Expand Down
6 changes: 5 additions & 1 deletion test/problems/hs6.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ function hs6(::Type{V}) where {V}
# objgrad explicitly not implemented
hprod = hprod,
hess_coord = ([1], [1], hess_coord),
cons = ((cx, x) -> (cx[1] = 10 * (x[2] - x[1]^2); cx), fill!(V(undef, 1), 0), fill!(V(undef, 1), 0)),
cons = (
(cx, x) -> (cx[1] = 10 * (x[2] - x[1]^2); cx),
fill!(V(undef, 1), 0),
fill!(V(undef, 1), 0),
),
jac_coord = ([1, 1], [1, 2], (vals, x) -> (vals[1] = -20x[1]; vals[2] = 10; vals)),
jprod = (jv, x, v) -> (jv[1] = -20x[1] * v[1] + 10v[2]; jv),
jtprod = (jtv, x, v) -> (jtv[1] = -20x[1] * v[1]; jtv[2] = 10 * v[1]; jtv),
Expand Down

0 comments on commit 41acaca

Please sign in to comment.