Skip to content

Commit 63e2744

Browse files
committed
added restore function and remove get_'s
1 parent 7fa41ea commit 63e2744

File tree

3 files changed

+7
-26
lines changed

3 files changed

+7
-26
lines changed

src/Pivoting.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ end
1616
Determine the pivot row for column `j` of `T`.
1717
"""
1818
function find_pivot_row(T::Tableau, j::Int)
19-
rhs = get_b(T)
19+
rhs = T.b
2020
col = T.M[1:(end - 1), j]
2121
vals = rhs .// col
2222
_, i = findmin(vals)

src/SimpleTableaux.jl

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ import Base: show
88

99
TabEntry = Rational{BigInt}
1010

11-
export Tableau,
12-
find_pivot, find_pivot_column, find_pivot_row, get_A, get_b, get_c, pivot, pivot!
11+
export Tableau, find_pivot, find_pivot_column, find_pivot_row, pivot, pivot!, restore
1312

1413
"""
1514
Tableau(A::Matrix, b::Vector, c::Vector)
@@ -38,31 +37,12 @@ struct Tableau
3837
end
3938

4039
"""
41-
get_A(T::Tableau)
40+
restore(T::Tableau)
4241
43-
Return the coefficient matrix of this `Tableau`.
42+
Create a new `Tableau` based on the original data used to create `T`.
4443
"""
45-
function get_A(T::Tableau)
46-
return copy(T.M[1:(T.n_cons), 1:(T.n_vars)])
47-
end
48-
49-
"""
50-
get_b(T::Tableau)
51-
52-
Return the RHS of this `Tableau`.
53-
"""
54-
function get_b(T::Tableau)
55-
return copy(T.M[1:(T.n_cons), end])
56-
end
57-
58-
"""
59-
get_c(T::Tableau)
60-
61-
Return the objective function of this `Tableau`.
62-
"""
63-
function get_c(T::Tableau)
64-
c = T.M[end, 1:(T.n_vars)]
65-
return collect(-c)
44+
function restore(T::Tableau)
45+
return Tableau(T.A, T.b, T.C)
6646
end
6747

6848
include("Exact.jl")

test/runtests.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ using DataFrames
88
b = [1; 3//2]
99
c = [5; 6; 9; 2]
1010
T = Tableau(A, b, c)
11+
pivot!(T)
1112
@test true
1213
end

0 commit comments

Comments
 (0)