From 9720c804e8f52ff316652ca5d1818e7f198a59a6 Mon Sep 17 00:00:00 2001 From: Oscar Dowson Date: Wed, 13 Nov 2024 20:59:41 +1300 Subject: [PATCH] Add MINLPTests (#586) --- .github/workflows/MINLPTests.yml | 44 +++++++++++++++++++++++ test/MINLPTests/Project.toml | 6 ++++ test/MINLPTests/runtests.jl | 61 ++++++++++++++++++++++++++++++++ 3 files changed, 111 insertions(+) create mode 100644 .github/workflows/MINLPTests.yml create mode 100644 test/MINLPTests/Project.toml create mode 100644 test/MINLPTests/runtests.jl diff --git a/.github/workflows/MINLPTests.yml b/.github/workflows/MINLPTests.yml new file mode 100644 index 00000000..d4880575 --- /dev/null +++ b/.github/workflows/MINLPTests.yml @@ -0,0 +1,44 @@ +name: MINLPTests +on: + push: + branches: [master] + pull_request: + types: [opened, synchronize, reopened] +jobs: + test: + name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + version: ['1'] + os: [ubuntu-latest] + arch: ['x64'] + steps: + - uses: actions/checkout@v4 + - uses: julia-actions/setup-julia@v2 + with: + version: ${{ matrix.version }} + arch: ${{ matrix.arch }} + - uses: julia-actions/cache@v1 + - shell: julia --project=. --color=yes {0} + run: | + import Pkg + Pkg.add(; name = "Gurobi_jll", version = "12.0.0") + env: + GUROBI_JL_SKIP_LIB_CHECK: "true" + GUROBI_JLL_VERSION: ${{ matrix.jll_version }} + - uses: julia-actions/julia-buildpkg@v1 + env: + WLSLICENSE: ${{ secrets.WLSLICENSE }} + - uses: julia-actions/julia-buildpkg@v1 + - name: + shell: julia --color=yes {0} + run: | + path = joinpath(ENV["GITHUB_WORKSPACE"], "test", "MINLPTests") + cd(path) + using Pkg + Pkg.activate(".") + Pkg.instantiate() + Pkg.add(PackageSpec(path=ENV["GITHUB_WORKSPACE"])) + include(joinpath(path, "runtests.jl")) diff --git a/test/MINLPTests/Project.toml b/test/MINLPTests/Project.toml new file mode 100644 index 00000000..62e196fb --- /dev/null +++ b/test/MINLPTests/Project.toml @@ -0,0 +1,6 @@ +[deps] +MINLPTests = "ee0a3090-8ee9-5cdb-b8cb-8eeba3165522" +Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" + +[compat] +MINLPTests = "0.6.1" diff --git a/test/MINLPTests/runtests.jl b/test/MINLPTests/runtests.jl new file mode 100644 index 00000000..6fd5d581 --- /dev/null +++ b/test/MINLPTests/runtests.jl @@ -0,0 +1,61 @@ +# Copyright (c) 2015 Dahua Lin, Miles Lubin, Joey Huchette, Iain Dunning, and +# 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. + +using Gurobi +using MINLPTests +using Test + +@testset "MINLPTests" begin + optimizer = MINLPTests.JuMP.optimizer_with_attributes( + Gurobi.Optimizer, + "TimeLimit" => 60.0, + ) + MINLPTests.test_nlp_cvx_expr( + optimizer; + termination_target = MINLPTests.TERMINATION_TARGET_GLOBAL, + primal_target = MINLPTests.PRIMAL_TARGET_GLOBAL, + objective_tol = 1e-6, + primal_tol = 1e-2, + dual_tol = NaN, + exclude = [ + "206_010", # TIME_LIMIT + "501_011", # TIME_LIMIT + ], + ) + MINLPTests.test_nlp_expr( + optimizer; + termination_target = MINLPTests.TERMINATION_TARGET_GLOBAL, + primal_target = MINLPTests.PRIMAL_TARGET_GLOBAL, + objective_tol = 1e-6, + primal_tol = 1e-2, + dual_tol = NaN, + exclude = [ + "001_010", # TIME_LIMIT + "004_010", # abs + "004_011", # abs + "005_010", # inv + "006_010", # UserDefinedFunction + "008_010", # MINLPTests.jl#21 + "009_010", # min + "009_011", # max + ], + ) + MINLPTests.test_nlp_mi_expr( + optimizer; + termination_target = MINLPTests.TERMINATION_TARGET_GLOBAL, + primal_target = MINLPTests.PRIMAL_TARGET_GLOBAL, + objective_tol = 1e-6, + primal_tol = 1e-2, + dual_tol = NaN, + exclude = [ + "001_010", # TIME_LIMIT + "004_010", # abs + "004_011", # abs + "005_010", # inv + "006_010", # UserDefinedFunction + ], + ) +end