Skip to content

Commit 987b76e

Browse files
committed
Extra ratios column for decimals
1 parent 5645da2 commit 987b76e

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-3
lines changed

Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ LatexPrint = "d2208f48-c256-5759-9089-c25ed2a93924"
1212
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1313
LinearAlgebraX = "9b3f67b0-2d00-526e-9884-9e4938f8fb88"
1414
PrettyTables = "08abe8d2-0d0c-5749-adfa-8a2ac140af0d"
15+
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
1516
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
1617

1718
[compat]
@@ -23,5 +24,6 @@ LatexPrint = "1"
2324
LinearAlgebra = "1"
2425
LinearAlgebraX = "0.2"
2526
PrettyTables = "3"
27+
Printf = "1"
2628
Test = "1"
2729
julia = "1"

docs/make.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ makedocs(;
1212
# "Solving LPs" => "solve.md",
1313
# "Dual LP" => "dual.md",
1414
"Other Functions" => "other.md",
15-
"API" => "api.md"
15+
"API" => "api.md",
1616
],
1717
sitename="SimplexTableaux",
1818
)

src/Ratios.jl

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,18 @@ end
3232
function _ratio_matrix_str(T::Tableau, col::Int)
3333
RM = _ratio_matrix(T, col)
3434
result = _pretty_string.(RM)
35+
blank = "---"
36+
37+
decimals = [blank for _ in 1:T.n_cons]
3538

3639
for i in 1:T.n_cons
40+
if RM[i, 4] 0
41+
decimals[i] = @sprintf "%.7f" Float64(RM[i, 4])
42+
end
43+
3744
if RM[i, 4] == 1//0
38-
result[i, 4] = "---"
45+
result[i, 4] = blank
46+
decimals[i] = blank
3947
end
4048
end
4149

@@ -44,6 +52,8 @@ function _ratio_matrix_str(T::Tableau, col::Int)
4452
i = 0
4553
end
4654

55+
result = hcat(result, decimals)
56+
4757
return result, i
4858
end
4959

@@ -55,7 +65,7 @@ Display a table for determining a valid pivot for `T` in column `col`.
5565
function ratios(T::Tableau, col::Int)
5666
RMS, i = _ratio_matrix_str(T, col)
5767

58-
header = ["Constraint", "Column $col", "RHS", "Ratio"]
68+
header = ["Constraint", "Column $col", "RHS", "Ratio", "Decimal"]
5969
title = "Ratios for column $col headed by " * _pretty_string(T[0, col])
6070
sub = ""
6171
if T[0, col] < 0

src/SimplexTableaux.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ using LatexPrint
77
using LinearAlgebra
88
using LinearAlgebraX
99
using PrettyTables
10+
using Printf
1011

1112
import Base: getindex, show
1213
import LatexPrint: latex_form

0 commit comments

Comments
 (0)