From 958a1a498f562906a6d132e1419aed4fe040c984 Mon Sep 17 00:00:00 2001 From: "mhsatman@gmail.com" Date: Fri, 10 May 2024 19:25:07 +0300 Subject: [PATCH] export JuMP and HiGHS for external use --- CHANGELOG.md | 1 + src/OperationsResearchModels.jl | 8 +++----- test/runtests.jl | 1 + test/testjump.jl | 24 ++++++++++++++++++++++++ 4 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 test/testjump.jl diff --git a/CHANGELOG.md b/CHANGELOG.md index 8de4f11..1f9ba95 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ### 0.2.1 (Upcoming Release) +- Export JuMP and HiGHS for external use - Fix documentation of CpmActivity - Fix documentation of Knapsack solver diff --git a/src/OperationsResearchModels.jl b/src/OperationsResearchModels.jl index 932262b..b182776 100644 --- a/src/OperationsResearchModels.jl +++ b/src/OperationsResearchModels.jl @@ -1,10 +1,6 @@ module OperationsResearchModels - -# Default Optimizer -using HiGHS -const theoptimizerpackage = Symbol("HiGHS") -const theoptimizer = HiGHS.Optimizer +using JuMP, HiGHS solve() = nothing @@ -67,6 +63,8 @@ export Simplex export Utility export latex +export JuMP, HiGHS + diff --git a/test/runtests.jl b/test/runtests.jl index ac6f418..34aae1b 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -3,6 +3,7 @@ using OperationsResearchModels using OperationsResearchModels.Simplex include("testutility.jl") +include("testjump.jl") include("testtransportation.jl") include("testassignment.jl") include("testshortestpath.jl") diff --git a/test/testjump.jl b/test/testjump.jl new file mode 100644 index 0000000..7d0d2cb --- /dev/null +++ b/test/testjump.jl @@ -0,0 +1,24 @@ +@testset "JuMP and HiGHS" begin + + eps = 0.001 + + import OperationsResearchModels: JuMP, HiGHS + import .JuMP: MOI + + m = JuMP.Model(OperationsResearchModels.HiGHS.Optimizer) + MOI.set(m, MOI.Silent(), true) + + JuMP.@variable(m, x >= 0) + JuMP.@variable(m, y >= 0) + + JuMP.@objective(m, Max, x + 2y) + + JuMP.@constraint(m, x + y <= 1) + + JuMP.optimize!(m) + + @test isapprox(JuMP.value(x), 0.0, atol = eps) + @test isapprox(JuMP.value(y), 1.0, atol = eps) + + @test isapprox(JuMP.objective_value(m), 2.0, atol = eps) +end \ No newline at end of file