Skip to content

Commit 5eea0fe

Browse files
committed
Rename some functions.
1 parent be7b188 commit 5eea0fe

File tree

8 files changed

+46
-22
lines changed

8 files changed

+46
-22
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "SimplexTableaux"
22
uuid = "b49aa546-d643-4829-bb91-bc1e5e539d80"
33
authors = ["Ed Scheinerman <ers@jhu.edu>"]
4-
version = "0.1.5"
4+
version = "0.2.0"
55

66
[deps]
77
ChooseOptimizer = "858a232f-1959-5553-8cfc-91e1fd5304e2"

development/examples.jl

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using SimplexTableaux, SimpleDrawing, Plots, SimpleDrawingObjects, Clines
22

33
"""
4-
dog_food()
4+
dog_food()
55
66
A,b,c for chapter 3 dogfood problem
77
"""
@@ -13,7 +13,7 @@ function dog_food()
1313
end
1414

1515
"""
16-
peanut_butter()
16+
peanut_butter()
1717
1818
A,b,c for peanut butter manufacturing problem in chapter 3
1919
"""
@@ -25,7 +25,7 @@ function peanut_butter()
2525
end
2626

2727
"""
28-
fishkind4()
28+
fishkind4()
2929
3030
DEF's example for chapter 4.
3131
"""
@@ -37,7 +37,7 @@ function fishkind4()
3737
end
3838

3939
"""
40-
fishkind400()
40+
fishkind400()
4141
4242
An example that fails the big-M method for small M.
4343
"""
@@ -49,7 +49,7 @@ function fishkind400()
4949
end
5050

5151
"""
52-
small_example()
52+
small_example()
5353
5454
Small example for section 4.4
5555
"""
@@ -217,4 +217,28 @@ function phase_one_trouble()
217217
return Tableau(A, b, c, false)
218218
end
219219

220+
"""
221+
dual_infeasible()
222+
223+
Return an LP that is infeasible and whose dual is infeasible.
224+
"""
225+
function dual_infeasible()
226+
A = [-1 -2 0 0; -3 -4 0 0; 0 0 1 2; 0 0 3 4]
227+
b = [2, 2, 4, 5]
228+
c = [2, 3, -4, -7]
229+
return Tableau(A, b, c)
230+
end
231+
232+
"""
233+
small_dual_infeasible()
234+
235+
Return an LP that is infeasible and whose dual is infeasible.
236+
"""
237+
function small_dual_infeasible()
238+
A = [-1 0; 0 1]
239+
b = [1, 1]
240+
c = [1, -1]
241+
return Tableau(A, b, c)
242+
end
243+
220244
nothing

docs/src/other.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
* `basic_vector(T)` returns the vector in which the nonbasic variables have been set to zero.
77
* `get_Abc(T)` returns the original matrix `A` and the vectors `b` and `c` for the standard presentation of the linear program.
88
* `get_basis(T)` returns the column numbers of the current basis.
9-
* `is_feasible(T)` returns `true` if the current basic vector is in the feasible region.
10-
* `is_optimal(T)` returns `true` if the tableau has reached an optimal (minimal) state.
9+
* `in_feasible_state(T)` returns `true` if the current basic vector is in the feasible region.
10+
* `in_optimal_state(T)` returns `true` if the tableau has reached an optimal (minimal) state.
1111
* `value(T)` returns the objective function value of the current basic vector.
1212

1313

src/Bases.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ function find_all_bases(T::Tableau)
6464
r, c = size(T.A)
6565
TT = deepcopy(T)
6666
result = [
67-
B for
68-
B in combinations(1:c, r) if check_basis(TT, B) && is_feasible(set_basis!(TT, B))
67+
B for B in combinations(1:c, r) if
68+
check_basis(TT, B) && in_feasible_state(set_basis!(TT, B))
6969
]
7070

7171
# T.M = TT.M

src/SimplexTableaux.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ export Tableau,
2626
find_pivot_column,
2727
get_Abc,
2828
get_basis,
29+
in_feasible_state,
30+
in_optimal_state,
2931
infer_basis!,
30-
is_feasible,
31-
is_optimal,
3232
lp_solve,
3333
matrix_pivot!,
3434
basis_pivot!,
@@ -46,22 +46,22 @@ include("Pretty.jl")
4646
include("Dual.jl")
4747

4848
"""
49-
is_feasible(T::Tableau)::Bool
49+
in_feasible_state(T::Tableau)::Bool
5050
5151
Return `true` is the current state of `T` is at a feasible vector.
5252
"""
53-
function is_feasible(T::Tableau)::Bool
53+
function in_feasible_state(T::Tableau)::Bool
5454
x = basic_vector(T)
5555
all(x .>= 0)
5656
end
5757

5858
"""
59-
is_feasible(T::Tableau, x::Vector)::Bool
59+
in_feasible_state(T::Tableau, x::Vector)::Bool
6060
6161
Return `true` is the vector `x` is a in the feasible region
6262
of the LP represented in `T`.
6363
"""
64-
function is_feasible(T::Tableau, x::Vector)::Bool
64+
function in_feasible_state(T::Tableau, x::Vector)::Bool
6565
return T.A*x == T.b && all(x .>= 0)
6666
end
6767

src/Solver.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ function simplex_solve!(T::Tableau, verbose::Bool=true)
106106

107107
pivot_count = 0
108108

109-
while !is_optimal(T)
109+
while !in_optimal_state(T)
110110
p = find_pivot(T)
111111
if 0 p
112112
if verbose

src/Tableau.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,6 @@ function value(T::Tableau)
123123
return value(T, x)
124124
end
125125

126-
function is_optimal(T::Tableau)
126+
function in_optimal_state(T::Tableau)
127127
return all(T.M[1, 2:(end - 1)] .≤ 0)
128128
end

test/runtests.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ using SimplexTableaux
99
T = Tableau(A, b, c, false)
1010

1111
simplex_solve!(T, false)
12-
@test is_feasible(T)
13-
@test is_optimal(T)
12+
@test in_feasible_state(T)
13+
@test in_optimal_state(T)
1414

15-
@test is_feasible(T)
15+
@test in_feasible_state(T)
1616

1717
set_basis!(T, [3, 4])
18-
@test !is_feasible(T)
18+
@test !in_feasible_state(T)
1919
end
2020

2121
@testset "Duality" begin

0 commit comments

Comments
 (0)