Skip to content

Commit

Permalink
Add tests for min(x, y) and max(x, y) (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
odow authored Sep 16, 2023
1 parent a85f1a5 commit af2232f
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/nlp-expr/009_010.jl
Original file line number Diff line number Diff line change
@@ -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
29 changes: 29 additions & 0 deletions src/nlp-expr/009_011.jl
Original file line number Diff line number Diff line change
@@ -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
29 changes: 29 additions & 0 deletions src/nlp/009_010.jl
Original file line number Diff line number Diff line change
@@ -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
29 changes: 29 additions & 0 deletions src/nlp/009_011.jl
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit af2232f

Please sign in to comment.