Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix formatting of test/test_solution_summary.jl #3849

Merged
merged 1 commit into from
Oct 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
198 changes: 102 additions & 96 deletions test/test_solution_summary.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,22 @@ using Test

function test_empty_model()
model = Model()
@test sprint(show, solution_summary(model)) == """
* Solver : No optimizer attached.
ret = """
* Solver : No optimizer attached.
* Status
Result count : 0
Termination status : OPTIMIZE_NOT_CALLED
Message from the solver:
"optimize not called"
* Status
Result count : 0
Termination status : OPTIMIZE_NOT_CALLED
Message from the solver:
"optimize not called"
* Candidate solution (result #1)
Primal status : NO_SOLUTION
Dual status : NO_SOLUTION
* Candidate solution (result #1)
Primal status : NO_SOLUTION
Dual status : NO_SOLUTION
* Work counters
"""
* Work counters
"""
@test sprint(show, solution_summary(model)) == ret
return
end

Expand Down Expand Up @@ -65,102 +66,107 @@ function test_solution_summary()
MOI.set(mock, MOI.BarrierIterations(), Int64(2))
MOI.set(mock, MOI.NodeCount(), Int64(1))
MOI.set(mock, MOI.SolveTimeSec(), 5.0)
@test sprint(show, solution_summary(model)) == """
* Solver : Mock
* Status
Result count : 2
Termination status : OPTIMAL
Message from the solver:
"solver specific string"
* Candidate solution (result #1)
Primal status : FEASIBLE_POINT
Dual status : FEASIBLE_POINT
Objective value : -1.00000e+00
Objective bound : -3.00000e+00
Relative gap : 6.66667e-01
Dual objective value : -1.00000e+00
* Work counters
Solve time (sec) : 5.00000e+00
Simplex iterations : 3
Barrier iterations : 2
Node count : 1
"""
ret = """
* Solver : Mock
* Status
Result count : 2
Termination status : OPTIMAL
Message from the solver:
"solver specific string"
* Candidate solution (result #1)
Primal status : FEASIBLE_POINT
Dual status : FEASIBLE_POINT
Objective value : -1.00000e+00
Objective bound : -3.00000e+00
Relative gap : 6.66667e-01
Dual objective value : -1.00000e+00
* Work counters
Solve time (sec) : 5.00000e+00
Simplex iterations : 3
Barrier iterations : 2
Node count : 1
"""
@test sprint(show, solution_summary(model)) == ret

summary = solution_summary(model; verbose = true)
@test sprint(show, summary) == """
* Solver : Mock
* Status
Result count : 2
Termination status : OPTIMAL
Message from the solver:
"solver specific string"
* Candidate solution (result #1)
Primal status : FEASIBLE_POINT
Dual status : FEASIBLE_POINT
Objective value : -1.00000e+00
Objective bound : -3.00000e+00
Relative gap : 6.66667e-01
Dual objective value : -1.00000e+00
Primal solution :
x : 1.00000e+00
y : 0.00000e+00
Dual solution :
* Work counters
Solve time (sec) : 5.00000e+00
Simplex iterations : 3
Barrier iterations : 2
Node count : 1
"""
ret = """
* Solver : Mock
* Status
Result count : 2
Termination status : OPTIMAL
Message from the solver:
"solver specific string"
* Candidate solution (result #1)
Primal status : FEASIBLE_POINT
Dual status : FEASIBLE_POINT
Objective value : -1.00000e+00
Objective bound : -3.00000e+00
Relative gap : 6.66667e-01
Dual objective value : -1.00000e+00
Primal solution :
x : 1.00000e+00
y : 0.00000e+00
Dual solution :
* Work counters
Solve time (sec) : 5.00000e+00
Simplex iterations : 3
Barrier iterations : 2
Node count : 1
"""
@test sprint(show, summary) == ret

summary = solution_summary(model; result = 2)
@test sprint(show, summary) == """
* Solver : Mock
ret = """
* Solver : Mock
* Status
Result count : 2
Termination status : OPTIMAL
* Status
Result count : 2
Termination status : OPTIMAL
* Candidate solution (result #2)
Primal status : FEASIBLE_POINT
Dual status : NO_SOLUTION
Objective value : -0.00000e+00
"""
* Candidate solution (result #2)
Primal status : FEASIBLE_POINT
Dual status : NO_SOLUTION
Objective value : -0.00000e+00
"""
@test sprint(show, summary) == ret

summary = solution_summary(model; result = 2, verbose = true)
@test sprint(show, summary) == """
* Solver : Mock
* Status
Result count : 2
Termination status : OPTIMAL
* Candidate solution (result #2)
Primal status : FEASIBLE_POINT
Dual status : NO_SOLUTION
Objective value : -0.00000e+00
Primal solution :
x : 0.00000e+00
y : 0.00000e+00
"""
ret = """
* Solver : Mock
* Status
Result count : 2
Termination status : OPTIMAL
* Candidate solution (result #2)
Primal status : FEASIBLE_POINT
Dual status : NO_SOLUTION
Objective value : -0.00000e+00
Primal solution :
x : 0.00000e+00
y : 0.00000e+00
"""
@test sprint(show, summary) == ret

summary = solution_summary(model; result = 3)
@test sprint(show, summary) == """
* Solver : Mock
ret = """
* Solver : Mock
* Status
Result count : 2
Termination status : OPTIMAL
* Status
Result count : 2
Termination status : OPTIMAL
* Candidate solution (result #3)
Primal status : NO_SOLUTION
Dual status : NO_SOLUTION
"""
* Candidate solution (result #3)
Primal status : NO_SOLUTION
Dual status : NO_SOLUTION
"""
@test sprint(show, summary) == ret
return
end

Expand Down
Loading