Class SimplexLPSolver solves linear programming problems using the simplex method.
Namespace:
CenterSpace.NMath.AnalysisAssembly: NMath (in NMath.dll) Version: 5.1.0.0
Syntax
| C# |
|---|
[SerializableAttribute] public class SimplexLPSolver : ICloneable |
| Visual Basic (Declaration) |
|---|
<SerializableAttribute> _ Public Class SimplexLPSolver _ Implements ICloneable |
| Visual C++ |
|---|
[SerializableAttribute] public ref class SimplexLPSolver : ICloneable |
Remarks
A linear programming (LP) problem optimizes a linear objective function subject to
a set of linear constraints, and optionally subject to a set of variable bounds.
The simplex method solves LP problems by constructing a solution at a vertex of
a simplex, then walking along edges of the simplex to vertices with successively
higher values of the objective function until the optimum is reached. For example:
CopyC#
The Solve() method on SimplexLPSolver accepts a vector of coefficients representing
the objective function, a matrix of constraint coefficients, a vector
of right-hand sides, the number of each constraint type (less than, greater than,
or equal to), and optionally vectors of lower and upper variable bounds. Thus:
CopyC#
It is important to check the Status property after optimization, which returns
a value from the SimplexLPSolver.SolutionStatus enum, since your problem may be unbounded
or infeasible.
Maximize Z = X1 + 4 X2 + 9 X3 Subject To X1 + X2 <= 5 X1 + X3 >= 10 - X2 + X3 = 7 Bounds 0 <= X1 <= 4 0 <= X2 <= 1
DoubleVector obj = new DoubleVector( "[1 4 9]" ); DoubleMatrix constraints = new DoubleMatrix( "3x3 [1 1 0 1 0 1 0 -1 1]" ); DoubleVector rhs = new DoubleVector( "[5 10 7]" ); int numLessThan = 1; int numGreaterThan = 1; int numEqual = 1; DoubleVector upperBounds = new DoubleVector( "[4 1 Infinity]" ); SimplexLPSolver solver = new SimplexLPSolver(); DoubleVector solution = solver.Solve( obj, constraints, rhs, numLessThan, numGreaterThan, numEqual, upperBounds );