From 9b4e23367e9f9b2db3039eb4faf80f06159ad879 Mon Sep 17 00:00:00 2001 From: odow Date: Fri, 15 Sep 2023 14:42:53 +1200 Subject: [PATCH 1/2] Add tests for min(x, y) and max(x, y) --- src/nlp-expr/009_010.jl | 29 +++++++++++++++++++++++++++++ src/nlp-expr/009_011.jl | 29 +++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 src/nlp-expr/009_010.jl create mode 100644 src/nlp-expr/009_011.jl diff --git a/src/nlp-expr/009_010.jl b/src/nlp-expr/009_010.jl new file mode 100644 index 0000000..63c984d --- /dev/null +++ b/src/nlp-expr/009_010.jl @@ -0,0 +1,29 @@ +# Copyright (c) 2021 MINLPTests.jl contributors +# +# Use of this source code is governed by an MIT-style license that can be found +# in the LICENSE.md file or at https://opensource.org/licenses/MIT. + +function nlp_expr_009_010( + optimizer, + objective_tol, + primal_tol, + dual_tol, + termination_target = TERMINATION_TARGET_LOCAL, + primal_target = PRIMAL_TARGET_LOCAL, +) + # Test Goals: + # - min support + + model = Model(optimizer) + + @variable(model, x) + + @objective(model, Max, min(0.75 + (x - 0.5)^3, 0.75 - (x - 0.5)^2)) + + optimize!(model) + + check_status(model, FEASIBLE_PROBLEM, termination_target, primal_target) + check_objective(model, 0.75, tol = objective_tol) + check_solution([x], [0.5], tol = primal_tol) + return +end diff --git a/src/nlp-expr/009_011.jl b/src/nlp-expr/009_011.jl new file mode 100644 index 0000000..06c1ac5 --- /dev/null +++ b/src/nlp-expr/009_011.jl @@ -0,0 +1,29 @@ +# Copyright (c) 2021 MINLPTests.jl contributors +# +# Use of this source code is governed by an MIT-style license that can be found +# in the LICENSE.md file or at https://opensource.org/licenses/MIT. + +function nlp_expr_009_011( + optimizer, + objective_tol, + primal_tol, + dual_tol, + termination_target = TERMINATION_TARGET_LOCAL, + primal_target = PRIMAL_TARGET_LOCAL, +) + # Test Goals: + # - max support + + model = Model(optimizer) + + @variable(model, x) + + @objective(model, Min, max(0.75 + (x - 0.5)^3, 0.75 + (x - 0.5)^2)) + + optimize!(model) + + check_status(model, FEASIBLE_PROBLEM, termination_target, primal_target) + check_objective(model, 0.75, tol = objective_tol) + check_solution([x], [0.5], tol = primal_tol) + return +end From b498c1bd350761165510a1fab4096b676f129d60 Mon Sep 17 00:00:00 2001 From: odow Date: Sat, 16 Sep 2023 11:15:28 +1200 Subject: [PATCH 2/2] Add to @NL tests as well --- src/nlp/009_010.jl | 29 +++++++++++++++++++++++++++++ src/nlp/009_011.jl | 29 +++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 src/nlp/009_010.jl create mode 100644 src/nlp/009_011.jl diff --git a/src/nlp/009_010.jl b/src/nlp/009_010.jl new file mode 100644 index 0000000..37e652f --- /dev/null +++ b/src/nlp/009_010.jl @@ -0,0 +1,29 @@ +# Copyright (c) 2021 MINLPTests.jl contributors +# +# Use of this source code is governed by an MIT-style license that can be found +# in the LICENSE.md file or at https://opensource.org/licenses/MIT. + +function nlp_009_010( + optimizer, + objective_tol, + primal_tol, + dual_tol, + termination_target = TERMINATION_TARGET_LOCAL, + primal_target = PRIMAL_TARGET_LOCAL, +) + # Test Goals: + # - min support + + model = Model(optimizer) + + @variable(model, x) + + @NLobjective(model, Max, min(0.75 + (x - 0.5)^3, 0.75 - (x - 0.5)^2)) + + optimize!(model) + + check_status(model, FEASIBLE_PROBLEM, termination_target, primal_target) + check_objective(model, 0.75, tol = objective_tol) + check_solution([x], [0.5], tol = primal_tol) + return +end diff --git a/src/nlp/009_011.jl b/src/nlp/009_011.jl new file mode 100644 index 0000000..6276b9a --- /dev/null +++ b/src/nlp/009_011.jl @@ -0,0 +1,29 @@ +# Copyright (c) 2021 MINLPTests.jl contributors +# +# Use of this source code is governed by an MIT-style license that can be found +# in the LICENSE.md file or at https://opensource.org/licenses/MIT. + +function nlp_009_011( + optimizer, + objective_tol, + primal_tol, + dual_tol, + termination_target = TERMINATION_TARGET_LOCAL, + primal_target = PRIMAL_TARGET_LOCAL, +) + # Test Goals: + # - max support + + model = Model(optimizer) + + @variable(model, x) + + @NLobjective(model, Min, max(0.75 + (x - 0.5)^3, 0.75 + (x - 0.5)^2)) + + optimize!(model) + + check_status(model, FEASIBLE_PROBLEM, termination_target, primal_target) + check_objective(model, 0.75, tol = objective_tol) + check_solution([x], [0.5], tol = primal_tol) + return +end