Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Gaussian fct #143

Merged
merged 1 commit into from
Apr 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/ADNLPProblems/gaussian.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export gaussian

function gaussian(args...; n::Int = default_nvar, type::Val{T} = Val(Float64), kwargs...) where {T}
function f(x)
y = T[.0009, .0044, .0175, .054, .1295, .242, .3521, .3989, .3521, .242, .1295, .054, .0175, .0044, .0009]
return sum( (x[1]*exp(-x[2]/2*(T(8-i)/2-x[3])^2)-y[i])^2 for i=1:15)
end
x0 = T[.4, 1, 0]
return ADNLPModels.ADNLPModel(f, x0, name = "gaussian"; kwargs...)
end
25 changes: 25 additions & 0 deletions src/Meta/gaussian.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
gaussian_meta = Dict(
:nvar => 3,
:variable_nvar => false,
:ncon => 0,
:variable_ncon => false,
:minimize => true,
:name => "gaussian",
:has_equalities_only => false,
:has_inequalities_only => false,
:has_bounds => false,
:has_fixed_variables => false,
:objtype => :other,
:contype => :unconstrained,
:best_known_lower_bound => -Inf,
:best_known_upper_bound => 3.888106991166885e-6,
:is_feasible => true,
:defined_everywhere => missing,
:origin => :unknown,
)
get_gaussian_nvar(; n::Integer = default_nvar, kwargs...) = 3
get_gaussian_ncon(; n::Integer = default_nvar, kwargs...) = 0
get_gaussian_nlin(; n::Integer = default_nvar, kwargs...) = 0
get_gaussian_nnln(; n::Integer = default_nvar, kwargs...) = 0
get_gaussian_nequ(; n::Integer = default_nvar, kwargs...) = 0
get_gaussian_nineq(; n::Integer = default_nvar, kwargs...) = 0
28 changes: 28 additions & 0 deletions src/PureJuMP/gaussian.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Source: Problem 9 in
# J.J. More', B.S. Garbow and K.E. Hillstrom,
# "Testing Unconstrained Optimization Software",
# ACM Transactions on Mathematical Software, vol. 7(1), pp. 17-41, 1981.

# See also Buckley#28

# classification SUR2-AN-3-0
export gaussian

function gaussian(args...; n::Int = default_nvar, kwargs...)
nlp = Model()

x0 = [.4, 1, 0]
@variable(nlp, x[i=1:3], start=x0[i])

y = [.0009, .0044, .0175, .054, .1295, .242, .3521, .3989, .3521, .242, .1295, .054, .0175, .0044, .0009]

@NLobjective(nlp, Min, (x[1]*exp(-x[2]/2*((8-1)/2-x[3])^2)-y[1])^2 + (x[1]*exp(-x[2]/2*((8-2)/2-x[3])^2)-y[2])^2
+ (x[1]*exp(-x[2]/2*((8-3)/2-x[3])^2)-y[3])^2 + (x[1]*exp(-x[2]/2*((8-4)/2-x[3])^2)-y[4])^2
+ (x[1]*exp(-x[2]/2*((8-5)/2-x[3])^2)-y[5])^2+ (x[1]*exp(-x[2]/2*((8-6)/2-x[3])^2)-y[6])^2
+ (x[1]*exp(-x[2]/2*((8-7)/2-x[3])^2)-y[7])^2+ (x[1]*exp(-x[2]/2*((8-8)/2-x[3])^2)-y[8])^2
+ (x[1]*exp(-x[2]/2*((8-9)/2-x[3])^2)-y[9])^2+ (x[1]*exp(-x[2]/2*((8-10)/2-x[3])^2)-y[10])^2
+ (x[1]*exp(-x[2]/2*((8-11)/2-x[3])^2)-y[11])^2+ (x[1]*exp(-x[2]/2*((8-12)/2-x[3])^2)-y[12])^2
+ (x[1]*exp(-x[2]/2*((8-13)/2-x[3])^2)-y[13])^2+ (x[1]*exp(-x[2]/2*((8-14)/2-x[3])^2)-y[14])^2
+ (x[1]*exp(-x[2]/2*((8-15)/2-x[3])^2)-y[15])^2 )
return nlp
end