Skip to content

Commit 8c7c9ca

Browse files
committed
Add verbose option
1 parent fffa094 commit 8c7c9ca

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

src/big_M.jl

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,18 @@ end
3939
4040
Solve the LP `T` using the big-M method.
4141
"""
42-
function big_M_solve(T::Tableau, M::Int=100)
42+
function big_M_solve(T::Tableau, M::Int=100, verbose::Bool=true)
4343
TT = big_M_tableau(T, M)
44-
println("Solving this augmented tableau")
44+
if verbose
45+
println("Solving this augmented tableau")
46+
end
4547
Tx = deepcopy(TT)
4648
restore!(Tx)
47-
println(Tx)
49+
if verbose
50+
println(Tx)
51+
end
4852

49-
x = simplex_solve!(TT)
53+
x = simplex_solve!(TT, verbose)
5054

5155
if isnothing(x)
5256
return nothing
@@ -56,16 +60,20 @@ function big_M_solve(T::Tableau, M::Int=100)
5660
arts = x[(T.n_vars + 1):end]
5761

5862
if any(arts .≠ 0)
59-
@info "LP is possibly infeasible. Try a larger value than M = $M?"
63+
if verbose
64+
@info "LP is possibly infeasible. Try a larger value than M = $M?"
65+
end
6066
return nothing
6167
end
6268

6369
x = x[1:T.n_vars]
6470
B = infer_basis!(T, x)
6571
set_basis!(T, B)
66-
println("\nFinal tableau\n")
67-
println(T)
68-
v = value(T)
69-
println("Minimial value = $v = $(Float64(v))")
72+
if verbose
73+
println("\nFinal tableau\n")
74+
println(T)
75+
v = value(T)
76+
println("Minimal value = $v = $(Float64(v))")
77+
end
7078
return x
7179
end

0 commit comments

Comments
 (0)