Skip to content

Commit

Permalink
Sort object_dictionary key in printing
Browse files Browse the repository at this point in the history
  • Loading branch information
blegat committed Dec 6, 2018
1 parent 8d23e99 commit 2fc482e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/print.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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: ",
Expand Down
10 changes: 2 additions & 8 deletions test/print.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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\\\\
Expand Down Expand Up @@ -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:
Expand All @@ -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)
Expand Down

0 comments on commit 2fc482e

Please sign in to comment.