Skip to content

Commit

Permalink
Prepare using NLS constructors (#251)
Browse files Browse the repository at this point in the history
* add `get_nls_nequ`

* add 0.5 to jump models

* add 0.5 on adnlpproblems
  • Loading branch information
tmigot authored Apr 4, 2023
1 parent ec0160f commit b7e24ef
Show file tree
Hide file tree
Showing 129 changed files with 167 additions and 124 deletions.
2 changes: 1 addition & 1 deletion src/ADNLPProblems/arglinb.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ function arglinb(; n::Int = default_nvar, type::Val{T} = Val(Float64), kwargs...
function f(x; n = length(x))
m = 2 * n
sj = sum(j * x[j] for j = 1:n)
return sum((i * sj - 1)^2 for i = 1:m)
return 1 // 2 * sum((i * sj - 1)^2 for i = 1:m)
end
x0 = ones(T, n)
return ADNLPModels.ADNLPModel(f, x0, name = "arglinb"; kwargs...)
Expand Down
2 changes: 1 addition & 1 deletion src/ADNLPProblems/bdqrtic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ function bdqrtic(; n::Int = default_nvar, type::Val{T} = Val(Float64), kwargs...
n < 5 && @warn("bdqrtic: number of variables must be ≥ 5")
n = max(5, n)
function f(x; n = length(x))
return sum(
return 1 // 2 * sum(
(3 - 4 * x[i])^2 + (x[i]^2 + 2 * x[i + 1]^2 + 3 * x[i + 2]^2 + 4 * x[i + 3]^2 + 5 * x[n]^2)^2
for i = 1:(n - 4)
)
Expand Down
6 changes: 3 additions & 3 deletions src/ADNLPProblems/beale.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ export beale

function beale(; n::Int = default_nvar, type::Val{T} = Val(Float64), kwargs...) where {T}
function f(x)
return (15 // 10 - x[1] * (1 - x[2]))^2 +
(225 // 100 - x[1] * (1 - x[2]^2))^2 +
(2625 // 1000 - x[1] * (1 - x[2]^3))^2
return 1 // 2 * (15 // 10 - x[1] * (1 - x[2]))^2 +
1 // 2 * (225 // 100 - x[1] * (1 - x[2]^2))^2 +
1 // 2 * (2625 // 1000 - x[1] * (1 - x[2]^3))^2
end
x0 = ones(T, 2)
return ADNLPModels.ADNLPModel(f, x0, name = "beale"; kwargs...)
Expand Down
2 changes: 1 addition & 1 deletion src/ADNLPProblems/brownbs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export brownbs

function brownbs(; n::Int = default_nvar, type::Val{T} = Val(Float64), kwargs...) where {T}
function f(x)
return (x[1] - 1000000)^2 + (x[2] - 2 * 1 // 1000000)^2 + (x[1] * x[2] - 2)^2
return 1 // 2 * (x[1] - 1000000)^2 + 1 // 2 * (x[2] - 2 * 1 // 1000000)^2 + 1 // 2 * (x[1] * x[2] - 2)^2
end
x0 = ones(T, 2)
return ADNLPModels.ADNLPModel(f, x0, name = "brownbs"; kwargs...)
Expand Down
2 changes: 1 addition & 1 deletion src/ADNLPProblems/brybnd.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ function brybnd(; n::Int = default_nvar, type::Val{T} = Val(Float64), kwargs...)
function f(x; n = length(x))
ml = 5
mu = 1
return sum(
return 1 // 2 * sum(
(
x[i] * (2 + 5 * x[i]^2) + 1 -
sum(x[j] * (1 + x[j]) for j = max(1, i - ml):min(n, i + mu) if j != i)
Expand Down
2 changes: 1 addition & 1 deletion src/ADNLPProblems/dixon3dq.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export dixon3dq

function dixon3dq(; n::Int = default_nvar, type::Val{T} = Val(Float64), kwargs...) where {T}
function f(x; n = length(x))
return (x[1] - 1)^2 + (x[n] - 1)^2 + sum((x[i] - x[i + 1])^2 for i = 2:(n - 1))
return 1 // 2 * (x[1] - 1)^2 + 1 // 2 * (x[n] - 1)^2 + 1 // 2 * sum((x[i] - x[i + 1])^2 for i = 2:(n - 1))
end
x0 = -ones(T, n)
return ADNLPModels.ADNLPModel(f, x0, name = "dixon3dq"; kwargs...)
Expand Down
4 changes: 2 additions & 2 deletions src/ADNLPProblems/errinros_mod.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ function errinros_mod(; n::Int = default_nvar, type::Val{T} = Val(Float64), kwar
n < 2 && @warn("errinros_mod: number of variables must be ≥ 2")
n = max(2, n)
function f(x; n = length(x))
return sum((x[i - 1] - 16 * x[i]^2 * (15 // 10 + eltype(x)(sin(i)))^2)^2 for i = 2:n) +
sum((1 - x[i])^2 for i = 2:n)
return 1 // 2 * sum((x[i - 1] - 16 * x[i]^2 * (15 // 10 + eltype(x)(sin(i)))^2)^2 for i = 2:n) +
1 // 2 * sum((1 - x[i])^2 for i = 2:n)
end
x0 = -ones(T, n)
return ADNLPModels.ADNLPModel(f, x0, name = "errinros"; kwargs...)
Expand Down
4 changes: 2 additions & 2 deletions src/ADNLPProblems/freuroth.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ function freuroth(; n::Int = default_nvar, type::Val{T} = Val(Float64), kwargs..
n < 2 && @warn("freuroth: number of variables must be ≥ 2")
n = max(2, n)
function f(x; n = length(x))
return sum(((5 - x[i + 1]) * x[i + 1]^2 + x[i] - 2 * x[i + 1] - 13)^2 for i = 1:(n - 1)) +
sum(((1 + x[i + 1]) * x[i + 1]^2 + x[i] - 14 * x[i + 1] - 29)^2 for i = 1:(n - 1))
return 1 // 2 * sum(((5 - x[i + 1]) * x[i + 1]^2 + x[i] - 2 * x[i + 1] - 13)^2 for i = 1:(n - 1)) +
1 // 2 * sum(((1 + x[i + 1]) * x[i + 1]^2 + x[i] - 14 * x[i + 1] - 29)^2 for i = 1:(n - 1))
end

x0 = zeros(T, n)
Expand Down
2 changes: 1 addition & 1 deletion src/ADNLPProblems/gaussian.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function gaussian(args...; n::Int = default_nvar, type::Val{T} = Val(Float64), k
9 // 10000,
]
function f(x; y = y)
return sum((x[1] * exp(-x[2] / 2 * ((8 - i) // 2 - x[3])^2) - y[i])^2 for i = 1:15)
return 1 // 2 * sum((x[1] * exp(-x[2] / 2 * ((8 - i) // 2 - x[3])^2) - y[i])^2 for i = 1:15)
end
x0 = T[0.4, 1, 0]
return ADNLPModels.ADNLPModel(f, x0, name = "gaussian"; kwargs...)
Expand Down
2 changes: 1 addition & 1 deletion src/ADNLPProblems/hovercraft1d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function hovercraft1d(
N = div(n, 3)
function f(y; N = N)
@views x, v, u = y[1:N], y[(N + 1):(2 * N)], y[(2 * N + 1):end]
return sum(u .^ 2)
return 1 // 2 * sum(u .^ 2)
end
xi = zeros(T, 3 * N - 1)
clinrows = vcat(
Expand Down
2 changes: 1 addition & 1 deletion src/ADNLPProblems/hs13.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export hs13
function hs13(; n::Int = default_nvar, type::Val{T} = Val(Float64), kwargs...) where {T}
function f(x)
n = length(x)
return (x[1] - 2)^2 + x[2]^2
return 1 // 2 * (x[1] - 2)^2 + 1 // 2 * x[2]^2
end
x0 = -2 * ones(T, 2)
lvar = zeros(T, 2)
Expand Down
2 changes: 1 addition & 1 deletion src/ADNLPProblems/hs14.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export hs14

function hs14(; n::Int = default_nvar, type::Val{T} = Val(Float64), kwargs...) where {T}
x0 = T[2; 2]
f(x) = (x[1] - 2)^2 + (x[2] - 1)^2
f(x) = 1 // 2 * (x[1] - 2)^2 + 1 // 2 * (x[2] - 1)^2
c(x) = [x[1]^2 / 4 + x[2]^2 - 1]
lcon = T[-1; -Inf]
ucon = T[-1; 0]
Expand Down
2 changes: 1 addition & 1 deletion src/ADNLPProblems/hs22.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export hs22
function hs22(; n::Int = default_nvar, type::Val{T} = Val(Float64), kwargs...) where {T}
function f(x)
n = length(x)
return (x[1] - 2)^2 + (x[2] - 1)^2
return 1 // 2 * (x[1] - 2)^2 + 1 // 2 * (x[2] - 1)^2
end
x0 = 2 * ones(T, 2)
function c(x)
Expand Down
2 changes: 1 addition & 1 deletion src/ADNLPProblems/hs23.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export hs23
function hs23(; n::Int = default_nvar, type::Val{T} = Val(Float64), kwargs...) where {T}
function f(x)
n = length(x)
return x[1]^2 + x[2]^2
return 1 // 2 * x[1]^2 + 1 // 2 * x[2]^2
end
x0 = T[3, 1]
lvar = -50 * ones(T, 2)
Expand Down
2 changes: 1 addition & 1 deletion src/ADNLPProblems/hs28.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export hs28

function hs28(; n::Int = default_nvar, type::Val{T} = Val(Float64), kwargs...) where {T}
return ADNLPModels.ADNLPModel(
x -> (x[1] + x[2])^2 + (x[2] + x[3])^2,
x -> 1 // 2 * (x[1] + x[2])^2 + 1 // 2 * (x[2] + x[3])^2,
T[-4.0, 1.0, 1.0],
[1; 1; 1],
[1; 2; 3],
Expand Down
2 changes: 1 addition & 1 deletion src/ADNLPProblems/hs30.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export hs30
function hs30(; n::Int = default_nvar, type::Val{T} = Val(Float64), kwargs...) where {T}
function f(x)
n = length(x)
return sum(x[i]^2 for i = 1:3)
return 1 // 2 * sum(x[i]^2 for i = 1:3)
end
x0 = ones(T, 3)
lvar = T[1, -10, -10]
Expand Down
2 changes: 1 addition & 1 deletion src/ADNLPProblems/hs42.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export hs42

function hs42(; n::Int = default_nvar, type::Val{T} = Val(Float64), kwargs...) where {T}
return ADNLPModels.ADNLPModel(
x -> (x[1] - 1)^2 + (x[2] - 2)^2 + (x[3] - 3)^2 + (x[4] - 4)^2,
x -> 1 // 2 * (x[1] - 1)^2 + 1 // 2 * (x[2] - 2)^2 + 1 // 2 * (x[3] - 3)^2 + 1 // 2 * (x[4] - 4)^2,
ones(T, 4),
[1],
[1],
Expand Down
2 changes: 1 addition & 1 deletion src/ADNLPProblems/hs48.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export hs48

function hs48(; n::Int = default_nvar, type::Val{T} = Val(Float64), kwargs...) where {T}
return ADNLPModels.ADNLPModel(
x -> (x[1] - 1)^2 + (x[2] - x[3])^2 + (x[4] - x[5])^2,
x -> 1 // 2 * (x[1] - 1)^2 + 1 // 2 * (x[2] - x[3])^2 + 1 // 2 * (x[4] - x[5])^2,
T[3, 5, -3, 2, -2],
[1; 1; 1; 1; 1; 2; 2; 2],
[1; 2; 3; 4; 5; 3; 4; 5],
Expand Down
2 changes: 1 addition & 1 deletion src/ADNLPProblems/hs51.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export hs51

function hs51(; n::Int = default_nvar, type::Val{T} = Val(Float64), kwargs...) where {T}
return ADNLPModels.ADNLPModel(
x -> (x[1] - x[2])^2 + (x[2] + x[3] - 2)^2 + (x[4] - 1)^2 + (x[5] - 1)^2,
x -> 1 // 2 * (x[1] - x[2])^2 + 1 // 2 * (x[2] + x[3] - 2)^2 + 1 // 2 * (x[4] - 1)^2 + 1 // 2 * (x[5] - 1)^2,
T[2.5, 0.5, 2.0, -1.0, 0.5],
[1; 1; 2; 2; 2; 3; 3],
[1; 2; 3; 4; 5; 2; 5],
Expand Down
2 changes: 1 addition & 1 deletion src/ADNLPProblems/hs52.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export hs52

function hs52(; n::Int = default_nvar, type::Val{T} = Val(Float64), kwargs...) where {T}
return ADNLPModels.ADNLPModel(
x -> (4 * x[1] - x[2])^2 + (x[2] + x[3] - 2)^2 + (x[4] - 1)^2 + (x[5] - 1)^2,
x -> 1 // 2 * (4 * x[1] - x[2])^2 + 1 // 2 * (x[2] + x[3] - 2)^2 + 1 // 2 * (x[4] - 1)^2 + 1 // 2 * (x[5] - 1)^2,
2 * ones(T, 5),
[1; 1; 2; 2; 2; 3; 3],
[1; 2; 3; 4; 5; 2; 5],
Expand Down
2 changes: 1 addition & 1 deletion src/ADNLPProblems/hs53.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export hs53
function hs53(; n::Int = default_nvar, type::Val{T} = Val(Float64), kwargs...) where {T}
function f(x)
n = length(x)
return (x[1] - x[2])^2 + (x[2] + x[3] - 2)^2 + (x[4] - 1)^2 + (x[5] - 1)^2
return 1 // 2 * (x[1] - x[2])^2 + 1 // 2 * (x[2] + x[3] - 2)^2 + 1 // 2 * (x[4] - 1)^2 + 1 // 2 * (x[5] - 1)^2
end
x0 = 2 * ones(T, 5)
lvar = -10 * ones(T, 5)
Expand Down
2 changes: 1 addition & 1 deletion src/ADNLPProblems/hs57.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function hs57(; n::Int = default_nvar, type::Val{T} = Val(Float64), kwargs...) w
b[41:42] .= 40 // 100
b[43:44] .= 39 // 100
function f(x; a = a, b = b)
return sum((b[i] - x[1] - (49 // 100 - x[1]) * exp(-x[2] * (a[i] - 8)))^2 for i = 1:44)
return 1 // 2 * sum((b[i] - x[1] - (49 // 100 - x[1]) * exp(-x[2] * (a[i] - 8)))^2 for i = 1:44)
end
x0 = T[0.42, 5]
lvar = T[0.4, -4]
Expand Down
2 changes: 1 addition & 1 deletion src/ADNLPProblems/hs6.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export hs6

function hs6(; n::Int = default_nvar, type::Val{T} = Val(Float64), kwargs...) where {T}
return ADNLPModels.ADNLPModel(
x -> (x[1] - 1)^2,
x -> 1 // 2 * (x[1] - 1)^2,
T[-1.2; 1.0],
x -> [10 * (x[2] - x[1]^2)],
zeros(T, 1),
Expand Down
2 changes: 1 addition & 1 deletion src/ADNLPProblems/jennrichsampson.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function jennrichsampson(;
kwargs...,
) where {T}
x0 = T[0.3; 0.4]
f(x) = sum((2 + 2 * i - (exp(i * x[1]) + exp(i * x[2])))^2 for i = 1:m)
f(x) = 1 // 2 * sum((2 + 2 * i - (exp(i * x[1]) + exp(i * x[2])))^2 for i = 1:m)

return ADNLPModels.ADNLPModel(f, x0, name = "jennrichsampson"; kwargs...)
end
2 changes: 1 addition & 1 deletion src/ADNLPProblems/kowosb.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function kowosb(args...; n::Int = default_nvar, type::Val{T} = Val(Float64), kwa
625 // 10000,
]
function f(x; m = m, y = y, u = u)
return sum(
return 1 // 2 * sum(
(y[i] - (x[1] * (u[i]^2 + u[i] * x[2])) / (u[i]^2 + u[i] * x[3] + x[4]))^2 for i = 1:m
)
end
Expand Down
2 changes: 1 addition & 1 deletion src/ADNLPProblems/meyer3.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function meyer3(; n::Int = default_nvar, type::Val{T} = Val(Float64), kwargs...)
2872,
]
function f(x)
return sum((x[1] * exp(x[2] / (t[i] + x[3])) - y[i])^2 for i = 1:16)
return 1 // 2 * sum((x[1] * exp(x[2] / (t[i] + x[3])) - y[i])^2 for i = 1:16)
end
return ADNLPModels.ADNLPModel(f, x0, name = "meyer3"; kwargs...)
end
6 changes: 3 additions & 3 deletions src/ADNLPProblems/morebv.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ function morebv(; n::Int = default_nvar, type::Val{T} = Val(Float64), kwargs...)
n = max(2, n)
function f(x)
h = 1 // (n + 1)
return sum(
return 1 // 2 * sum(
(2 * x[i] - x[i - 1] - x[i + 1] + (h^2 // 2) * (x[i] + i * h + 1)^3)^2 for
i = 2:(n - 1)
) +
(2 * x[1] - x[2] + (h^2 // 2) * (x[1] + 1)^3)^2 +
(2 * x[n] - x[n - 1] + (h^2 // 2) * (x[n] + n * h + 1)^3)^2
1 // 2 * (2 * x[1] - x[2] + (h^2 // 2) * (x[1] + 1)^3)^2 +
1 // 2 * (2 * x[n] - x[n - 1] + (h^2 // 2) * (x[n] + n * h + 1)^3)^2
end

x0 = ones(T, n) / 2
Expand Down
2 changes: 1 addition & 1 deletion src/ADNLPProblems/osborne1.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function osborne1(args...; n::Int = default_nvar, type::Val{T} = Val(Float64), k

function f(x)
m = 33
return sum((y[j] - (x[1] + x[2] * exp(-j * x[4]) + x[3] * exp(-j * x[5])))^2 for j = 1:m)
return 1 // 2 * sum((y[j] - (x[1] + x[2] * exp(-j * x[4]) + x[3] * exp(-j * x[5])))^2 for j = 1:m)
end
x0 = T[0.5; 1.5; -1; 0.01; 0.02]
return ADNLPModels.ADNLPModel(f, x0, name = "osborne1"; kwargs...)
Expand Down
2 changes: 1 addition & 1 deletion src/ADNLPProblems/osborne2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function osborne2(args...; n::Int = default_nvar, type::Val{T} = Val(Float64), k
m = 65

function f(x)
return sum(
return 1 // 2 * sum(
(
y[i] - (
x[1] * exp(-(i - 1) // 10 * x[5]) +
Expand Down
2 changes: 1 addition & 1 deletion src/ADNLPProblems/palmer1c.jl
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ function palmer1c(; n::Int = default_nvar, type::Val{T} = Val(Float64), kwargs..
]
function f(x)
Ti = eltype(x)
return sum((Ti(Y[i]) - sum(x[j] * Ti(X[i])^(2 * j - 2) for j = 1:8))^2 for i = 1:35)
return 1 // 2 * sum((Ti(Y[i]) - sum(x[j] * Ti(X[i])^(2 * j - 2) for j = 1:8))^2 for i = 1:35)
end
x0 = ones(T, 8)
return ADNLPModels.ADNLPModel(f, x0, name = "palmer1c"; kwargs...)
Expand Down
2 changes: 1 addition & 1 deletion src/ADNLPProblems/palmer1d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ function palmer1d(; n::Int = default_nvar, type::Val{T} = Val(Float64), kwargs..
]
function f(x)
Ti = eltype(x)
return sum((Ti(Y[i]) - sum(x[j] * Ti(X[i])^(2 * j - 2) for j = 1:7))^2 for i = 1:35)
return 1 // 2 * sum((Ti(Y[i]) - sum(x[j] * Ti(X[i])^(2 * j - 2) for j = 1:7))^2 for i = 1:35)
end
x0 = ones(T, 7)
return ADNLPModels.ADNLPModel(f, x0, name = "palmer1d"; kwargs...)
Expand Down
2 changes: 1 addition & 1 deletion src/ADNLPProblems/palmer2c.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function palmer2c(; n::Int = default_nvar, type::Val{T} = Val(Float64), kwargs..
]
function f(x)
Ti = eltype(x)
return sum((Ti(Y[i]) - sum(x[j] * Ti(X[i])^(2 * j - 2) for j = 1:8))^2 for i = 1:23)
return 1 // 2 * sum((Ti(Y[i]) - sum(x[j] * Ti(X[i])^(2 * j - 2) for j = 1:8))^2 for i = 1:23)
end
x0 = ones(T, 8)
return ADNLPModels.ADNLPModel(f, x0, name = "palmer2c"; kwargs...)
Expand Down
2 changes: 1 addition & 1 deletion src/ADNLPProblems/palmer3c.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function palmer3c(; n::Int = default_nvar, type::Val{T} = Val(Float64), kwargs..
]
function f(x)
Ti = eltype(x)
return sum((Ti(Y[i]) - sum(x[j] * Ti(X[i])^(2 * j - 2) for j = 1:8))^2 for i = 1:23)
return 1 // 2 * sum((Ti(Y[i]) - sum(x[j] * Ti(X[i])^(2 * j - 2) for j = 1:8))^2 for i = 1:23)
end
x0 = ones(T, 8)
return ADNLPModels.ADNLPModel(f, x0, name = "palmer3c"; kwargs...)
Expand Down
2 changes: 1 addition & 1 deletion src/ADNLPProblems/palmer4c.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function palmer4c(; n::Int = default_nvar, type::Val{T} = Val(Float64), kwargs..
]
function f(x)
Ti = eltype(x)
return sum((Ti(Y[i]) - sum(x[j] * Ti(X[i])^(2 * j - 2) for j = 1:8))^2 for i = 1:23)
return 1 // 2 * sum((Ti(Y[i]) - sum(x[j] * Ti(X[i])^(2 * j - 2) for j = 1:8))^2 for i = 1:23)
end
x0 = ones(T, 8)
return ADNLPModels.ADNLPModel(f, x0, name = "palmer4c"; kwargs...)
Expand Down
2 changes: 1 addition & 1 deletion src/ADNLPProblems/palmer5c.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function palmer5c(; n::Int = default_nvar, type::Val{T} = Val(Float64), kwargs..
end
function f(x)
Ti = eltype(x)
return sum((Ti(Y[i]) - sum(x[j] * Ti(t[i, 2 * j - 1]) for j = 1:6))^2 for i = 1:12)
return 1 // 2 * sum((Ti(Y[i]) - sum(x[j] * Ti(t[i, 2 * j - 1]) for j = 1:6))^2 for i = 1:12)
end
x0 = ones(T, 6)
return ADNLPModels.ADNLPModel(f, x0, name = "palmer5c"; kwargs...)
Expand Down
2 changes: 1 addition & 1 deletion src/ADNLPProblems/palmer5d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function palmer5d(; n::Int = default_nvar, type::Val{T} = Val(Float64), kwargs..
]
function f(x)
Ti = eltype(x)
return sum((Ti(Y[i]) - sum(x[j] * Ti(X[i])^(2 * j - 2) for j = 1:4))^2 for i = 1:12)
return 1 // 2 * sum((Ti(Y[i]) - sum(x[j] * Ti(X[i])^(2 * j - 2) for j = 1:4))^2 for i = 1:12)
end
x0 = ones(T, 4)
return ADNLPModels.ADNLPModel(f, x0, name = "palmer5d"; kwargs...)
Expand Down
2 changes: 1 addition & 1 deletion src/ADNLPProblems/palmer6c.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function palmer6c(; n::Int = default_nvar, type::Val{T} = Val(Float64), kwargs..
]
function f(x)
Ti = eltype(x)
return sum((Ti(Y[i]) - sum(x[j] * Ti(X[i])^(2 * j - 2) for j = 1:8))^2 for i = 1:13)
return 1 // 2 * sum((Ti(Y[i]) - sum(x[j] * Ti(X[i])^(2 * j - 2) for j = 1:8))^2 for i = 1:13)
end
x0 = ones(T, 8)
return ADNLPModels.ADNLPModel(f, x0, name = "palmer6c"; kwargs...)
Expand Down
2 changes: 1 addition & 1 deletion src/ADNLPProblems/palmer7c.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function palmer7c(; n::Int = default_nvar, type::Val{T} = Val(Float64), kwargs..
]
function f(x)
Ti = eltype(x)
return sum((Ti(Y[i]) - sum(x[j] * Ti(X[i])^(2 * j - 2) for j = 1:8))^2 for i = 1:13)
return 1 // 2 * sum((Ti(Y[i]) - sum(x[j] * Ti(X[i])^(2 * j - 2) for j = 1:8))^2 for i = 1:13)
end
x0 = ones(T, 8)
return ADNLPModels.ADNLPModel(f, x0, name = "palmer7c"; kwargs...)
Expand Down
2 changes: 1 addition & 1 deletion src/ADNLPProblems/palmer8c.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function palmer8c(; n::Int = default_nvar, type::Val{T} = Val(Float64), kwargs..
]
function f(x)
Ti = eltype(x)
return sum((Ti(Y[i]) - sum(x[j] * Ti(X[i])^(2 * j - 2) for j = 1:8))^2 for i = 1:12)
return 1 // 2 * sum((Ti(Y[i]) - sum(x[j] * Ti(X[i])^(2 * j - 2) for j = 1:8))^2 for i = 1:12)
end
x0 = ones(T, 8)
return ADNLPModels.ADNLPModel(f, x0, name = "palmer8c"; kwargs...)
Expand Down
2 changes: 1 addition & 1 deletion src/ADNLPProblems/power.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export power

function power(; n::Int = default_nvar, type::Val{T} = Val(Float64), kwargs...) where {T}
function f(x; n = length(x))
return (sum((i * x[i]^2) for i = 1:n))^2
return 1 // 2 * (sum((i * x[i]^2) for i = 1:n))^2
end
x0 = ones(T, n)
return ADNLPModels.ADNLPModel(f, x0, name = "power"; kwargs...)
Expand Down
2 changes: 1 addition & 1 deletion src/ADNLPProblems/sbrybnd.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function sbrybnd(; n::Int = default_nvar, type::Val{T} = Val(Float64), kwargs...
J = [[max(1, i - 5):(i - 1); (i + 1):min(n, i + 1)] for i = 1:n]

function f(x; n = length(x))
return sum(
return 1 // 2 * sum(
(
(2 + 5 * eltype(x)(p[i])^2 * x[i]^2) * eltype(x)(p[i]) * x[i] + 1 -
sum(eltype(x)(p[j]) * x[j] * (1 + eltype(x)(p[j]) * x[j]) for j in J[i])
Expand Down
Loading

0 comments on commit b7e24ef

Please sign in to comment.