From 1cdd64f9f2d305cdaf89a81c5385bf1499698c7a Mon Sep 17 00:00:00 2001 From: Jean-Luc Lupien Date: Thu, 14 Apr 2022 20:27:17 -0400 Subject: [PATCH] Added Gaussian fct --- src/ADNLPProblems/gaussian.jl | 10 ++++++++++ src/Meta/gaussian.jl | 25 +++++++++++++++++++++++++ src/PureJuMP/gaussian.jl | 28 ++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+) create mode 100644 src/ADNLPProblems/gaussian.jl create mode 100644 src/Meta/gaussian.jl create mode 100644 src/PureJuMP/gaussian.jl diff --git a/src/ADNLPProblems/gaussian.jl b/src/ADNLPProblems/gaussian.jl new file mode 100644 index 00000000..b5ff72e9 --- /dev/null +++ b/src/ADNLPProblems/gaussian.jl @@ -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 diff --git a/src/Meta/gaussian.jl b/src/Meta/gaussian.jl new file mode 100644 index 00000000..f3719d3c --- /dev/null +++ b/src/Meta/gaussian.jl @@ -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 diff --git a/src/PureJuMP/gaussian.jl b/src/PureJuMP/gaussian.jl new file mode 100644 index 00000000..29195835 --- /dev/null +++ b/src/PureJuMP/gaussian.jl @@ -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