OperationsResearchModels.Simplex.createsimplexproblem — Function
createsimplexproblem(obj::Vector, amat::Matrix, rhs::Vector, dir::Vector, opttype::OptimizationType)::SimplexProblemDescription
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.
Examples
Primal Simplex
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, x3 >= 0The following code creates a SimplexProblem object for the above problem:
using OperationsResearchModels.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)Dual Simplex
Suppose the linear programming problem is as follows:
Minimize: 10.0x1 + 20.0x2
Subject to:
2.0x1 + 3.0x2 >= 5.0
1.0x1 + 4.0x2 >= 10.0
x1, x2 >= 0The following code creates a SimplexProblem object for the above problem and solves it using the Dual Simplex method:
using OperationsResearchModels.Simplex
obj = Float64[10.0, 20.0]
amat = Float64[2.0 3.0; 1.0 4.0]
rhs = Float64[5.0, 10.0]
dir = [GE, GE]
opttype = Minimize
s = createsimplexproblem(obj, amat, rhs, dir, opttype)
solve!(s, method = Dual)