From 667f66a8d040564ef25392c963240f456dad10a3 Mon Sep 17 00:00:00 2001 From: Joey Huchette Date: Sun, 4 Jan 2015 17:59:41 -0500 Subject: [PATCH] fixup tests --- src/print.jl | 2 +- test/print.jl | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/src/print.jl b/src/print.jl index a246c8cfaf7..c7689a2a499 100644 --- a/src/print.jl +++ b/src/print.jl @@ -190,7 +190,7 @@ function model_str(mode, m::Model, leq, geq, in_set, str *= sep * "$var_name $in_set $open_rng$str_lb,$str_ub$close_rng $union $(open_set)0$close_set" elseif var_cat == :Fixed str *= sep * "$var_name = $str_lb" - elseif var_lb == -Inf && var_ub == +Inf && var_cat == :Cont # Free variable + elseif var_lb == -Inf && var_ub == +Inf # Free variable str *= sep * "$var_name free" elseif var_lb == -Inf # No lower bound str *= sep * "$var_name $leq $str_ub" diff --git a/test/print.jl b/test/print.jl index a4b5fa76ffc..2de5b3e3c4a 100644 --- a/test/print.jl +++ b/test/print.jl @@ -391,7 +391,46 @@ Solver set to Default""", repl=:show) """, repl=:print) end +facts("[print] changing variable categories") do + le, ge = JuMP.repl_leq, JuMP.repl_geq + mod = Model() + @defVar(mod, x[1:3]) + @defVar(mod, y[i=1:3,i:3]) + setCategory(x[3], :SemiCont) + setCategory(y[1,3], :Int) + + io_test(REPLMode, mod, """ +Min 0 +Subject to + x[i] free for all i in {1,2,3} + y[i,j] free for all i in {1,2,3}, j in {..} + x[1] free + x[2] free + x[3] in [-Inf,Inf] or {0} + y[1,1] free + y[1,2] free + y[1,3] free, integer + y[2,2] free + y[2,3] free + y[3,3] free +""", repl=:print) + io_test(IJuliaMode, mod, """ +\\begin{alignat*}{1}\\min\\quad & 0\\\\ +\\text{Subject to} \\quad & x_{i} free \\quad\\forall i \\in \\{1,2,3\\}\\\\ + & y_{i,j} free \\quad\\forall i \\in \\{1,2,3\\}, j \\in \\{..\\}\\\\ + & x_{1} free\\\\ + & x_{2} free\\\\ + & x_{3} \\in \\[-Inf,Inf\\] \\cup \\{0\\}\\\\ + & y_{1,1} free\\\\ + & y_{1,2} free\\\\ + & y_{1,3} free, \\in \\mathbb{Z}\\\\ + & y_{2,2} free\\\\ + & y_{2,3} free\\\\ + & y_{3,3} free\\\\ +\\end{alignat*} +""") +end facts("[print] expressions") do # Most of the expression logic is well covered by test/operator.jl