Skip to content

Commit 1121254

Browse files
committed
Bug fix in find_a_basis
1 parent eadc025 commit 1121254

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

src/Bases.jl

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,24 @@ function find_a_basis(T::Tableau)
88
m = T.n_cons
99
n = T.n_vars
1010

11+
bb = deepcopy(b)
12+
AA = deepcopy(A)
13+
1114
# ensure RHS is nonnegative
1215
for i in 1:m
13-
if b[i] < 0
14-
b[i] = -b[i]
15-
A[i, :] = -A[i, :]
16+
if bb[i] < 0
17+
bb[i] = -bb[i]
18+
AA[i, :] = -AA[i, :]
1619
end
1720
end
1821

1922
# glue an identity matrix to RHS
20-
A = hcat(A, eye(Int, m))
23+
AA = hcat(AA, eye(Int, m))
2124

2225
# create artifical c
23-
c = vcat(0*c, ones(Int, m))
26+
cc = vcat(0*c, ones(Int, m))
2427

25-
TT = Tableau(A, b, c, false)
28+
TT = Tableau(AA, bb, cc, false)
2629

2730
B = collect((n + 1):(n + m))
2831
set_basis!(TT, B)
@@ -34,7 +37,12 @@ function find_a_basis(T::Tableau)
3437
return 0*get_basis(TT)
3538
end
3639

37-
return TT.B
40+
xx = basic_vector(TT)
41+
xx = xx[1:n]
42+
43+
B = findall(iszero, xx)
44+
45+
return B
3846
end
3947

4048
# function find_a_basis(T::Tableau)::Vector{Int}

0 commit comments

Comments
 (0)