diff --git a/src/ADNLPProblems/BOX2.jl b/src/ADNLPProblems/BOX2.jl new file mode 100644 index 00000000..b3f8d7dc --- /dev/null +++ b/src/ADNLPProblems/BOX2.jl @@ -0,0 +1,13 @@ +export BOX2 + +function BOX2(args...; n::Int = default_nvar, type::Val{T} = Val(Float64), m::Int = 10, kwargs...) where {T} + m < 3 && @warn("BOX2: must have m ≥ 3") + m = max(m, 3) + + x0 = T[0; 10; 1] + f(x) = one(T)/2*sum((exp(-one(T)/10*j*x[1]) - exp(-one(T)/10*j*x[2]) -x[3]*(exp(-one(T)/10*j) - exp(-T(j))))^2 for j = 1:m) + c(x) = [x[3]] + l = ones(T, 1) + + return ADNLPModels.ADNLPModel(f, x0, c, l, l, name = "BOX2", lin = [1]; kwargs...) +end diff --git a/src/Meta/BOX2.jl b/src/Meta/BOX2.jl new file mode 100644 index 00000000..c5f056e0 --- /dev/null +++ b/src/Meta/BOX2.jl @@ -0,0 +1,25 @@ +BOX2_meta = Dict( + :nvar => 3, + :variable_nvar => false, + :ncon => 1, + :variable_ncon => false, + :minimize => true, + :name => "BOX2", + :has_equalities_only => true, + :has_inequalities_only => false, + :has_bounds => false, + :has_fixed_variables => false, + :objtype => :other, + :contype => :general, + :best_known_lower_bound => -Inf, + :best_known_upper_bound => 0.9422842504428566, + :is_feasible => true, + :defined_everywhere => missing, + :origin => :unknown, +) +get_BOX2_nvar(; n::Integer = default_nvar, kwargs...) = 3 +get_BOX2_ncon(; n::Integer = default_nvar, kwargs...) = 1 +get_BOX2_nlin(; n::Integer = default_nvar, kwargs...) = 1 +get_BOX2_nnln(; n::Integer = default_nvar, kwargs...) = 0 +get_BOX2_nequ(; n::Integer = default_nvar, kwargs...) = 1 +get_BOX2_nineq(; n::Integer = default_nvar, kwargs...) = 0 diff --git a/src/PureJuMP/BOX2.jl b/src/PureJuMP/BOX2.jl new file mode 100644 index 00000000..cf9045b6 --- /dev/null +++ b/src/PureJuMP/BOX2.jl @@ -0,0 +1,28 @@ +# Box problem in 2 variables, obtained by fixing X3 = 1 in BOX2. + +# Source: Problem 11 in +# A.R. Buckley, +# "Test functions for unconstrained minimization", +# TR 1989CS-3, Mathematics, statistics and computing centre, +# Dalhousie University, Halifax (CDN), 1989. + +# classification SXR2-AN-3-0 +export BOX2 + +function BOX2(args...; n::Int = default_nvar, m::Int = 10, kwargs...) + m < 3 && @warn("BOX2: must have m ≥ 3") + m = max(m, 3) + + nlp = Model() + + x0 = [0.0; 10.0; 1.0] + @variable(nlp, x[i=1:3], start = x0[i]) + + @NLobjective( + nlp, + Min, + 0.5*sum((exp(-0.1*j*x[1]) - exp(-0.1*j*x[2]) -x[3]*(exp(-0.1*j) - exp(-j)))^2 for j = 1:m)) + @constraint(nlp, x[3] == 1) + + return nlp +end \ No newline at end of file