Skip to content

Commit

Permalink
minor changes on simplex iterations
Browse files Browse the repository at this point in the history
  • Loading branch information
jbytecode committed Nov 23, 2023
1 parent caea221 commit b01c479
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
### 0.1.6 (Upcoming release)

- Pretty printing simplex iterations
- Automatic calculation of objective value by iterations and manual calculation code is removed


### 0.1.5

- Add objective value in Simplex iterations
Expand Down
23 changes: 17 additions & 6 deletions src/simplex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,20 @@ function invert(d::Direction)::Direction
end
end

function Base.print(io::IO, dir::Direction)
if dir == LE
print(io, "<=")
elseif dir == GE
print(io, ">=")
elseif dir == EQ
print(io, "==")
else
error("Undefined dir: $dir")
end
end



function makerhspositive!(s::SimplexProblem)
nc = length(s.rhs)
for i in 1:nc
Expand Down Expand Up @@ -442,8 +456,6 @@ function simplexpretty(s::SimplexProblem; maxiter::Int = 1000)::Nothing
standardform!(copied)
println(copied)

standardform::SimplexProblem = copy(copied)

@info "M Method corrections:"
mmethodcorrection(copied)
println(copied)
Expand All @@ -465,12 +477,11 @@ function simplexpretty(s::SimplexProblem; maxiter::Int = 1000)::Nothing
@info "$(varnames[i]) = $(copied.rhs[i])"
end

zzz = zeros(Float64, length(copied.varnames))
zzz[copied.basicvariableindex] .= copied.rhs
goalvalue = sum(zzz .* standardform.z)
@info "Objective value: $goalvalue"
@info "Objective value: $(copied.objective_value)"
println()
end


function createsimplexproblem(
obj::Vector,
amat::Matrix,
Expand Down
3 changes: 3 additions & 0 deletions test/testsimplex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,7 @@ using OperationsResearchModels.Simplex

end




end # end of test set Simplex

0 comments on commit b01c479

Please sign in to comment.