Skip to content

Commit 0216f26

Browse files
authored
Apply suggestions from code review
1 parent ad66a20 commit 0216f26

File tree

3 files changed

+11
-15
lines changed

3 files changed

+11
-15
lines changed

src/ADNLPProblems/auglag.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@ function auglag(; n::Int = default_nvar, type::Type{T} = Float64, kwargs...) whe
3636
for i = 1:n
3737
m = mod(i, 5)
3838
if m == 1
39-
x0[i] = i <= 2 ? T(-2) : T(-1)
39+
x0[i] = i <= 2 ? -2 : -1
4040
elseif m == 2
41-
x0[i] = i <= 2 ? T(2) : T(-1)
41+
x0[i] = i <= 2 ? 2 : -1
4242
elseif m == 3
43-
x0[i] = T(2)
43+
x0[i] = 2
4444
elseif m == 4
45-
x0[i] = T(-1)
45+
x0[i] = -1
4646
else
47-
x0[i] = T(-1)
47+
x0[i] = -1
4848
end
4949
end
5050

src/ADNLPProblems/genbroydenb.jl

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ function genbroydenb(::Val{:nlp}; n::Int = default_nvar, type::Type{T} = Float64
2121
end
2222
return s
2323
end
24-
x0 = Vector{T}(undef, n)
25-
fill!(x0, -one(T))
24+
x0 = fill(-one(T), n)
2625
return ADNLPModels.ADNLPModel(f, x0, name = "genbroydenb", minimize = true; kwargs...)
2726
end
2827

@@ -39,13 +38,10 @@ function genbroydenb(::Val{:nls}; n::Int = default_nvar, type::Type{T} = Float64
3938
end
4039
end
4140
z = diag + neigh
42-
r[i] = sign(z) * abs(z)^(p)
41+
r[i] = abs(z)^(p)
4342
end
4443
return r
4544
end
46-
47-
x0 = Vector{T}(undef, n)
48-
fill!(x0, -one(T))
49-
45+
x0 = fill(-one(T), n)
5046
return ADNLPModels.ADNLSModel!(F!, x0, n, name = "genbroydenb-nls"; kwargs...)
5147
end

src/PureJuMP/nazareth.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
# https://www.researchgate.net/publication/325314400_Sparse_Test_Problems_for_Unconstrained_Optimization
1111
export nazareth
1212

13-
function nazareth(; n::Int = default_nvar, type::Type{T} = Float64) where {T}
13+
function nazareth(; n::Int = default_nvar)
1414
nh = div(n, 2)
1515

1616
nlp = Model()
17-
@variable(nlp, x[1:n], start = one(T) / T(n))
17+
@variable(nlp, x[1:n], start = 1 / n)
1818

1919
@objective(nlp, Min, sum((
2020
begin
@@ -40,6 +40,6 @@ function nazareth(; n::Int = default_nvar, type::Type{T} = Float64) where {T}
4040

4141
(n + i - sumtrig)^2
4242
end
43-
) for i = 1:n) / T(n))
43+
) for i = 1:n) / n)
4444
return nlp
4545
end

0 commit comments

Comments
 (0)