@@ -11,11 +11,11 @@ export singleiteration!
1111export simplexiterations
1212export simplexpretty
1313export createsimplexproblem
14- export solve!
1514export gaussjordan
1615
17- import .. Utility: numround
1816
17+ import .. Utility: numround
18+ import .. OperationsResearchModels: solve!
1919
2020@enum OptimizationType begin
2121 Maximize
@@ -412,6 +412,22 @@ function singleiteration!(s::SimplexProblem)
412412 update! (s, enteringvariableindex, rowindex)
413413end
414414
415+ """
416+ solve!(s::SimplexProblem)::SimplexProblem
417+
418+ # Description
419+
420+ Solves the given SimplexProblem using the Simplex algorithm. The `solve!` function
421+ modifies the input SimplexProblem in place.
422+
423+ # Arguments
424+
425+ - `s::SimplexProblem`: The SimplexProblem to solve.
426+
427+ # Returns
428+
429+ - `SimplexProblem`: The solved SimplexProblem.
430+ """
415431function solve! (s:: SimplexProblem ):: SimplexProblem
416432 standardform! (s)
417433
@@ -424,6 +440,24 @@ function solve!(s::SimplexProblem)::SimplexProblem
424440 return s
425441end
426442
443+
444+ """
445+ simplexiterations(s::SimplexProblem)::Vector{SimplexProblem}
446+
447+ # Description
448+
449+ This function performs the Simplex iterations on the given SimplexProblem and returns the
450+ history of SimplexProblem states.
451+
452+ # Arguments
453+
454+ - `s::SimplexProblem`: The SimplexProblem to iterate.
455+
456+ # Returns
457+
458+ - `Vector{SimplexProblem}`: The history of SimplexProblem states (by iterations).
459+
460+ """
427461function simplexiterations (s:: SimplexProblem ):: Vector{SimplexProblem}
428462 iterations = Vector {SimplexProblem} (undef, 0 )
429463
@@ -484,23 +518,23 @@ end
484518"""
485519 createsimplexproblem(obj::Vector, amat::Matrix, rhs::Vector, dir::Vector, opttype::OptimizationType)::SimplexProblem
486520
487- Description:
521+ # Description
488522
489523 This function creates a SimplexProblem object from the given parameters.
490524
491- Arguments:
525+ # Arguments
492526
493527- `obj::Vector`: The objective function coefficients.
494528- `amat::Matrix`: The LHS of the constraints.
495529- `rhs::Vector`: The RHS of the constraints.
496530- `dir::Vector`: The directions of the constraints. Can be a vector of LE (<=), GE (>=), or EQ (==).
497531- `opttype::OptimizationType`: The type of the optimization. Can be Maximize or Minimize.
498532
499- Returns:
533+ # Returns
500534
501535 A SimplexProblem object.
502536
503- Example:
537+ # Example
504538
505539Suppose the linear programming problem is as follows:
506540
@@ -549,20 +583,20 @@ end
549583"""
550584 gaussjordan(A::Matrix; verbose::Bool = true)::Matrix
551585
552- Description:
586+ # Description
553587
554588 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.
555589
556- Arguments:
590+ # Arguments
557591
558592- `A::Matrix`: The matrix to find the inverse.
559593- `verbose::Bool`: If true, the intermediate steps are displayed. Default is true.
560594
561- Returns:
595+ # Returns
562596
563597 The inverse of the given matrix.
564598
565- Example:
599+ # Example
566600
567601```julia
568602julia> A = [1.0 2.0 3.0; 4.0 5.0 6.0; 7.0 8.0 10.0]
0 commit comments