The Simplex Method
Simplex
OperationsResearchModels.Simplex.createsimplexproblem
— Functioncreatesimplexproblem(obj::Vector, amat::Matrix, rhs::Vector, dir::Vector, opttype::OptimizationType)::SimplexProblem
Description:
This function creates a SimplexProblem object from the given parameters.
Arguments:
obj::Vector
: The objective function coefficients.amat::Matrix
: The LHS of the constraints.rhs::Vector
: The RHS of the constraints.dir::Vector
: The directions of the constraints. Can be a vector of LE (<=), GE (>=), or EQ (==).opttype::OptimizationType
: The type of the optimization. Can be Maximize or Minimize.
Returns:
A SimplexProblem object.
Example:
Suppose the linear programming problem is as follows:
Maximize: 1.0x1 + 2.0x2 + 3.0x3
Subject to:
1.0x1 + 2.0x2 + 3.0x3 <= 10.0
3.0x1 + 1.0x2 + 5.0x3 <= 15.0
x1, x2 >= 0
The following code creates a SimplexProblem object for the above problem:
using OperationsResearch.Simplex
obj = Float64[1.0, 2.0, 3.0]
amat = Float64[1.0 2.0 3.0; 3.0 1.0 5.0]
rhs = Float64[10.0, 15.0]
dir = [LE, LE]
opttype = Maximize
s = createsimplexproblem(obj, amat, rhs, dir, opttype)
iters = simplexiterations(s)
Gauss Jordan steps for matrix inversion
OperationsResearchModels.Simplex.gaussjordan
— Functiongaussjordan(A::Matrix; verbose::Bool = true)::Matrix
Description:
Attaches an Identity matrix to the right of the given matrix A and applies the Gauss-Jordan elimination method to find the inverse of the given matrix.
Arguments:
A::Matrix
: The matrix to find the inverse.verbose::Bool
: If true, the intermediate steps are displayed. Default is true.
Returns:
The inverse of the given matrix.
Example:
julia> A = [1.0 2.0 3.0; 4.0 5.0 6.0; 7.0 8.0 10.0]
julia> invA = gaussjordan(A, verbose = false)
3×3 Matrix{Float64}:
-0.666667 -1.33333 1.0
-0.666667 3.66667 -2.0
1.0 -2.0 1.0