From 2fc482efa50aa4324ad6dd3b04df7a8ce838d9d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Legat?= Date: Thu, 6 Dec 2018 12:21:01 +0100 Subject: [PATCH] Sort object_dictionary key in printing --- src/print.jl | 2 +- test/print.jl | 10 ++-------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/print.jl b/src/print.jl index 9f35e9d1267..f1190f71b0b 100644 --- a/src/print.jl +++ b/src/print.jl @@ -183,7 +183,7 @@ function Base.show(io::IO, model::Model) end # The last print shouldn't have a new line print(io, "Solver name: ", solver_name(model)) - names_in_scope = collect(keys(object_dictionary(model))) + names_in_scope = sort(collect(keys(object_dictionary(model)))) if !isempty(names_in_scope) println(io) print(io, "Names registered in the model: ", diff --git a/test/print.jl b/test/print.jl index 58878dd30ff..1910617a592 100644 --- a/test/print.jl +++ b/test/print.jl @@ -402,9 +402,6 @@ function printing_test(ModelType::Type{<:JuMP.AbstractModel}) """, repl=:print) - names_in_scope = Set([:b, :c, :c1, :b1, :a1, :x, :fi, :z, :u, :a, :y]) - # The order in which they appear varies between 32-bit and 64-bit - names_in_scope_str = join(names_in_scope, ", ") io_test(REPLMode, model_1, """ A JuMP Model Maximization problem with: @@ -420,7 +417,7 @@ function printing_test(ModelType::Type{<:JuMP.AbstractModel}) Model mode: Automatic CachingOptimizer state: NoOptimizer Solver name: No optimizer attached. - Names registered in the model: $names_in_scope_str""", repl=:show) + Names registered in the model: a, a1, b, b1, c, c1, fi, u, x, y, z""", repl=:show) io_test(IJuliaMode, model_1, """ \\begin{alignat*}{1}\\max\\quad & a - b + 2 a1 - 10 x\\\\ @@ -454,9 +451,6 @@ function printing_test(ModelType::Type{<:JuMP.AbstractModel}) @variable(model_2, y, Int) @constraint(model_2, x*y <= 1) - names_in_scope = Set([:x, :y]) - # The order in which they appear varies between 32-bit and 64-bit - names_in_scope_str = join(names_in_scope, ", ") io_test(REPLMode, model_2, """ A JuMP Model Feasibility problem with: @@ -467,7 +461,7 @@ function printing_test(ModelType::Type{<:JuMP.AbstractModel}) Model mode: Automatic CachingOptimizer state: NoOptimizer Solver name: No optimizer attached. - Names registered in the model: $names_in_scope_str""", repl=:show) + Names registered in the model: x, y""", repl=:show) model_2 = Model() @variable(model_2, x)