From b01c479b36103dc97755f95798d137def09e6e2f Mon Sep 17 00:00:00 2001 From: "mhsatman@gmail.com" Date: Thu, 23 Nov 2023 21:12:12 +0300 Subject: [PATCH] minor changes on simplex iterations --- CHANGELOG.md | 4 ++++ src/simplex.jl | 23 +++++++++++++++++------ test/testsimplex.jl | 3 +++ 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c4faf3d..9ff8fc6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/simplex.jl b/src/simplex.jl index 9fc045f..93ef090 100644 --- a/src/simplex.jl +++ b/src/simplex.jl @@ -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 @@ -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) @@ -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, diff --git a/test/testsimplex.jl b/test/testsimplex.jl index 3d04f6a..626beb9 100644 --- a/test/testsimplex.jl +++ b/test/testsimplex.jl @@ -46,4 +46,7 @@ using OperationsResearchModels.Simplex end + + + end # end of test set Simplex