From 503d1f440fd48e2dcc79906d612dbe1d0f6bd784 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Legat?= Date: Sat, 31 Dec 2016 13:17:29 +0100 Subject: [PATCH] Test that getsolution is feasible when problem is Unbounded --- test/linproginterface.jl | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/test/linproginterface.jl b/test/linproginterface.jl index aff86c1..ecc59e0 100644 --- a/test/linproginterface.jl +++ b/test/linproginterface.jl @@ -192,6 +192,30 @@ function linprogsolvertest(solver::AbstractMathProgSolver, eps = Base.rtoldefaul @test getconstrLB(m)[i] <= getconstrsolution(m)[i] + eps @test getconstrsolution(m)[i] <= getconstrUB(m)[i] + eps end + + # Tests that getsolution is feasible when the problem is unbounded + # so that getsolution() + λ getunboundedray() is feasible for any λ >= 0 + # See https://github.com/JuliaOpt/MathProgBase.jl/pull/144 + + # Max x + # s.t. x >= 1 + # x unbounded + # y <= -1 + loadproblem!(m, [1. 0.], [-Inf, -Inf], [Inf, -1], [1., 0.], [1], [Inf], :Max) + optimize!(m) + @test MathProgBase.status(m) == :Unbounded + x = MathProgBase.getsolution(m) + @test 1 <= x[1] + eps + @test x[2] <= -1 + eps + + # See https://github.com/JuliaOpt/Gurobi.jl/issues/80 + # Min y + # s.t. x >= 1 + loadproblem!(m, [1. 0.], [-Inf, -Inf], [Inf, Inf], [0., 1.], [1.], [Inf], :Min) + optimize!(m) + @test MathProgBase.status(m) == :Unbounded + x = MathProgBase.getsolution(m) + @test 1 <= x[1] + eps end