-
Notifications
You must be signed in to change notification settings - Fork 48
Expand file tree
/
Copy pathhs6.jl
More file actions
43 lines (40 loc) · 855 Bytes
/
hs6.jl
File metadata and controls
43 lines (40 loc) · 855 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
export hs6
function hs6(; use_nls::Bool = false, kwargs...)
model = use_nls ? :nls : :nlp
return hs6(Val(model); kwargs...)
end
function hs6(::Val{:nlp}; n::Int = default_nvar, type::Type{T} = Float64, kwargs...) where {T}
function c!(cx, x)
cx[1] = 10 * (x[2] - x[1]^2)
return cx
end
return ADNLPModels.ADNLPModel!(
x -> 1 // 2 * (x[1] - 1)^2,
T[-1.2; 1.0],
c!,
zeros(T, 1),
zeros(T, 1),
name = "hs6";
kwargs...,
)
end
function hs6(::Val{:nls}; n::Int = default_nvar, type::Type{T} = Float64, kwargs...) where {T}
function F!(r, x)
r[1] = (x[1] - 1)
return r
end
function c!(cx, x)
cx[1] = 10 * (x[2] - x[1]^2)
return cx
end
return ADNLPModels.ADNLSModel!(
F!,
T[-1.2; 1.0],
1,
c!,
zeros(T, 1),
zeros(T, 1),
name = "hs6-nls";
kwargs...,
)
end